|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Default namespace in result document
(I had some problem sending this earlier; appologies if you see it twice.)
Dear All, I have been using XSLT successfully for a few years now but have never tried to make namespaces work, mainly because at least one component in the system has not supported them properly. I've now tried using them for the first time and although I get a result document that is correct it's not quite what I had expected. Here's an example: [XML input:] <?xml version="1.0"?> <foo xmlns="http://example.com/foo"> <blah/> </foo> [XSLT:] <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:foo="http://example.com/foo"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/">
<foo:root>
<xsl:apply-templates mode="copy"/>
</foo:root>
</xsl:template> <xsl:template match="*" mode="copy">
<xsl:copy>
<xsl:apply-templates mode="copy"/>
</xsl:copy>
</xsl:template></xsl:stylesheet>
<?xml version="1.0"?>
<root xmlns="http://example.com/foo">
<foo>
<blah/>
</foo>
</root>i.e. the default namespace is defined on the root element, and no namespace things are used anywhere else. But instead, using libxslt version 1.1.15, I get this: <?xml version="1.0"?>
<foo:root xmlns:foo="http://example.com/foo">
<foo xmlns="http://example.com/foo">
<blah/>
</foo>
</foo:root>This is not ideal because it makes files much larger than they need to be. I guessed that there would be some xsl:output attribute to select a default namespace but I can't see anything that does exactly this. I can't help feeling that I've missed something obvious. Can someone suggest what I need to do? (I assume that this is also an issue for people trying to generate "HTML-compatible XSLT" - not something I have tried to do yet...) Many thanks, --Phil.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








