Calling xsl variables and params within attribute values

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Calling xsl variables and params within attribute values

flyingzumwalt
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:

          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" 
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>


Default Submission:
<my>
<path>myvalue</path>
</my>


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Calling xsl variables and params within attribute values

Alexander Žaťko
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: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 
<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:

          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" 
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>


Default Submission:
<my>
<path>myvalue</path>
</my>

--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
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
Reply | Threaded
Open this post in threaded view
|

RE: Calling xsl variables and params within attribute values

Ryan Puddephatt
In reply to this post by flyingzumwalt
Matt,
    I don't think this works, but saxon:evaluate($my-path) will work

Ryan
 

Ryan Puddephatt
Software Engineer
 

Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP
 
e> [hidden email]
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com

 


From: Matt Zumwalt [mailto:[hidden email]]
Sent: 15 November 2006 23:25
To: [hidden email]
Subject: [ops-users] Calling xsl variables and params within attribute values

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">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
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>


Default Submission:
<my>
<path>myvalue</path>
</my>


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Calling xsl variables and params within attribute values

Alessandro  Vernet
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
Reply | Threaded
Open this post in threaded view
|

Re: Calling xsl variables and params within attribute values

flyingzumwalt
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:

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:

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:

          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
 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>



Default Submission:
<my>
 <path>myvalue</path>
</my>




Matt Zumwalt



--
You receive this message as a subscriber of the [hidden email]
mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws





-- 
Blog (XML, Web apps, Open Source):


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
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