Subject: Re: [xsl] XML serializer in XSLT 2.0, using FXSL, to text and HTML From: Florent Georges <darkman_spam@xxxxxxxx> Date: Thu, 21 Dec 2006 13:41:48 +0100 (CET) |
Dimitre Novatchev wrote: Hi Dimitre > Florent Geores: >> I just wrote a few stylesheets to serialize sequences. >> If you are interested, you can find it, as well as a >> few words, here: >> http://www.fgeorges.org/xslt/serial/ > Could you describe the general ideas and architecture, > please? Of course. There are also a few infos on the page above. The main idea is simple. The serialization function takes a sequence as input, does a sequence normalization as in '2 in "XSLT 2.0 and XQuery 1.0 Serialization", and use template rules to walk this tree. A usual XSLT serializer. But the template rules don't serialize the nodes themselves. They send instead messages to a receiver object that does the actual job. The receiver is a structure of several function objects: a function serializing start tags, another for processing instructions, etcetera. So when you use the main serialization function, you can choose the receiver to use, as well as several options. You can even customize the sequence normalizer. As for now, there is only one option: indentation (do make indentation?, and how many spaces to use?). There are two receiver, one that creates a text node and another that creates HTML nodes. They only have to deal with "how to serialize these and these events". They don't worry about walking through the input sequence nor about several options at a higher level. src/serial.xsl is the main stylesheet, src/serial-text.xsl and src/serial-html.xsl are the two receiver for resp. text and HTML. They can be used as example of creating a new receiver. BTW, the interest of the HTML receiver is that it wrap some of the text into 'span' elements, with appropriate @class (there is one class for element local name, for element name prefix, for attribute values, etcetera). So it is easy to insert XML fragment into HTML with syntactic coloration. One receiver could be created to output HTML that allow the user to collapse/expand the XML elements (as in the XML view in XML IDEs and browsers). Filtering serializers can also easily be built, using the decorator pattern. For example if you want to filter out elements by name, you create a function that handles the start and end tag events, and test the name of the element; if the element needs to be serialized, the function call the original function (else it does nothing). Those are unordered thoughts. I hope I answered your question. I still have to wrote a more comprehensive and accurate documentation. Regards, --drkm ___________________________________________________________________________ Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions ! Profitez des connaissances, des opinions et des expiriences des internautes sur Yahoo! Questions/Riponses http://fr.answers.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XML serializer in XSLT 2., Dimitre Novatchev | Thread | [xsl] dateTime fun, James A. Robinson |
Re: [xsl] Are namespace nodes requi, David Carlisle | Date | [xsl] Sort list by a combination of, Manuel Strehl |
Month |