473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

dynamic matching

Hello

I'd like to match a dynamic node, given as a parameter to the
stylesheet. Something like:

<xsl:stylesheet ...>
<xsl:param name="tomatch"/>
<xsl:template match="{$tomatch}">
Hallo
</xsl:template>
</xsl:stylesheet>

However, this seems not to be so simple, as "{" and if I remove the
parentesis the "$" are not allowed in the match value.

Certainly, I could take this as a row xslt and pre-transform it with
another script to merge the value of the variable into the {$tomatch}
location. However, then I would need two steps, one to create the
merged xslt, and another to transform the xml with it.

Is there a way to get it simlier? Any idea how to match dynamic nodes
given in parameters would be highly appreciated.

Thanks in advance.
Daniel Frey

Jul 20 '06 #1
5 1302
Search for FXSL

Cheers,
Dimitre Novatchev

"Daniel Frey" <qw*******@gmx.chwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hello

I'd like to match a dynamic node, given as a parameter to the
stylesheet. Something like:

<xsl:stylesheet ...>
<xsl:param name="tomatch"/>
<xsl:template match="{$tomatch}">
Hallo
</xsl:template>
</xsl:stylesheet>

However, this seems not to be so simple, as "{" and if I remove the
parentesis the "$" are not allowed in the match value.

Certainly, I could take this as a row xslt and pre-transform it with
another script to merge the value of the variable into the {$tomatch}
location. However, then I would need two steps, one to create the
merged xslt, and another to transform the xml with it.

Is there a way to get it simlier? Any idea how to match dynamic nodes
given in parameters would be highly appreciated.

Thanks in advance.
Daniel Frey

Jul 21 '06 #2
This is related to the thread "expand parts of an xml, which is
transformed by xslt to html". Either use the EXSLT
dynamic-XPath-evaluation extensions (if available), or figure out a way
to express your selection request in a form that lets you write an
interpreter in XSLT to evaluate it.

EXSLT is supported by many XSLT processors these days... but not all.
Depending on what you're trying to do, that possible loss of portability
may or may not be a problem.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jul 21 '06 #3
Thanks Joe for the hint. I looked at EXSLT and tried node-set(),
evaluate() and document(). But still, the parser does complain about
"$" in the match value. I read in Michael Kays XSLT 2nd Edition that
any sort of variable is disalowed in the match attribute to prevent
circular definitions. So it seem that there is no way to use the match
attribute.

Maybe there is another way to achive the same result. I'd like to use a
template to handle dynamic structures as described in my first post. Is
there another way to handle dynamic matches?

Daniel

Joe Kesselman schrieb:
This is related to the thread "expand parts of an xml, which is
transformed by xslt to html". Either use the EXSLT
dynamic-XPath-evaluation extensions (if available), or figure out a way
to express your selection request in a form that lets you write an
interpreter in XSLT to evaluate it.

EXSLT is supported by many XSLT processors these days... but not all.
Depending on what you're trying to do, that possible loss of portability
may or may not be a problem.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jul 21 '06 #4
Thanks for the hint Dimitre. How would FXSL help me doing that?

Daniel

Dimitre Novatchev schrieb:
Search for FXSL

Cheers,
Dimitre Novatchev

"Daniel Frey" <qw*******@gmx.chwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hello

I'd like to match a dynamic node, given as a parameter to the
stylesheet. Something like:

<xsl:stylesheet ...>
<xsl:param name="tomatch"/>
<xsl:template match="{$tomatch}">
Hallo
</xsl:template>
</xsl:stylesheet>

However, this seems not to be so simple, as "{" and if I remove the
parentesis the "$" are not allowed in the match value.

Certainly, I could take this as a row xslt and pre-transform it with
another script to merge the value of the variable into the {$tomatch}
location. However, then I would need two steps, one to create the
merged xslt, and another to transform the xml with it.

Is there a way to get it simlier? Any idea how to match dynamic nodes
given in parameters would be highly appreciated.

Thanks in advance.
Daniel Frey
Jul 21 '06 #5
Hi Daniel,

I was mislead by the wording: "match a dynamic node, given as a parameter ",
which sounds as a good description what a higher-order xsl:function does --
with the exception that we should say "apply-templates to a dynamic node,
given as a parameter ".

Reading your post for a second time I understand what you want. One way to
achieve this is, supposing that the $tomatch parameter is defined as a
single node, is to have the following template:

<xsl:template match="node() | @*">

<xsl:choose>
<xsl:when test="generate-id() = generate-id($tomatch)">
Hallo
</xsl:when>
<xsl:otherwise>
<xsl:apply-imports/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
You have to assure this template has the highest import-precedence and that
any other templates are part of stylesheets imported by the stylesheet that
contains the above template. Not very convenient, but possible to do.

In XSLT 2.0 one can use the <xsl:next-matchinstruction -- designed to
eliminate the inconvenience of using <xsl:apply-importsin a case like
this -- the overridden templates that are invoked can now be in the same
stylesheet.

Hope this helped.
Cheers,
Dimitre Novatchev
"Daniel Frey" <qw*******@gmx.chwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Thanks for the hint Dimitre. How would FXSL help me doing that?

Daniel

Dimitre Novatchev schrieb:
>Search for FXSL

Cheers,
Dimitre Novatchev

"Daniel Frey" <qw*******@gmx.chwrote in message
news:11**********************@p79g2000cwp.googleg roups.com...
Hello

I'd like to match a dynamic node, given as a parameter to the
stylesheet. Something like:

<xsl:stylesheet ...>
<xsl:param name="tomatch"/>
<xsl:template match="{$tomatch}">
Hallo
</xsl:template>
</xsl:stylesheet>

However, this seems not to be so simple, as "{" and if I remove the
parentesis the "$" are not allowed in the match value.

Certainly, I could take this as a row xslt and pre-transform it with
another script to merge the value of the variable into the {$tomatch}
location. However, then I would need two steps, one to create the
merged xslt, and another to transform the xml with it.

Is there a way to get it simlier? Any idea how to match dynamic nodes
given in parameters would be highly appreciated.

Thanks in advance.
Daniel Frey

Jul 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
0
by: CSDunn | last post by:
Hello, I have a format issue on an Access 2000 ADP report that I am going to attempt to explain from a 'ten thousand foot view' : I have an Access 2000 ADP report that has a SQL Server 2000...
9
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the...
1
by: russ | last post by:
Hi all, Here's a problem I'm having with a dynamic table. Following the guidelines here (http://www.codeproject.com/aspnet/dynamiccontrols.asp), which make perfect sense. The problem is that...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
2
by: jmgopi | last post by:
Hi: Can somebody provide me samples on how to create a dynamic CollapsiblePanel using ASP.NET AJAX Toolkit. Any points are highly appreciated. Thanks, GJM
13
by: Jess | last post by:
Hello, I have some questions to do with dynamic binding. The example program is: #include<iostream> using namespace std; class A{
4
by: Bongard | last post by:
I have a dynamic range that I would like to use as a linked table into Access. The problem is that Access doesn't seem to want to to recognize the dynamic range when you click on "show named...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.