This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Integrating SAX filters produced streams with XSLT


With the advent of JAXP/TRAX, it is easy to give an XSLT stylesheet an
XML document which is actually a result of SAX events. Using SAX2
filters it is also possible to convert some non-XML subpart of an XML
document into SAX events which can also be fed to an XSLT stylesheet.
All fine and good.

However, if you are using a stylesheet minimizing technique[1] for
templating a website, say, which takes at least two input XML documents,
one via stdin, and the other a result of opening a file using
document(), then you have the problem that only one of these inputs can
be a stream. All the other inputs (via document()) have to be saved in
files prior to input, at least temporarily.

Is there anyway around this? Three solutions come to mind:

1. Make the `input document stream' a combination of N xml documents.
For example:

<foo>Blah</foo>

and

<bar>Blah</bar>

become:

<documentSet>
   <document id="foo"><foo>Blah</foo></document>
   <document id="bar"><bar>Blah</bar></document>
</documentSet>

The XSLT stylesheet then uses a documentSet/document[@id='foo'] XPath
match to set up $fooRoot, as opposed to doing document('foo'). I can see
problems with this if the subdocuments require a DOCTYPE to be set (for
default atributes for example). There are probably others.

2. Change the `file' URI that is given to document() so that it resolves
to a SAX processed stream. I'm not sure how you would do this.

3. Pass in the contents of a SAX processed file as a string xsl:param, 
then somehow turn this into an XML tree. This is not strictly a solution 
as the file is then just in memory, as opposed to on-disk. This is not 
good if you were using a non XML format, converted by SAX2 filters into 
an XML format, as a means to avoid large disk *and* memory requirements.

Are there any other possible solutions?

[1]: http://www.xml.com/pub/a/2000/07/26/xslt/xsltstyle.html

--
Mike



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]