Transformation with XSLTProcessor
[email protected] 28 Mar 2007 03:23:48 -0700
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
Hi,
I try to do the following:
-- file.xml --
<?xml version="1.0" encoding="ISO-8859-1" ?>
<catalog>
<cd>
<artist>Bob Dylan</artist>
<country>USA</country>
<artist>Heino</artist>
<country>Germany</country>
</cd>
</catalog>
-- 1.xsl --
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:include href="2.xsl"/>
</xsl:stylesheet>
-- 2.xsl --
<?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="/">
<h2>CD</h2>
<ul>
<xsl:for-each select="catalog/cd">
<xsl:sort select="artist" order="ascending" />
<li><xsl:value-of select="artist"/> - <xsl:value-of
select="country"/> </li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
-- anotherfile.html --
...
//for mozilla/netscape
processor = new XSLTProcessor();
xslt = document.implementation.createDocument("", "", null);
xslt.async = false;
xslt.load(xslURI);
processor.importStylesheet(xslt);
src_doc = document.implementation.createDocument("","", null);
src_doc.async = false;
src_doc.load(xmlURI);
result = processor.transformToDocument(src_doc);
xmls = new XMLSerializer();
output = xmls.serializeToString(result);
...
If the imported stylesheet (in this case 1.xsl) has an include or
import tag, the transformation fails. Is there a way to include more
than one xsl file?
Spider