aspose file tools*
The moose likes XML and Related Technologies and the fly likes JAXP XSLT transform to DOMResult failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXP XSLT transform to DOMResult failure" Watch "JAXP XSLT transform to DOMResult failure" New topic
Author

JAXP XSLT transform to DOMResult failure

M Galevsky
Greenhorn

Joined: Mar 05, 2008
Posts: 10
Hi all,

I am running the following code well:

[...]
StreamResult fileResult= new StreamResult(outputFile);
Transformer transformer = xmlWritter.newTransformer(new javax.xml.transform.stream.StreamSource("./my_sheet.xsl"));
transformer.transform(new DOMSource(dom), fileResult);
[...]

it generates the outputFile as expected.

Now, I would like to get a DOMResult instead:

[...]
DOMResult domResult= new DOMResult();
Transformer transformer = xmlWritter.newTransformer(new javax.xml.transform.stream.StreamSource("./my_sheet.xsl"));
transformer.transform(new DOMSource(dom), domResult);
[...]

But execution fails on :

ERREUR : 'HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it
is not permitted. '

Anyone can help ?

Thks very much,

Gal'
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

My guess is that your XSL produces something that isn't an XML document. This doesn't matter when you are writing to a file, but you can't produce a DOM unless your output is a well-formed XML document.

Most likely your output doesn't have a single root element, but I suppose there are other possibilities.
 
Consider Paul's rocket mass heater.
 
subject: JAXP XSLT transform to DOMResult failure