EasyCFM.COM ColdFusion Forums / Coding Help! / Coldfusion Xml Namespace

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Coldfusion Xml Namespace

remove book mark from this topic Printer-friendly Version  send this discussion to a friend  new posts last

luteralus
07-05-2013 @ 7:07 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Member
Posts:
Joined: Jul 2013

I need to build an xml document with a namespace. When
I create the root element, I define all the necessary
namespaces with xmlAttribute[xmlns:xxx]. But after
that, when I create a child element the namespace
reference is also shown.Is this ok or what do I need to
prevent that?
Here is my code example
y_doc = XmlNew();
my_doc.xmlRoot = XmlElemNew(my_doc,"Invoice");
my_doc.xmlRoot.XmlAttributes["xmlns"] =
'urn:oasis:names:specification:ubl:schema:xsd:Invoice-
2';
    my_doc.xmlRoot.XmlAttributes["xmlns:cbc"] =
'urn:oasis:names:specification:ubl:schema:xsd:CommonBas
icComponents-2';
    my_doc.Invoice.XmlChildren[1] =
XmlElemNew(my_doc,"cbc:UBLVersionID");
    my_doc.Invoice.XmlChildren[1].XmlText = '2.0';

and result is
<?xml version="1.0" encoding="UTF-8"?>
<Invoice
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Inv
oice-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd
:CommonBasicComponents-2">
    <cbc:UBLVersionID
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd
:CommonBasicComponents-2">2.0</cbc:UBLVersionID>
</Invoice>

But i want to be seen as
<cbc:UBLVersionID>2.0</cbc:UBLVersionID>

Thanks

Webmaster
08-09-2013 @ 1:25 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

I see you created a namespace, but you never defined
the namespace in the header.

<?xml version="1.0" encoding="UTF-8" cbc="PATH?"
?>
<Invoice
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Inv

oice-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd

:CommonBasicComponents-2">

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

\m/ (>.<) \m/
--- rock on ---


Website Designed and Developed by Pablo Varando.