Skip to main content
Inspiring
May 6, 2011
Answered

Error received (sometimes) when using <cfxml> tag

  • May 6, 2011
  • 2 replies
  • 1566 views

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>

    This topic has been closed for replies.
    Correct answer Adam Cameron.

    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...


    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

    2 replies

    Inspiring
    May 6, 2011

    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

    talofer99
    Inspiring
    May 6, 2011

    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 ...

    _G_1Author
    Inspiring
    May 6, 2011

    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....

    Inspiring
    May 6, 2011

    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