472,988 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 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 1277
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.