You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by MAHE Vincent FTRD/DIH/REN <vi...@rd.francetelecom.fr> on 2000/10/11 18:05:25 UTC
RE: How to parse an XML Tree that was created with the DOM API ?
(in my servlet)
You're right but it was just a mistake from me. This was not really the
source code I'm using.
I do the following in my DoGet() function of my servlet :
// Create the DOM Tree
Document doc= new DocumentImpl();
root_element = doc.createElement("Products"); // Create Root Element
named <Products>
Element product_element= doc.createElement("Produit"); // Create the tag
<Product> child of <Products>
Element ref_element = doc.createElement("Ref"); // Create the tag <Ref>
child of <Product>
ref_element.appendChild( doc.createTextNode("my content"));
product_element.appendChild( ref_element );
root.appendChild( product_element );
// Process the tree with Xalan and an XSL file
XSLTProcessor processor = null;
try
{
processor = XSLTProcessorFactory.getProcessor();
XMLParserLiaison xmlProcessorLiaison = processor.getXMLProcessorLiaison();
xmlProcessorLiaison.setUseValidation(false);
processor.process(new XSLTInputSource(root_element),
new XSLTInputSource("/toto/transfo.xsl"),
new XSLTResultTarget(out));
}
catch (Exception exc)
{
out.println("Exception occurred during Transformation:"
+ "<br>" +
exc.getMessage() + "<br>");
}
finally
{
processor.reset();
} // end of try ... catch ... finally
And I've got an exception but with no explicit message. So I don't know
where my error comes from.
I know that my DOM tree is build well because when I serialize it with
Xerces, it creates a beautiful XML file just the way I want it.
So where is my error coming from ?
Vincent.
-----Message d'origine-----
De: Tako Schotanus [ mailto:quintesse@palacio-cristal.com
<ma...@palacio-cristal.com> ]
Date: mercredi 11 octobre 2000 17:45
À: xalan-dev@xml.apache.org
Objet: RE: How to parse an XML Tree that was created with the DOM API ?
(in my servlet)
Shouldn't this be:
processor.process(new XSLTInputSource(root_xml_node), new
XSLTInputSource("my_xsl.xsl"), newXSLTResultTarget(out));
?
-Tako
> I've created a tree in memory with the DOM API and I want to
> parse this tree
> with Xalan and to send the result to the output of my servlet.
>
> What should I use instead of :
> processor.process(XSLTInputSource(root_xml_node), "my_xsl.xsl",
> XSLTResultTarget(out));
>
> I get an error from the parser but I don't know which error it is (my
> exception sends no message).
> I'm sure that my XSL file is good because I've tested it with
> simpletransform.
>
> Any help would be nice ...
>
> Thanks.
RE: How to parse an XML Tree that was created with the DOM API ? (in my servlet)
Posted by Tako Schotanus <qu...@palacio-cristal.com>.
<snip>
> // Create the DOM Tree
> Document doc= new DocumentImpl();
> root_element = doc.createElement("Products"); // Create Root Element
<snip>
> processor.process(new XSLTInputSource(root_element),
> new XSLTInputSource("/toto/transfo.xsl"),
> new XSLTResultTarget(out));
I think you should have entered "doc" instead of "root_element"
Good luck,
-Tako
> So where is my error coming from ?
>
> Vincent.
>
> -----Message d'origine-----
> De: Tako Schotanus [ mailto:quintesse@palacio-cristal.com
> <ma...@palacio-cristal.com> ]
> Date: mercredi 11 octobre 2000 17:45
> À: xalan-dev@xml.apache.org
> Objet: RE: How to parse an XML Tree that was created with the DOM API ?
> (in my servlet)
>
>
>
> Shouldn't this be:
>
> processor.process(new XSLTInputSource(root_xml_node), new
> XSLTInputSource("my_xsl.xsl"), newXSLTResultTarget(out));
>
> ?
>
> -Tako
>
> > I've created a tree in memory with the DOM API and I want to
> > parse this tree
> > with Xalan and to send the result to the output of my servlet.
> >
> > What should I use instead of :
> > processor.process(XSLTInputSource(root_xml_node), "my_xsl.xsl",
> > XSLTResultTarget(out));
> >
> > I get an error from the parser but I don't know which error it is (my
> > exception sends no message).
> > I'm sure that my XSL file is good because I've tested it with
> > simpletransform.
> >
> > Any help would be nice ...
> >
> > Thanks.
>