This week's book giveaway is in the Testing forum.
We're giving away four copies of Practical Unit Testing with TestNG and Mockito and have Tomek Kaczanowski on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes JAXP 1.1 transform issue using DOMSource Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "JAXP 1.1 transform issue using DOMSource" Watch "JAXP 1.1 transform issue using DOMSource" New topic
Author

JAXP 1.1 transform issue using DOMSource

Jo Mo
Greenhorn

Joined: Jun 06, 2001
Posts: 3
I am doing some bench marks on transformations using JAXP 1.1. One of the scenarios I am testing involves the use of a custom cache for the single xml file that I am going to transform. The cache parses the xml file the first time and then stores it in the Document (DOM) format within the cache for use thereafter (eliminating the need to parse that xml file every time).
Here is the code snippet that I am using to perform the transformation:
xform.transform(source, result);
where 'source' is a DOMSource object and 'result' is a StreamResult.
After retrieving the Document (DOM) from the cache I construct a DOMSource from this Document. If I use the following code:

xmlDomSource = new DOMSource(xmlDoc);
where 'xmlDoc' is the Document (DOM) from my cache everything works fine and I see the transformed xml as HTML - all is good. However, if I construct my DOMSource the following way:
xmlDomSource = new DOMSource(xmlDoc.getDocumentElement());
(again, where 'xmlDoc' is the Document (DOM) from the cache) the result of the transform simply yields the contents of the xml file with no tags. Essentially it has not been properly transformed - it just spits out the values found within the xml file.
Any thoughts on why this might be happening? I am using the default JAXP 1.1 implementation (Crimson, Xalan). Any help or insights would be greatly appreciated. Thanks.
 
 
subject: JAXP 1.1 transform issue using DOMSource
 
Threads others viewed
xml and javascript
DOM Parser
How to transform DTD with JAXP
JAXP transformations
Return type recomendation
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture