Subject: RE: Reusing XPath statements (defining once and only once)
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 18 Apr 2003 12:01:51 +0100
|
> >The stylesheet works, but the XPath expressions bother me. I
> would like
> >to declare this XPath once:
> >
> >@* | * | comment() | processing-instruction() | text()
> >
> >and refer to it elsewhere. I tried to make it a variable, but it
> >doesn't seem to work.
>
> Nope, it's not going to. Variables are bound to values, not
> to expressions
> that can be evaluated.
In XSLT 2.0, of course, you can define this as a function:
<xsl:function name="my:sprogs">
<xsl:param name="here" as="node"/>
<xsl:result select="$here/node() | $here/@*"/>
</xsl:function>
Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|