Re: [xsl] More Multi-Document Mambo

Subject: Re: [xsl] More Multi-Document Mambo
From: Laurence O Garfield <lgarfiel@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Jul 2001 12:36:43 -0500 (CDT)
On Wed, 18 Jul 2001, David Carlisle wrote:

> > But what exactly is happening internally with the trees,

> not sure what you want to know, but possibly the answer is that the
> XPath model gives you an ordered sequence of distinct trees coming from
> document() (and xx:node-set() and any otehr external function
> thatgenerates a tree). / always refers to the tree containing the
> current node.
>
> > and is there any way to differentiate between them so that the identity
> > transform doesn't pass through stuff from one of the trees?
>
> the default apply-templates will never pass from one tree to another
> as none of the axis cross a tree, so your transform will only move from
> one tree to another if you explictly apply-templates select="document(...
>
>
> David

OK, so when I apply-templates to another document() tree explicitly, I am
jumping explicitly out of the current tree?  If I apply-templates into
treeB from treeA, and then in some template check for a given ancestor
that is in treeA but not treeB, should it return true or false?

Code wise:

treeA: book/part/section/para
treeB: html/body

<xsl:template match="book/part/section">
	<xsl:apply-templates select="document('treeB.xml')" />
</xsl:template>

<xsl:template match="body">
	<xsl:if test="Boolean(ancestor::part)" >
		Bingo!
	</xsl:if>
</xsl:template>

<!-- Identity template here -->

Will "Bingo!" be output?

It's not that <apply-templates /> is passing from one tree to another.
It's that I want the default rule for one tree to be the identity
transformation (the template file), and the default rule for the other to
be the normal pass-through template.  However, if I include the identity
transformation in the script then it is the default rule for BOTH trees,
when I <apply-templates /> in each one individually.  Hense my question
about the relationship between the trees, as the only way I can see to do
that is to put a test inside the identity template that says "if this node
is part of treeA pass it through the identity template, otherwise ignore
it."  Unless there is a better way to do it?

Thanks for putting up with me asking the same question over and over
again. :-)

--Larry Garfield


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


Current Thread