Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: passing in an element as a parameter to a stylesheet

From: richard@------.--.--.-- (------- -----)
To: 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.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent