[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Need help using variable in select statement

Subject: RE: Need help using variable in select statement
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 26 Sep 2005 16:11:20 +0100
use variable in select statement
Variables in XPath represent values, they don't (like macro variables in a
shell language) represent bits of text to be inserted textually into an
expression.

To evaluate an XPath expression read at run-time from a source document, use
an xx:evaluate() expression if your XSLT processor offers one. This can't be
done in pure XSLT without extensions. Namespace prefixes can make it messy
even with extensions.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Frank Stoner [mailto:fstoner@xxxxxxx] 
> Sent: 26 September 2005 15:38
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Need help using variable in select statement 
> 
> I'm trying to mimic the functionality of a tag used in  
> documenting .NET C# code.
> The tag identifies a file and path location of xml content to merge  
> into the source document.
> 
> <include file="content.xml" path="/Top/Child[@name='Me']/*" />
> 
> The template that I have written to translate this tag is simply:
> 
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ 
> Transform">
>      <xsl:template match="include">
>          <xsl:variable name="file" select="@file"/>
>          <xsl:variable name="path" select="@path"/>
>          <xsl:copy-of select="document($file)$path"/>
>      </xsl:template>
> </xsl:stylesheet>
> 
> The problem is that the use of the $path variable in the "select="  
> statement seems to violate some syntax rule and all I get is a  
> complaint about an unexpected token on that line.
> 
> Now if I substitute the variable value "Top/Child[@name='Me']/*" in  
> place of the "$path" variable, the template works as expected.
> 
> I've tried a number of ways to build the select statement, but none  
> have worked out.  Any suggestions?
> 
> Thanks,
> Frank

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.