Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - passing in an element as a parameter to a stylesheet >Thread Next - Re: passing in an element as a parameter to a stylesheet Re: passing in an element as a parameter to a stylesheetTo: NULL Date: 8/2/2007 12:36:00 PM
In article <DZjsi.41827$%v3.7939@f...>,
Andy Fish <ajfish@b...> wrote:
>the question is, is there a way to match only the root node element of the
>input document rather than the root element of a stylesheet parameter
match="/" doesn't match the root element, it matches the root node which
is above the root element (so that it can contain, for example, processing
instructions before the root element). But I don't think that matters to
your question, which is how to distinguish the root node of the
input document from the root node of other documents.
The only way I can think of to do this is to bind a variable to the
root node of the input document:
<xsl:variable name="input-root" select="/"/>
(which works because top-level variable declarations have the root node
of the input document as their current node) and compare the node against
that, for example
<xsl:template match="/[count(.|$input-root) = 1]">
("count($a|$b)=1" is a way of testing two nodes for identity - if they're
the same then the set containing both of them will only have one element).
I haven't tested this.
-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
