How to make an XMLDocument as a parameter in a XSLT transformation ?
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
I'm trying to make an XML available as a parameter in a XSLT
transformation (use case like mixing up business data to be transformed
to a HTML GUI with say language dependent text data for labels' texts
or something).
I'm quite new to the Mozilla API for XML but I know a thing or two
about MSMXL where i used this approach that has often prooved simple
and useful.
Is this possible some way (a way in which i should be able to code the
xsl only once for BOTH, msxml and Mozilla)? Or are there other
approaches allowing similar usage?
code would look something like:
--js-------
var httprequest = new XMLHttpRequest();
httprequest.open("GET", "data2.xml", this.async);
httprequest.send(null);
var dom2 = httprequest.responseXML;
var xsltproc = new XSLTProcessor()
xsltproc.clearParameters();
xsltproc.setParameter(null, "dom2", xml2);
var dom = this.xsltproc.transformToDocument(xml.dom);
var serializer = new XMLSerializer();
--xsl-------
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="domext"/>
<xsl:template match="/*">
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match="container">
<li><xsl:value-of select="$domext//text[@id=current()/@id]"/></li>
</xsl:template>
<xsl:template match="composite">
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
</xsl:stylesheet>
--xml-------
<?xml version="1.0" ?>
<labels>
<text id="c0">text c0</text>
<text id="c1">text c1</text>
<text id="c2">text c2</text>
<text id="c3">text c3</text>
</labels>
Thanks in advance for any help!