I'm sure I've done this a million times, but now I'm suddenly getting errors. I want to store part of an XPath expression as an xsl:variable and then call it later on in my template. Normal syntax should be
<xsl:value-of select="{$my-param}"/> ... but this doesn't work. Have I missed something? Here is an example in an XPL pipeline, using XSLT processor: <p:param name="instance" type="input"/> <p:param name="data" type="output"/> <p:processor name="oxf:xslt"> <p:input name="data" href="#instance"/> <p:input name="config"> version="2.0"> <xsl:variable name="mypath">/my/path</xsl:variable> <xsl:template match="/"> <head> <title>XSL Param Usage Test</title> </head> <body> <p><strong>Variable Alone:</strong><xsl:value-of select="$mypath"/></p> <p><strong>Value of node pointed to by path:</strong><xsl:value-of select="/my/path"/></p> <p> <strong>Value of node pointed to by path, accessed using variable:</strong> <!-- The Offending Line. If I uncomment this, OPS throws an error. --> <!-- <xsl:value-of select="{$mypath}"/> --> </p> </body> </html> </xsl:template> </xsl:stylesheet> </p:input> <p:output name="data" id="boo" ref="data" /> </p:processor> </p:config> -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Matt,
One way to do what you want is to use function like saxon:evaluate() to have the XSL engine evaluate the path stored in variable. Otherwise the content of the variable is treated as string. Try this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:saxon="http://saxon.sf.net/"> <xsl:variable name="mypath">/my/path</xsl:variable> <xsl:template match="/"> <head> <title>XSL Param Usage Test</title> </head> <body> <p><strong>Variable Alone:</strong><xsl:value-of select="$mypath"/></p> <p><strong>Value of node pointed to by path:</strong><xsl:value-of select="/my/path"/></p> <p> <strong>Value of node pointed to by path, accessed using variable:</strong> <!-- The Offending Line. If I uncomment this, OPS throws an error. --> [<xsl:value-of select="saxon:evaluate($mypath)"/>] <!-- --> </p> </body> </html> </xsl:template> </xsl:stylesheet> On Nov 16, 2006, at 12:24 AM, Matt Zumwalt wrote: I'm sure I've done this a million times, but now I'm suddenly getting errors. I want to store part of an XPath expression as an xsl:variable and then call it later on in my template. Normal syntax should be -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
In reply to this post by flyingzumwalt
Matt,
I don't think this works, but
saxon:evaluate($my-path) will work
Ryan Ryan
Puddephatt
-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
In reply to this post by flyingzumwalt
Matt,
If you have an XPath expression in a string, and you want to evaluate it, you will need to use a Saxon extension: saxon:evaluate(). It looks like: <xsl:value-of select="saxon:evaluate($mypath)"/> See more at: http://www.saxonica.com/documentation/extensions/functions/evaluate.html Alex On 11/15/06, Matt Zumwalt <[hidden email]> wrote: > I'm sure I've done this a million times, but now I'm suddenly getting > errors. I want to store part of an XPath expression as an xsl:variable and > then call it later on in my template. Normal syntax should be > <xsl:value-of select="{$my-param}"/> > > ... but this doesn't work. Have I missed something? > > Here is an example in an XPL pipeline, using XSLT processor: > > <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" > xmlns:oxf="http://www.orbeon.com/oxf/processors" > xmlns:xforms="http://www.w3.org/2002/xforms" > xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> > > > <p:param name="instance" type="input"/> > <p:param name="data" type="output"/> > > > > > > > <p:processor name="oxf:xslt"> > <p:input name="data" href="#instance"/> > <p:input name="config"> > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:exist="http://exist.sourceforge.net/NS/exist" > version="2.0"> > <xsl:variable name="mypath">/my/path</xsl:variable> > <xsl:template match="/"> > <html xmlns="http://www.w3.org/1999/xhtml" > xmlns:html="http://www.w3.org/1999/xhtml"> > <head> > <title>XSL Param Usage Test</title> > </head> > <body> > <p><strong>Variable Alone:</strong><xsl:value-of select="$mypath"/></p> > <p><strong>Value of node pointed to by path:</strong><xsl:value-of > select="/my/path"/></p> > <p> > <strong>Value of node pointed to by path, accessed using variable:</strong> > > > <!-- The Offending Line. If I uncomment this, OPS throws an error. --> > <!-- > <xsl:value-of select="{$mypath}"/> > --> > </p> > </body> > </html> > </xsl:template> > </xsl:stylesheet> > </p:input> > <p:output name="data" id="boo" ref="data" /> > </p:processor> > > > > > > > </p:config> > > > > Default Submission: > <my> > <path>myvalue</path> > </my> > > > > > Matt Zumwalt > http://flyingzumwalt.blogspot.com > > > > -- > You receive this message as a subscriber of the [hidden email] > mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws > > > -- Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Thanks to everyone who offered help with this one. Everything is working smoothly now.
Matt Zumwalt MediaShelf, LLC On Nov 16, 2006, at 6:48 PM, Alessandro Vernet wrote:
-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |