You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Martín Lahittette <ml...@telpin.com.ar> on 2001/01/16 02:40:15 UTC
DOM output of an XSLTProcessor as a DOM input to another
Hi!!
I'd like to use a DOM output of an XSLTProcessor as a DOM input to another
XSLTProcessor. Is it posible?
I tried with this code:
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import org.apache.xalan.xslt.*;
import org.apache.xalan.xpath.xml.XMLParserLiaison;
import org.w3c.dom.*;
import org.apache.xerces.dom.*;
import java.io.IOException;
.......
org.w3c.dom.Document in, out, end;
DOMParser parser = new DOMParser();
parser.parse("catalogo.xml");
in = parser.getDocument();
out = test(in);
end = test(out);
.........
// Process the DOM dom with a stylesheet that produce a copy of the input
DOM.
public org.w3c.dom.Document test(org.w3c.dom.Document dom) throws
SAXException {
org.w3c.dom.Document answ;
XSLTProcessor xsltProc = XSLTProcessorFactory.getProcessor
(new org.apache.xalan.xpath.xdom.XercesLiaison());
answ = new org.apache.xerces.dom.DocumentImpl();
XSLTResultTarget resultTarget = new XSLTResultTarget(answ);
xsltProc.process(new XSLTInputSource(dom),
new XSLTInputSource("catalogo.xsl"),
resultTarget);
return answ;
}
When I call the test method with 'out', it doesn't work ok. It doesn't throw
any Exception, but the DOM is not correctly processed.
I think the problem is that XSLTProcessor work only with a
DeferredDocumentImpl (as created by the DOMParsed) as input, but it always
produce a DocumentImpl as output (even if I set 'answ' as a
DeferredDocumentImpl)
Any help will be much appreciated...
Thanks, Martin
Re: DOM output of an XSLTProcessor as a DOM input to another
Posted by Martín Lahittette <ml...@telpin.com.ar>.
Ops!! I'm sorry. I had a bug in my stylesheet. XSLTProcessor works fine with
DocumentImpl DOM as input.
Sorry again and thanks.
----- Original Message -----
From: "Martín Lahittette" <ml...@telpin.com.ar>
To: <xe...@xml.apache.org>
Sent: Monday, January 15, 2001 10:40 PM
Subject: DOM output of an XSLTProcessor as a DOM input to another
> Hi!!
> I'd like to use a DOM output of an XSLTProcessor as a DOM input to another
> XSLTProcessor. Is it posible?
>
> I tried with this code:
>
> import org.apache.xerces.parsers.DOMParser;
> import org.xml.sax.SAXException;
> import org.apache.xalan.xslt.*;
> import org.apache.xalan.xpath.xml.XMLParserLiaison;
> import org.w3c.dom.*;
> import org.apache.xerces.dom.*;
> import java.io.IOException;
>
> .......
>
> org.w3c.dom.Document in, out, end;
>
> DOMParser parser = new DOMParser();
> parser.parse("catalogo.xml");
> in = parser.getDocument();
>
> out = test(in);
> end = test(out);
> .........
>
> // Process the DOM dom with a stylesheet that produce a copy of the input
> DOM.
> public org.w3c.dom.Document test(org.w3c.dom.Document dom) throws
> SAXException {
> org.w3c.dom.Document answ;
>
> XSLTProcessor xsltProc = XSLTProcessorFactory.getProcessor
> (new org.apache.xalan.xpath.xdom.XercesLiaison());
>
> answ = new org.apache.xerces.dom.DocumentImpl();
> XSLTResultTarget resultTarget = new XSLTResultTarget(answ);
>
> xsltProc.process(new XSLTInputSource(dom),
> new XSLTInputSource("catalogo.xsl"),
> resultTarget);
> return answ;
> }
>
> When I call the test method with 'out', it doesn't work ok. It doesn't
throw
> any Exception, but the DOM is not correctly processed.
> I think the problem is that XSLTProcessor work only with a
> DeferredDocumentImpl (as created by the DOMParsed) as input, but it always
> produce a DocumentImpl as output (even if I set 'answ' as a
> DeferredDocumentImpl)
>
> Any help will be much appreciated...
> Thanks, Martin
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org