Skip to main content
May 5, 2011
Answered

CFXML and Namespace References Order

  • May 5, 2011
  • 2 replies
  • 1268 views

I am using cfxml top create an xml file to send to a third party.
There are two Namespace references in the xml.  The problem is that cfxml apparently alphabetizes the reference order.  This results in a "fatal xml error" from the third party I am submitting the xml to.
It's a guess as to the alphabetizing, but CF is definitely switching the references in the resulting xml.

This is what's in my code:
<CFXML variable="MyXML">
<?xml version="1.0"?>
...
...

When I view the resulting xml the namespace reference have switched:
...
...

Anyone know of a way to get CF to do what I tell it?

This topic has been closed for replies.
Correct answer ilssac

robs67 wrote:


Anyone know of a way to get CF to do what I tell it?


IF you are not using the XML data structure in ColdFusion, and I presume you are just passing an XML string, then just create the XML string directly.

Basically, if you replace the <cfxml....> with <cfsavecontent...> you can get just that.  Just know that with the <cfsavecontent...> version, you are responsible for you own XML prologue.

2 replies

ilssac
Inspiring
May 5, 2011

Message was edited by: ilssac to remove the duplicate post.  One just gotta love this Jive forum doesn't one.

ilssac
ilssacCorrect answer
Inspiring
May 5, 2011

robs67 wrote:


Anyone know of a way to get CF to do what I tell it?


IF you are not using the XML data structure in ColdFusion, and I presume you are just passing an XML string, then just create the XML string directly.

Basically, if you replace the <cfxml....> with <cfsavecontent...> you can get just that.  Just know that with the <cfsavecontent...> version, you are responsible for you own XML prologue.

May 5, 2011

Thank you so much.  That worked just fine.

I'm curious though.  Is it normal for an XML parser to put the namespace references in alpha order?  Or is that just a CF thing?

Thanks again!

ilssac
Inspiring
May 5, 2011

robs67 wrote:

Is it normal for an XML parser to put the namespace references in alpha order?  Or is that just a CF thing?

I don't know for sure, I have never had to dig that deep into ColdFusion's XML features.

I can speculate that the XML Object in memory does not have any 'order' to the namespace references (or any other of the references that make up the XML data object).  It is not until that internal object is output as a string representation that the ordering occurs.

It is also a bit of an open question in my mind of why any XML parser should care about the order of elements.  It's sort of a basic premise of XML that order should seldom matter, is it not?