Re: [xsl] Evaluating XSLT Expressions At Run-Time

Subject: Re: [xsl] Evaluating XSLT Expressions At Run-Time
From: "George Cristian Bina" <george@xxxxxxx>
Date: Fri, 9 Jan 2004 10:11:41 +0200
Hi,

You can just use:

<xsl:apply-templates select="*[name() = $Node_Name]" />

for:

> <xsl:apply-templates select="$Node_Name" />

As an example the following stylesheet:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
    <xsl:template match="/">
        <xsl:variable name="test" select="'x'"/>
        <xsl:apply-templates select="//*[name()=$test]"/>
    </xsl:template>
    <xsl:template match="x">Got x!</xsl:template>
</xsl:stylesheet>

applied on

<?xml version="1.0" encoding="UTF-8"?>
<test>
   <x></x>
   <x><y></y></x>
</test>

will give you

<?xml version="1.0" encoding="utf-8"?>
        Got x!

        Got x!

HTH,
George
-------------------------------------------------------------
George Cristian Bina mailto:george@xxxxxxxxxxxxx
<oXygen/> XML Editor - http://www.oxygenxml.com/


----- Original Message -----
From: "Schwartz, Rechell R, ALABS" <rrschwartz@xxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, January 09, 2004 9:26 AM
Subject: [xsl] Evaluating XSLT Expressions At Run-Time


> All,
>
> I was wondering if there was a way to evaluate XSLT Expressions at
> run-time without resorting to using extensions. Specifically, what I am
> trying to do is as follows (this is a simplified version to ease the
> explanation). I have 2 XML documents: one that has my real XML data and
> a second document that specifies the node names that are identified in
> my first document. Depending upon what node name is read from the second
> document, I want the string value of that node name to be used in the
> line <xsl:apply-templates select="$Node_Name" />, so that a different
> template is called depending upon what the string value of  $Node_Name
> evaluates to. Any help would be greatly appreciated.
>
> <xsl:template match="ElementFromFirstXMLDoc">
> <xsl:variable name="Data" select="document('doc2.xml')/Data" />
>  <xsl:for-each select="$Data/Node">
> <xsl:variable name="Node_Name" select="NodeName" />
> <xsl:apply-templates select="$Node_Name" />
> </xsl:template>
>
> Thanks,
> Rechell Schwartz
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread