xsl-list
[Top] [All Lists]

RE: RE: How to get output XML same as input XML?

2003-07-12 13:58:43
Hi all -

First, let me thank you all for the helpful advice. Other mailing boards I have been on are usually much less helpful (see Jetspeed....). Second, let me explain my app a little better, and tell you about a problem I had with xsl:copy (i did not try xsl:copy-of). In the XML I am dealing with, I always have two child elements of the root element which I parse with two different stylesheets. Since the stylesheets cannot be loaded dynamically, I do the separate parsing in my Xalan code. The stylesheets are identified by an attribute on each child element of the root node. Once the stylesheets parse the input XML, the result gets streamed into the same file, one child element of the root node on top of the other. So, if I am going to create a valid XML document from this, I need to open an element in one template but close it in another template describing the other child element.

xsl:copy would not put the namespace definition for one of my attributes. Specifically, one of the child elements of the root node of the original XML document would have attributes from another namespace than the one that the element is defined under. xsl:copy does not provide a definition of the namespace of the attributes which belong to other namespaces. Specifically, the namespaces of the attributes were defined in the root element. I suspect that is why xsl:copy fails to make a valid document in this case, since a straight copy doesn't include a definition of something defined outside the stylesheet. But I am not sure. As I said, I did not try xsl:copy-of.

I ended up creating a Perl script as the output of the stylesheets and using ASCII characters to write the opening tag in one template and a closing tag in another. The Perl script writes the XML to a file, including resolving the ASCII codes, producing a valid document with essentially two wrapped child elements of the former root node. An example result document is at:

http://hnpux3.physics.fsu.edu/~hone/hnpuxpadmin_2003-07-12_10-17-11.959.xml

with the stylesheets which produced this document referenced therein.

Thanks again and I will respond to any questions,
Josh Hone

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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