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

Re: [xsl] Calling subdocuments with processing directives


Subject: Re: [xsl] Calling subdocuments with processing directives
From: Steven Ericsson-Zenith <steven@xxxxxxxxxxxxx>
Date: Fri, 26 Oct 2007 01:53:43 -0700

Thanks Michael,

Your assumptions are correct.

From what you say, it should do exactly what I expected - but the key in the top document does not appear in the key set. Tomorrow I'll knock up a test case (it is currently passed my bedtime).

The poem finishes:

Rolling snot up it in teenie hard balls
and flinging it hard at his dad!

As I recall.

Steven

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



On Oct 26, 2007, at 1:41 AM, Michael Kay wrote:

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.

I'm really quite confused by what you are doing here.


First point: when you load a document using the document() function, Saxon
will always ignore any <?xml-stylesheet?> processing instruction in that
document.


Second point: I really don't know what you are doing with this key
definition. You say it's in a file called "form.xml", was that meant to be
"form.xsl"? If the key definition is in the stylesheet that is controlling
your processing, then it can be used with any document that participates in
the transformation, you don't need to do anything special to say which
documents it applies to.


I won't ask you how the poem continues. Alright, I will.

Michael Kay
http://www.saxonica.com/

The boy stood on the burning deck
His heart was all a-quiver.
He gave a cough, his leg fell off
and floated down the river.


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
Keywords