Subject: RE: [xsl] Can I substitute a predefined path/expression within the [..] tags? From: "Ganesh Murthy" <ganesh.murthy@xxxxxxxx> Date: Thu, 23 Jan 2003 09:59:47 -0600 |
Jeni.. that worked pretty good. For my case, the list-variable option is probably the one I want. Thanks a ton!! Ganesh. -----Original Message----- From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx] Sent: Thursday, January 23, 2003 9:27 AM To: Ganesh Murthy Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Can I substitute a predefined path/expression within the [..] tags? Hi Ganesh, > I have several references in my stylesheet to a pattern that resembles: > > Node[@name='AA' or @name='BB'] > > With time, I continuously need to update this pattern to include > newer attributes @name='CC', @name='DD' and so on. > > Instead of repeating this addition in every match in the stylesheet, > I am wondering if there is some way to store this path/expression: > > myexpression = "Node[@name='AA' or @name='BB']" or > myexpression = "@name='AA' or @name='BB' " > > and use 'myexpression' in my pattern matches. That way, I will have > only one location to update. I have tried using variables without > success. I think that the best thing is to construct a list of the names that you're interested in and then check whether @name is in that list. You could use a string containing the list: <xsl:variable name="names" select="' AA BB '" /> <xsl:apply-templates select="Node[contains($names, concat(' ', @name, ' '))]" /> Or you could construct a node set containing the names as a list of elements. For example, you could have a separate document, names.xml, that looked like: <names> <name>AA</name> <name>BB</name> </names> and then do: <xsl:variable name="names" select="document('names.xml')/names/name" /> <xsl:apply-templates select="Node[@name = $names]" /> You could use the latter method with a result tree fragment that you convert to a node set using an extension node-set() function if you didn't want to create a separate document. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Can I substitute a predef, Jeni Tennison | Thread | RE: [xsl] Can I substitute a predef, Conal Tuohy |
RE: Re: [xsl] No-output identity te, cknell | Date | RE: [xsl] No-output identity templa, Roger Glover |
Month |