xsl-list
[Top] [All Lists]

RE: string parameter to node-set?

2003-01-03 11:26:12
Some products offer an xx:evaluate() extension function that allows you
to evaluate an XPath expression supplied as a string.

The other technique is to create or modify the stylesheet source before
compiling it.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
bernd(_at_)gauweiler(_dot_)net
Sent: 03 January 2003 16:41
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] string parameter to node-set?


I am at a loss, and wonder if anybody can help: I pass two parameter 
from Javascript into XSLT, the URI of an XML document and an XPath 
expression. Both parameters are strings as far as JavaScript 
is concerned.

I can load the XML data with document($para-xml) just fine:

    <xsl:param name="para-xml"/>
    <xsl:param name="para-xpath" select="'/'"/>

    <xsl:template match="/">
        <xsl:apply-templates select="document($para-xml)" 
mode="transform"/>
    </xsl:template>

Next, I would like to use the XPath expression to select the 
node(s) the 
subsequent transformation should apply to. Something along 
the lines of 
this:

    <xsl:template match="/" mode="transform">
        <xsl:apply-templates select="/root/data[(_at_)id='whatever']"/>
    </xsl:template>

That works great, too. However, I find myself unable to using 
the XPath 
parameter instead of the constant XPath expression, as in

    <xsl:template match="/" mode="transform">
        <xsl:apply-templates select="$para-xpath"/>
    </xsl:template>

I suppose this is because the parameter is of type string, and the 
select attribute requires a node set. How do I solve this?

The key problem is that I need to transform a subset of a larger XML 
stream, where the subset is defined through an XPath 
expression and all 
this must happen within XSL in order to avoid cross-domain security 
constrains in JavaScript. Any recommendations welcome.

TIA
Bernd


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



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



<Prev in Thread] Current Thread [Next in Thread>