Hi, all,
I have some code that is attempting to apply an xsl transform to an xml file, and I've found that if I use the same xsl file, but reading it in different ways, I get different results. Specifically, if I parse the xsl file into a Document, and then create a DOMSource for the xsl file, it doesn't work. However, if I simply create a StreamSource for the same file, it does work. According to the API, it should be able to take both types of sources.
I wonder if anybody can explain why this would happen?
The files I'm using to test this are just pulled of the xslt w3schools tutorial:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I'd really like to be able to use a DOM Source (so that I don't have to write it out to a file before I attempt to do a transform!), but for some reason, it isn't working correctly. Can anybody explain this?
Thanks!
- Adam