[xsl] Calling subdocuments with processing directives

Subject: [xsl] Calling subdocuments with processing directives
From: Steven Ericsson-Zenith <steven@xxxxxxxxxxxxx>
Date: Thu, 25 Oct 2007 19:57:24 -0700
I have a question concerning the use of fn:document in XSL 2.0 using Saxon 8

I have an xml document with an xsl style sheet processing directive that calls a working style sheet. What I thought I could do to embellish the document under certain circumstances is include this document from another document by specifying an extension attribute that uses fn:document to include the subdocument. The embellishment simply sets up a key that, if it had been defined in the subdocument, would be generated perfectly well. (This is rather like extending a base class in OOP).

What happens is that the subdocument is generated as expected but the key has not been passed.

So the issue, I suspected, is that the processing directive in the subdocument (that in fact calls the same style sheet) reinitializes either the key or the style sheet processor. This implies that the question I should ask is: can I include a document that I want to parse and ask the style sheet processor to ignore any processing directives? So obviously I removed the processing directive but it made no difference.

So we have something like this:
== top.xml ==
<?xml-stylesheet type="text/xsl"href="oxygen:/eXist$memeio-exist/db/ memeio/xml/form.xsl"?>
<document extends="document.xml">
<embellishment type="sidebar">
<p>The boy stood on the burning deck ...</p>
</embellishment>
</document>


== document.xml ==
<?xml-stylesheet type="text/xsl"href="oxygen:/eXist$memeio-exist/db/ memeio/xml/form.xsl"?>
<document>
<embellishment type="overlay">
<p>... picking his nose like mad.</p>
</embellishment>
<!-- the xml that defines the document -->


</document>

== form.xml includes:
<xsl:key match="embellishment" name="embellishment" use="@type"/>

and, of course, it knows what to do with these keys as the document is generated. This all works for the non-extended case.

I know that there are other ways to do this and different ways to structure the document but I am looking for a simple way to extend existing documents in the current style sheet structure.

Thanks,
Steven


-- Dr. Steven Ericsson-Zenith Institute for Advanced Science & Engineering http://iase.info http://senses.info

Current Thread