Chris Bowditch wrote:
I dont agree. Write a class that extends DefaultHandler and implement
the processingInstruction method. Parse the XML file using SAX, get the
path to the stylesheet from the data value passed to the
processInstruction method, throw an exception to halt the SAX parser.
Well, for a start I gather the original poster didn't
want to have a reference to the XSLT in the XML file
but the XSLT code itself, perhaps something like
<root>
<xsl:stylesheet ...>
...
</xsl:stylesheet>
<element>stuff</element>
...
</root>
(added "root" element to make it well formed XML)
With Saxon you can have a fragment in the PI referring
to the XSLT code:
<?xml-stylesheet type="text/xml" href="#xslt"?>
<root>
<xsl:stylesheet id="xslt" ...>
...
which gives a less brittle solution for finding the XSLT
code.
In either case the XSLT code can be extracted with a filter,
but it is certainly more laboriously than just extracting
the reference. There are a few more details needing attention,
for example how namespaces declared on the elements
enclosing the XSLT code but not referenced there will be
handled.
The second assuption is that the user wouldn't mind if the
document is opened andprocessed twice. A reasonable assumption
for a file, but more difficult to asses for documents addressed
by HTTP URLs, and even more difficult for on-the-fly generated
XML, as it often happens at DB interfaces.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]