xsl-list
[Top] [All Lists]

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

2003-07-12 15:00:06

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.

Elements don't open and close in XSLT. They are nodes that are single
entities. opening and closing tags are a feature of the linearisation to a
file, not a feature of the trees on which XSLT works.
Your "so" doesn't follow, if I followed your premise (which I didn't
completely, a small example would have been clearer) then that sounds
normal XSLT work, but not by generating half a node in one
template and half in another.

xsl:copy would not put the namespace definition for one of my
attributes.  
I have no idea what you mean here. XSLT doesn't directly deal with
namespace declarations. If you create or copy a node whose name is in a
namespace to the output tree, then the XSLT system will generate enough
namespace declarations so that when the output is re-parsed the
attributes and elements will be in the right namespaces, but this is an
automatic feature of the linearisation, not something directly under the
control of the stylesheet.


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. 

I suspect your terminology here is non standard. a well formed document
can only have one child element of the root node.

 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.

Sorry I can't guess what you mean here.

http://hnpux3.physics.fsu.edu/~hone/hnpuxpadmin_2003-07-12_10-17-11.959.xml
That's a required result, if you also showed your input documents, I'm
sure someone would suggest a way of doing it in xslt.

In http://www.jlab.org/~hone/gridsubDemo/StartWrap.xsl
You say XSLT has problems outputting < which isn't the case at all.
If you output < using the xml or html output methods, then that
character will be output in a form legal in those formats (eg &lt;)
however this stylesheet appears to be writing a perl script.
If you'd used xsl:output method="text" then when serialising to a text
stream < characters will be written out as < as you'd expect.

David

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