|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] parameter use in XPath
Hello,
Is it possible to use the parameter "keyword" (line 1) in
XPath expressions (lines 5, 13, and 27) in the following stylesheet
without the use of specific processor extensions?
I know one may not use variables set by the stylesheet in
XPath expressions, but $keyword is passed from the command line
and thus not computed or set by the stylesheet.
Many thanks in advance,
Saverio
--
1:<xsl:param name="keyword"/>
2:<xsl:template match="{$keyword}">
3: <xsl:apply-templates/>
4:</xsl:template>
<!-- matches all nodes which have a descendant-or-self,
which is an ancestor-or-self::d and a leaf,
and does nothing with them -->
5:<xsl:template match="node()[not (descendant-or-self::node()[ancestor-or-self::{$keyword} and count (child::node()) = 0])]">
6: <xsl:variable name="original-node" select="."/>
7: <xsl:variable name="original-node-name" select="name()"/>
8: <xsl:variable name="original-node-id" select="@id"/>
<!-- match a node who has a descendant with a refid attribute, e.g., e -->
9: <xsl:if test="descendant::node()[@refid]">
10: <xsl:for-each select="descendant::node()[@refid]">
11: <xsl:variable name="target-id" select="@refid"/>
12: <xsl:variable name="target-node" select="//node()[@id=$target-id]"/>
13: <xsl:if test="$target-node[descendant-or-self::node()[ancestor-or-self::{$keyword} and count (child::node()) = 0]]">
14: <xsl:element name="{$original-node-name}">
15: <xsl:attribute name="id">
16: <xsl:value-of select="$original-node-id"/>
17: </xsl:attribute>
18: <xsl:apply-templates select="$original-node/*"/>
19: </xsl:element>
20: </xsl:if>
21: </xsl:for-each>
22: </xsl:if>
23:</xsl:template>
<!-- matches all crosslinks and -->
24:<xsl:template match="node()[@refid]" priority="0.7">
25: <xsl:variable name="target-id" select="@refid"/>
26: <xsl:variable name="target-node" select="//node()[@id=$target-id]"/>
<!-- only copies those which have a descendant-or-self,
which has a reference to a node,
which is an ancestor-or-self::d and a leaf -->
27: <xsl:if test="$target-node[descendant-or-self::node()[ancestor-or-self::{$keyword} and count (child::node()) = 0]]">
28: <xsl:copy>
29: <xsl:attribute name="refid">
30: <xsl:value-of select="$target-id"/>
31: </xsl:attribute>
32: </xsl:copy>
33: </xsl:if>
34:</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








