dynamic generate the document() function

dynamic generate the document() function

Post by Jens Heinric » Tue, 08 Jul 2003 02:28:51



Hi all,

I have some problem.
The document() Function with fix parameter works very well:

<xsl:value-of select="document('test.xml')//Name/FirstName"/>

...but I have the path of the context node and want to set this path
dynamicly to this
function.
The path are saved in the variable xpath.

I want to build some statement like:
<xsl:value-of select="document('test.xml') + $xpath"/>    (perhaps,  the
"+"doesn't work)
to get the value of the node.

<xsl:value-of select="document(('test.xml'),$xpath) "/> doesn't work.

Thanks

Jens

 
 
 

dynamic generate the document() function

Post by Marro » Tue, 08 Jul 2003 09:38:22


Hi Jens,


Quote:> I have some problem.
> The document() Function with fix parameter works very well:

> <xsl:value-of select="document('test.xml')//Name/FirstName"/>

> ...but I have the path of the context node and want to set this path
> dynamicly to this
> function.
> The path are saved in the variable xpath.

> I want to build some statement like:
> <xsl:value-of select="document('test.xml') + $xpath"/>    (perhaps,  the
> "+"doesn't work)
> to get the value of the node.

> <xsl:value-of select="document(('test.xml'),$xpath) "/> doesn't work.

Firstly, this has nothing to do with the document() function really.

None of what you are trying will work - there is no syntax for doing this
because it cannot be done in XSLT+XPath.  IOW, XSLT and XPath cannot macro
evaluate a string as an XPath expression.

However, some transformation engines do have extension functions that might
enable you to do this (e.g. the evaluate() extension function in some
engines) - but of course this makes the XSLT code less portable.

Cheers
Marrow
http://www.veryComputer.com/ - home of Xselerator (XSLT IDE and de*)
http://www.veryComputer.com/

 
 
 

dynamic generate the document() function

Post by Marro » Tue, 08 Jul 2003 09:38:22


Hi Jens,


Quote:> I have some problem.
> The document() Function with fix parameter works very well:

> <xsl:value-of select="document('test.xml')//Name/FirstName"/>

> ...but I have the path of the context node and want to set this path
> dynamicly to this
> function.
> The path are saved in the variable xpath.

> I want to build some statement like:
> <xsl:value-of select="document('test.xml') + $xpath"/>    (perhaps,  the
> "+"doesn't work)
> to get the value of the node.

> <xsl:value-of select="document(('test.xml'),$xpath) "/> doesn't work.

Firstly, this has nothing to do with the document() function really.

None of what you are trying will work - there is no syntax for doing this
because it cannot be done in XSLT+XPath.  IOW, XSLT and XPath cannot macro
evaluate a string as an XPath expression.

However, some transformation engines do have extension functions that might
enable you to do this (e.g. the evaluate() extension function in some
engines) - but of course this makes the XSLT code less portable.

Cheers
Marrow
http://www.veryComputer.com/ - home of Xselerator (XSLT IDE and de*)
http://www.veryComputer.com/