![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Cand XSLT evaluate XPath in String variable? >Thread Next - Re: Cand XSLT evaluate XPath in String variable? - Thanks. Re: Cand XSLT evaluate XPath in String variable? - Thanks.To: NULL Date: 1/5/2005 9:53:00 AM Thank you.
It works perfectly.
I attach the dyn:evaluate example XSL for someone who has the same
problem as mine. With xalan, no need to do anything to use dyn:evaluate.
Just use.
----------------------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:dyn="http://exslt.org/dynamic"
extension-element-prefixes="dyn"
>
<xsl:output method="xml"/>
<xsl:template match="/">
<ROOT>
<xsl:apply-templates />
</ROOT>
</xsl:template>
<xsl:template match="xpath">
<RESULT>
<XPATH><xsl:value-of select="."/></XPATH>
<xsl:variable name="xpathstr"
select="concat('document("data.xml")',.)"/>
<VALUE><xsl:value-of select="dyn:evaluate($xpathstr)"/></VALUE>
</RESULT>
</xsl:template>
</xsl:stylesheet>
Son KwonNam wrote:
> In XSLT, is this possible to get value from xml using XPath
> which is in XSLT variable?
>
> I mean XPath strings can be dynamic while XSL Transforming.
>
> If possible, How??
>
> Because I'm not a native English speaker, it's quite hard
> to make the problem clear. Please see the following example.
>
> There are two XML files.
> One has data, and the other has xpath. I will transform
> the XPath XML.
>
> for example,
>
> * XPath XML
> <xpaths>
> <xpath>/students/student/name</xpath>
> <xpath>/students/student/id</xpath>
> </xpaths>
>
> * Data XML : data.xml
> <students>
> <student>
> <name>John Doe</name>
> <id>234234</id>
> </student>
> </students>
>
> * XSL snippet.
> <xsl:template match="//xpath">
> <xsl:variable name="xpathstring" select="."/>
> <B>XPaht : <xsl:value-of select="$xpathstring"/></B>
> <B>Value : <xsl:value-of select="document('data.xml')/$xpathstring" />
> </B> </xsl:template>
>
>
> As you know, that <xsl:value-of select(document(bla...)/> line
> does not
> work.
>
> Any solution for this problem in XSLT?
> I use JDOM/Xalan for transforming.
>
> Thanks,
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
