Re: [xsl] Transforming XML 'on-the-fly' / Dynamic XSLT???

Subject: Re: [xsl] Transforming XML 'on-the-fly' / Dynamic XSLT???
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Mon, 08 Nov 2004 17:27:52 -0800
Nick,

Joseph Dane brought up a good example of how to implement a solution from within Java that allows you the ability to do "mini" transforms of data which can then be passed to another transformation process based on the results of each transformation or upon the variables that you are speaking of. Without seeing an example of the variables I can't give you an example of the Java code beyond pointing you to Dr. Kays company site (http://www.saxonica.com) to download the latest Saxon bits which come packaged with tons of Java examples that implement all sorts of transformations using various streams (dynamic and static) and document types (DOM, SAX, etc...)... I would pay specific attention to the TrAX examples (part of the JAXP API) as this will get you more inline with what Joseph is refering to.

Adding to this a bit you might also want to consider the idea of creating a generic XSLT stylesheet that simply acts as a mechanism for matching one set of input XML patterns to another set of output XML patterns. In essence you will be creating an XML output definition file that can be mapped to the input file and then used to weave together any data elements necessary to give the proper output you desire. This gives you much more freedom and is more inline with what XSLT was designed for in the first place... a way to locate patterns in your XML data and then output a specified pattern of data once that pattern has been matched w/o hardcoding your stylesheets in a way that makes them harder to reuse for other types of output. Data weaving is not a new concept by any stretch of the imagination but its something that hasn't seen a lot of airtime as it can sometimes be a little tricky getting things to work just as you want them to. Best rest assured that just like XSLT, once you get it you get it and life becomes that much easier and your coding that much more productice than before.

An example of this type of transformation process can be found at http://www.aspectxml.org. This takes the weaving concept and applies it to the Aspect Oriented Software Development paradigm but it should adequately showcase the concept that I am speaking of and give you some ideas on how to implement this concept into your own solution.

If any of this is helpful and you still have further questions don't hesitate to ask.

Best regards,

<M:D/>



Nick Roberts wrote:

Hi all,

I'm currently investigating into a JAVA based application aimed to transform an XML document.

I understand XSLT and how it is used to transform XML pages, however, my current understanding is that an XSLT page has to be pre-written, with a pre-definition of how you want to transform the XML document.

What I want to achieve is some kind of tool, which will input an XML document, then transform this document based on arguments declared within the application. For example, once the XML document has been inputted into the system, you can view the current nodes and then say how you want to transform these.

As far as i'm aware, this would require some kind of method of 'dynamically' creating an XSLT page, without any kind of pre-definition of how the XML documents' required to change.

Sorry if i'm not explaining myself very well but I hope you can understand what i'm trying to achieve.

Thanks in advance,

Nick

_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger http://www.msn.co.uk/messenger

Current Thread