Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Cand XSLT evaluate XPath in String variable? - Thanks.

From: Son KwonNam <kwon37xi@--------.--->
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(&quot;data.xml&quot;)',.)"/>
            <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,


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent