Copy link to clipboard
Copied
I have a problem when using the <cfxml> tag, its seems to error when I try and display xml code over a certain length, as it works for some of my records and not others. Is there a known sizing limit when displaying stuff within the cfxml tag ?
Here is my code, I am un-sure as to how to progress with this issue. Any help would be much apprciated.
<cflayout type="tab">
<cflayoutarea title="Application XML">
<cfoutput>
<cftry>
<cfxml variable="MyXMLDoc" casesensitive="yes">
#getAppReqHeader.application_xml#
</cfxml>
<cfdump var="#MyXMLDoc#">
<cfcatch>
<br /><br />
<div style="margin-left:5px;color:gray">Error displaying xml.</div><br/>
</cfcatch>
</cftry>
</cfoutput>
</cflayoutarea>
</cflayout>
Right.
So it's being truncated when it's fetched from the DB. Nothing to do with CFXML.
Sounds like it's hitting the Long Text Buffer size (which by default is 64kB). Increase that value (in your DSN advanced settings).
--
Adam
Copy link to clipboard
Copied
Certine carecters can through the XML off, like : & (and) for example.
You code is not posted, but you can try and use #XmlFormat()#
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6e62.html
look at the link for more info ...
Copy link to clipboard
Copied
Thanks for your response, I tried your suggestion but to no avail.
Here is my code now...
<cfxml variable="MyXMLDoc" casesensitive="yes">
#XmlFormat(getBatchReqHeader.out_batch_xml)#
</cfxml>
<cfdump var="#MyXMLDoc#">
I am getting the XML from a field in the database which is of field type CLOB, I have tracked the error down to coldfusion cutting the end part of the string which is causing the error. I am trying to display a big bit of xml... around about 65k words + .... I have a feeling that coldfusion is chopping of the end part of my string variable which makes it syntactially incorrect which is causing the error.
Now I am sure my code works because it works with smaller field lengths in the database....
Copy link to clipboard
Copied
Well: don't have a feeling that CF is truncating the string: check. Output the string before you CFXML it. Is it all there?
Also, you're misusing xmlFormat(). xmlFormat() is for escaping invalid characters in text values (like xmlattribute values, or xmltext values). You don't escape the whole thing.
Also, given what you're doing, it looks like the string coming back from the DB is XML already, so you don't need to use CFXML, just use xmlParse().
It might be an idea to read through the XML section of the CF docs.
--
Adam
Copy link to clipboard
Copied
Something is truncating the string as when I output it the XML is not all there... Which is why <cfxml> and <cfdump> can not parse the xml probably.
I may have given off the wrong impression, I do not want to escape the xml special charactors. I want to show these.... Which is why I am using CFDUMP as it displays the xml in a good way.
Copy link to clipboard
Copied
Do what I asked.
Output the string BEFORE (or INSTEAD) of trying to treat it as XML. Forget CFXML and CFDUMP, just do this:
<cfoutput>#getBatchReqHeader.out_batch_xml#</cfoutput>
Then view the source and see if the entire string is there.
There's a good chance it's being truncated when it's being fetched from the DB.
--
Adam
Copy link to clipboard
Copied
silly Q' if you try and dump the getBatchReqHeader.out_batch_xml as is, will all
the XML look ok ?
or do they get cut off at this stage already ?
Copy link to clipboard
Copied
silly Q' if you try and dump the getBatchReqHeader.out_batch_xml as is, will all
the XML look ok ?
or do they get cut off at this stage already ?
------------------------------------------------------------------------------------
If I try and directly output it, it gets cut of at this stage, after about the 65,000 word...
Copy link to clipboard
Copied
Right.
So it's being truncated when it's fetched from the DB. Nothing to do with CFXML.
Sounds like it's hitting the Long Text Buffer size (which by default is 64kB). Increase that value (in your DSN advanced settings).
--
Adam
Copy link to clipboard
Copied
Thanks Adam, I will give this a shot and report back...
Copy link to clipboard
Copied
You can't just wrap an XML document with the XMLFormat function - that will escape all XML metacharacters. Use XMLFormat to escape metacharacters within XML text nodes and attribute values only:
<myxml someattribute="#XMLFormat(someCFVariable)#"/>
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/
Copy link to clipboard
Copied
Problem solved.
In the coldfusion administrator I checked the option:
-- Enable long text retrieval (CLOB). |
and all worked.
Thanks for your help guys.
Copy link to clipboard
Copied
What would also be helpful is posting the actual error.
As a rule of thumb when posting a question about code not working:
* post some code that reproduces the problem. Not just a chunk out of the middle of your production code, but a refactored, stand-alone example demonstrating the problem. So we can save it locally and see the problem
* any error message you get. Not described, but copy and pasted from the screen
* a description of what you were expecting, and how what happened differs from your expectation (obviously in your case it's "I don't want the error", but it's sometimes not so clear cut as that, and people have a tendency to say "it didn't work", which by itself is meaningless).
--
Adam