XML transformation/parsing problem

pulvertum

Usenet Archive
Joined
Oct 11, 2002
Messages
3
Reaction score
0
Hello,

I need an org.w3c.dom.Document so I can pass them to do a transformation of my XML using XSL (to another XML as result).

I've tried several solutions but didn't have the desired result:

SOLUTION 1 using StreamOutput:
StreamSource streamXSL = new StreamSource(new
File(txtFileXSL));
Templates templates =
TransformerFactory.newInstance.newTemplates(streamXSL); Transformer parser = null; // tranformation using STREAMOUTPUT StreamSource streamXML = new StreamSource(new File(txtFileXMLSource)); StreamResult streamOutput = new StreamResult(System.out); parser = templates.newTransformer; parser.transform(streamXML, streamOutput);
--> does the parsing CORRECT but I don't have a
org.w3c.dom.Document/Node as a result

SOLUTION 2 :
// transformation using DOMRESULT
DOMResult domResult = new DOMResult;
parser = templates.newTransformer;
parser.transform(streamXML, domResult);
--> does NOT WORK if I do domResult.getNode.getFirstChild then my rootnode is empty?????

SOLUTION 3 (other builder/parser):
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance;
DocumentBuilder parser = factory.newDocumentBuilder;
org.w3c.dom.Document docXSL = parser.parse(fileXSL);
--> I don't get any errormessages but again if I ask for the rootnode, it is EMPTY???

How can I retrieve an org.w3c.dom.Document/Node without having an empty rootnode? I'm sure my XSL and/or XSL is correctly because using solution 1 with a StreamOutput doesn't cause any problems!!

Hopefully someone can help me, I'm out of inspiration!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top