I don't know if this helps or not, but here's an interal KB we have on a 
ToString/XML bug:

CFMX function toString() outputs null when attempting to output a XML document 
created with the <cfxml> tag.

Example:<cfxml variable="ticker">     <xmlticker>          <cfoutput >          
<tickeritem><headline>          #XMLFormat(Trim(tempText))#          
</headline>           <link>            #XMLFormat(Trim(tempLink))#           
</link></tickeritem>            </cfoutput>    </xmlticker> </cfxml> 
<!--- this will output null when sandbox security is enabled 
---><cfoutput>ToString Result: #ToString(ticker)#</cfoutput>
The preceding toString() function outputs null or an empty string.

Answer/Solution:
The following solution was found on Macromedia's forums. (see reference below)

1. Copy and paste this CF code into the template where the toString function is 
being used.

<!--- Standardized, JAXP-based version --->
<!--- (info on JAXP at http://java.sun.com/xml/jaxp/) --->
<cffunction name="XmlToString" returntype="string">
  <cfargument name="Xml" required="true">  

  <!--- Classes from the standard Java/JAXP APIs --->
  <cfset var stream = CreateObject("java", "java.io.ByteArrayOutputStream")>
  <cfset var transformer = CreateObject("java", 
"javax.xml.transform.TransformerFactory").newInstance().newTransformer()>
  <cfset var domsource = CreateObject("java", 
"javax.xml.transform.dom.DOMSource")>
  <cfset var streamresult = CreateObject("java", 
"javax.xml.transform.stream.StreamResult")>

  <!--- Initialize class instances --->
  <cfset stream.init()>
  <cfset domsource.init(Arguments.Xml.getDocumentElement())>
  <cfset streamresult.init(stream)>
  
  <!--- Perform the actual serialization --->
  <cfset transformer.transform(domsource, streamresult)>

  <!--- Return the result --->
  <cfreturn stream.toString()>
</cffunction> 

2. replace the toString() function with XmlToString() in the CF Code.

Reference:
http://webforums.macromedia.com/coldfusion/messageview.cfm?catid=143&threadid=461867

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - RUWebby
http://www.ruwebby.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187959
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to