You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Michael Engelhart <me...@navigatus.com> on 2002/06/01 17:32:49 UTC

Transformer usage question

Hi -

I have 2 stylesheets.

The first one is very simple:

<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">    

<xsl:param name="url1">
<xsl:param name="url2">
<xsl:param name="url3">

<xsl:template match="/">
    <xsl:copy-of select="document($url1)" />
    <xsl:copy-of select="document($url2)" />
    <xsl:copy-of select="document($url3)" />
</xsl:template>

</xsl:stylesheet>

I set the "urlx" parameters with the Transformer.setParameter() method.

What I need to do is have this document transformed to include all the XML
that is grabbed by the copy-of calls and then run the result through a
stylesheet.

I'm confused as to how to do this with my two documents.  I tried this:

TransformerFactory tFactory = TransformerFactory.newInstance();
String url1 = "http://127.0.0.1/doc1.xml";
String url2 = "http://127.0.0.1/doc2.xml";
String url3 = "http://127.0.0.1/doc3..xml";
Source copyOfSource = new StreamSource(new URL("copy.xsl").openStream());
Source resultSource = new StreamSource(new
URL("transform.xsl").openStream());
Transformer transformer = tFactory.newTransformer(copyOfSource );
transformer.setParameter("url1", url1);
transformer.setParameter("url2", url2);
transformer.setParameter("url3", url3);
transformer.transform(resultSource , new StreamResult(System.out));

But the copyOfSource document isn't grabbing the documents, I think it's
just passing the actual stylesheet into the transformer because the output
is just the  resultSource stylesheet.  When I switch the copyOfSource into
the transform method, it returns the copy-of XML document but doesn't
transform it with the resultSourceStylesheet.

I'm just basically confused on how to do this.  Do I need to transform it
2x? Once to get the copy-of document generated and then take that result and
trasnform it to get the resulting XML?

Pointers to code examples would be great.

Thanks
Mike