Re: [xsl] comparing XML streams / nodesets

Subject: Re: [xsl] comparing XML streams / nodesets
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Wed, 19 Dec 2001 18:04:33 -0500
[Martijn" <rootroot@xxxxxxxxx>]

> I have a question. I've got an XML document containing the following
> nodeset:
>
> <rootnode>
>     <childnode>
>         <grantchildnode1 />
>         <grantchildnode2 />
>         <grantchildnode3>
>             <grantchildnode31 />
>             <grantchildnode32 />
>         </grantchildnode3>
>     </childnode>
> </rootnode>
>
> Now in XSL, I have a variable that declares which entities are allowed
into
> certain functions like this:

First of all, please do not call them "entities".  That only confuses
people, sinse the term means something specific.  You seem to mean
"elements".
>
> <xsl:variable name="allowednodes">
>     <rootnode>
>         <childnode>
>             <grantchildnode1 />
>             <grantchildnode3>
>                 <grantchildnode32 />
>             </grantchildnode3>
>         </childnode>
>     </rootnode>
> </xsl:variable>
>

I would remove the schema definition (for it is in effect that) and put it
in a separate xml file.  Then you can get it with document(), and you can
create general xslt machinery for doing whatever it is you want to.

It will probably be easier if you are willing to use a processor that can
change a result tree fragment into a nodeset for further processing, like
Saxon can.

> when iterating through the main XML document, I need to check if the
current
> node is allowed to pass through to a function.
> Essentially, I'd like to say:
>
> <xslt:if test="count(//*//$allowednodes) != 0" />
>
> This ofcourse doesn't work. Does anyone know if and how I can compare the
> trees so I can make accurate decisions about allowing a node ???
>

Cheers,

Tom P


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


Current Thread