|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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








