Here is another way to solve the problem..
var Stream = createObject( "java", "java.io.ByteArrayOutputStream" );
var Transformer = createObject( "java",
"javax.xml.transform.TransformerFactory").newInstance().newTransformer();
var DOMSource = createObject( "java", "javax.xml.transform.dom.DOMSource" );
var StreamResult = createObject( "java",
"javax.xml.transform.stream.StreamResult" );
var OutputKeys = createObject( "java", "javax.xml.transform.OutputKeys" );
// Initialize class instances
Stream.init();
DOMSource.init( arguments.xmlObject.getDocumentElement() );
StreamResult.init( stream );
// *** this is the part the CF toString() method is missing!
Transformer.setOutputProperty( OutputKeys.METHOD, "xml");
// Perform the actual serialization
Transformer.transform( DOMSource, StreamResult );
return Stream.toString();
Taco Fleur
> -----Original Message-----
> From: Taco Fleur [mailto:[EMAIL PROTECTED]
> Sent: Saturday, 18 December 2004 12:07 PM
> To: CF-Talk
> Subject: RE: toString() generates invalid xml [solution]
>
>
> Thanks for all the help!
>
> problem solved!!
>
> A new day, did some tests to verify my suspicions!
>
> <cfxml variable="myHTMLDOMObject"><html>
> <head>
> <link href="test" rel="stylesheet" />
> </head>
> <body>This is the body</body>
> </html>
> </cfxml>
>
> <cfdump var="#myHTMLDOMObject#" label="I am a valid XML object">
>
> <cfdump var="#toString( myHTMLDOMObject )#" label="Now I am
> not valid XML anymore">
>
> <cfxml variable="myXHTMLDOMObject"><html
> xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <link href="test" rel="stylesheet" />
> </head>
> <body>This is the body</body>
> </html>
> </cfxml>
>
> <cfdump var="#myXHTMLDOMObject#" label="I am a valid XML object">
>
> <cfdump var="#toString( myXHTMLDOMObject)#" label="Now I
> stayt valid XML">
>
> <cfxml variable="myTestDOMObject"><test>
> <head>
> <link href="test" rel="stylesheet" />
> </head>
> <body>This is the body</body>
> </test>
> </cfxml>
>
> <cfdump var="#myTestDOMObject#" label="I am a valid XML object">
>
> <cfdump var="#toString( myTestDOMObject )#" label="I stay
> valid because the html element is not used">
>
> <cfabort>
>
> So I have my html document as XML which I will transform to
> HTML at a later stage, but want to execute some
> transformations on it first! To do this I need to call
> toString() on the DOM which generated a real html document,
> not an xml presentation of my HTML file, so I guess I need to
> put the xhtml namespace on the file treath it as xhtml and
> then when done convert it to html....
>
>
> Taco Fleur
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - New Atlanta
http://www.newatlanta.com
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188187
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54