Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > parameters in a search with match

Reply
Thread Tools

parameters in a search with match

 
 
Iain
Guest
Posts: n/a
 
      12-09-2003
I've got some XLST which extracts some stuff from a config file. it works
nicely. Now I want to make it work with a parameter

My original attempt looked like (fragment)

<xslaram name="StyleName" />

<xsl:template match="/Vendor/Style[@Name=$StyleName]" >

And failed. (replace $StyleName in the above with a real style name and it
works correctly). Eventually, I came up with this ...

<xslaram name="StyleName" />

<xsl:template match="/Vendor" >

<xsl:for-each select="Style[@Name=$StyleName]" >

Which works also. But WHY won't it work with the match?

Iain

PS. I claim no skill in these areas - xslt/xpath and their friends are NOT
pellicidly clear.


 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      12-09-2003
A match pattern cannot have a variable/parameter references in XSLT 1.0
because this might lead to circular definitions (the referenced xsl:variable
may have xsl:apply-templates in its body and the template that references
this variable may be applied ...)

The workaround is the following:

Instead of:

match = "aPatternWithVariableReference"

use:

<xsl:template match="correctPattern">
<xsl:if test="someConditionWithTheVariableReference">
<!-- The whole processing goes only here -->
</xsl:if>
</xsl:template>

As you can see, this would be equivalent to:

<xsl:template
match="correctPattern[someConditionWithTheVariableReference]">
<!-- Whatever processing should be performed -->
</xsl:template>

if the latter were allowed.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


"Iain" <(E-Mail Removed)> wrote in message
news:WvpBb.989$(E-Mail Removed)...
> I've got some XLST which extracts some stuff from a config file. it works
> nicely. Now I want to make it work with a parameter
>
> My original attempt looked like (fragment)
>
> <xslaram name="StyleName" />
>
> <xsl:template match="/Vendor/Style[@Name=$StyleName]" >
>
> And failed. (replace $StyleName in the above with a real style name and

it
> works correctly). Eventually, I came up with this ...
>
> <xslaram name="StyleName" />
>
> <xsl:template match="/Vendor" >
>
> <xsl:for-each select="Style[@Name=$StyleName]" >
>
> Which works also. But WHY won't it work with the match?
>
> Iain
>
> PS. I claim no skill in these areas - xslt/xpath and their friends are

NOT
> pellicidly clear.
>
>



 
Reply With Quote
 
 
 
 
Iain
Guest
Posts: n/a
 
      12-09-2003
Thanks!

Iain
"Dimitre Novatchev" <(E-Mail Removed)> wrote in message
news:br5a8n$28oqvd$(E-Mail Removed)-berlin.de...
> A match pattern cannot have a variable/parameter references in XSLT 1.0
> because this might lead to circular definitions (the referenced

xsl:variable
> may have xsl:apply-templates in its body and the template that references
> this variable may be applied ...)
>
> The workaround is the following:
>
> Instead of:
>
> match = "aPatternWithVariableReference"
>
> use:
>
> <xsl:template match="correctPattern">
> <xsl:if test="someConditionWithTheVariableReference">
> <!-- The whole processing goes only here -->
> </xsl:if>
> </xsl:template>
>
> As you can see, this would be equivalent to:
>
> <xsl:template
> match="correctPattern[someConditionWithTheVariableReference]">
> <!-- Whatever processing should be performed -->
> </xsl:template>
>
> if the latter were allowed.
>
> =====
> Cheers,
>
> Dimitre Novatchev.
> http://fxsl.sourceforge.net/ -- the home of FXSL
>
>
> "Iain" <(E-Mail Removed)> wrote in message
> news:WvpBb.989$(E-Mail Removed)...
> > I've got some XLST which extracts some stuff from a config file. it

works
> > nicely. Now I want to make it work with a parameter
> >
> > My original attempt looked like (fragment)
> >
> > <xslaram name="StyleName" />
> >
> > <xsl:template match="/Vendor/Style[@Name=$StyleName]" >
> >
> > And failed. (replace $StyleName in the above with a real style name and

> it
> > works correctly). Eventually, I came up with this ...
> >
> > <xslaram name="StyleName" />
> >
> > <xsl:template match="/Vendor" >
> >
> > <xsl:for-each select="Style[@Name=$StyleName]" >
> >
> > Which works also. But WHY won't it work with the match?
> >
> > Iain
> >
> > PS. I claim no skill in these areas - xslt/xpath and their friends are

> NOT
> > pellicidly clear.
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
re.sub(): replace longest match instead of leftmost match? John Gordon Python 13 12-20-2011 02:58 AM
pat-match.lisp or extend-match.lisp in Python? ekzept Python 0 08-10-2007 06:08 PM
Match doesn't match Volkan Civelek Ruby 4 07-19-2006 07:44 AM
$match = true() for empty $match?? Victor XML 2 05-17-2004 10:43 AM
Java regex can't match lengthy match? hiwa Java 0 01-29-2004 10:09 AM



Advertisments