[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] xpath:document - how to access elements from all xsl:include referencing documents


Subject: [xsl] xpath:document - how to access elements from all xsl:include referencing documents
From: "Ross, Douglas" <DRoss@xxxxxxxxxx>
Date: Fri, 21 Jan 2005 15:47:51 -0500

Is it possible to access elements from multiple documents which
reference the current xslt document when you don't know the
reference-uri for each document?

I would like something like this:
xpath:document(xx:get-all-referencing-uri()) where
xx:get-all-referencing-uri returns a NodeList of URIs for all documents
which included this document.

Is there a way to access elements from all the referencing documents?

Here is an example of what I am trying to do, which fails:

>java org.apache.xalan.xslt.Process -XSL a.xslt -OUT result.txt

This is the main script which uses the library script b.xslt.
a.xslt {
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xalan="http://xml.apache.org/xalan"
	xmlns:t="test"
>
	<t:d>a stuff</t:d>
	<xsl:include href="b.xslt" />
	<xsl:output method="text" indent="yes" />
</xsl:stylesheet>
}

This is a library script which extends c.xslt.
b.xslt {
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xalan="http://xml.apache.org/xalan"
	xmlns:t="test"
>
	<t:d>b stuff</t:d>
	<xsl:include href="c.xslt" />
	<xsl:template match="/">
		<xsl:for-each
select="xalan:nodeset($all-d-elements)/t:d">
			<xsl:value-of select="." />
			<xsl:text>&#10;</xsl:text>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>
}

This is a generic library xslt which grabs all the <t:d> elements from
all the scripts which have included it (or imported, whichever works).
c.xslt {
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xalan="http://xml.apache.org/xalan"
	xmlns:t="test"
>
	<t:d>c stuff</t:d>
	<xsl:variable name="all-d-elements">
		<!-- how can I include all referencing documents? -->
		<xsl:copy-of select="document('')//t:d" />
	</xsl:variable>
</xsl:stylesheet>
}

I expected variable "all-d-elements" to contain <t:d>a stuff</t:d>,
<t:d>b stuff</t:d>, <t:d>c stuff</t:d>.

c.xslt is not aware of the xslt files referencing it by the include or
import actions.

Thanks for any thoughts or pointers.

Douglas Ross
Developer, HTML UI Framework
Kronos
E-mail: dross@xxxxxxxxxx
www.kronos.com


Current Thread
Keywords