This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Transforming XML doc with namespace


My job this week is to perform some XSLT on someone else's XML document.
This should be straight forward, but I've been thrown a curve ball that I
haven't seen mentioned in other documentation.

My question is: How can I get XSLT to work with this document containing a
namespace?  (Let's assume I can't have the source document fixed.)

I've included a minimal demonstration below including both a source file
that works fine and a source file that demonstrates my problem.


STYLESHEET:
<xsl:stylesheet 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	version="1.0">
<xsl:template match="book">
	<html><body>
	<xsl:value-of select="@category"/><br/>
	<xsl:value-of select="title"/>
	</body></html>
</xsl:template>
</xsl:stylesheet>


SOURCE THAT WORKS:
<?xml version="1.0"?>
<books>
	<book category="reference">
		<author>Nigel Rees</author>
		<title>Sayings of the Century</title>
		<price>8.95</price>
	</book>
</books>
OUTPUT: <html><body>reference<br>Sayings of the Century</body></html>


SOURCE THAT BREAKS:
<?xml version="1.0"?>
<books xmlns="blah.blah.blah">
	<book category="reference">
		<author>Nigel Rees</author>
		<title>Sayings of the Century</title>
		<price>8.95</price>
	</book>
</books>
OUTPUT: <?xml version="1.0" encoding="UTF-16"?>Nigel ReesSayings of the
Century8.95


I don't yet understand why the second source file renders in what seems to
be a ramdom fashon.  Maybe I'm misunderstanding the basics of namespaces.  

Thanks for your input.

-Mark

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]