[xsd-users] wildcard namespaces

Latrach, Farhat Farhat.Latrach at sc.com
Tue Jun 2 07:54:37 EDT 2015


Hi Boris,

Here is a test case:

Xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns4:HHML xmlns:ns2="http://com.hh.wb.com/position" xmlns:ns4="http://www.hh.com/HHML-1" xmlns:ns5="http://www.fpml.org/FpML-5/confirmation" xmlns:ns6="http://www.hh.com/hhml/extension-2-0" xmlns:ns10="http://www.hhi.com" xmlns:ns7="http://www.fpml.org/FpML-5/ext" xmlns:ns8="http://www.w3.org/2000/09/xmldsig#">
    <ns4:header>
..........
<ns4:payload>
       <ns4:FPMLPayloads> <!—This is the expected wildcard -->
            <ns4:FPMLPayload>

C++ code:
 auto_ptr<hhml::HHML> xmlRequest (hhml::HHML_( argv[1], xml_schema::flags::dont_validate) ); //successful
std::cout << *xmlRequest << std::endl; //shows all elements except the wildcard
  ::xercesc::DOMElement &e = xmlRequest->payload().any();
hhml::FPMLPayloadListType  fpmlPayLoadsList ( e,
xml_schema::flags::dont_validate ) ; ==> exception: no mapping provided for namespace prefix 'ns6'

By adding the namespace prefix mapping to the DOM element  as below the error disappears:
e.setAttributeNS( xsd::cxx::xml::string("http://www.w3.org/2000/xmlns/").c_str(), xsd::cxx::xml::string("xmlns:ns6").c_str(), xsd::cxx::xml::string("http://www.hh.com/hhml/extension-2-0").c_str());

It seems to me that the DOM element is not importing namespaces prefixes.

When serializing, the xml produced put all namespaces used in the wildcard at the wildcard root element even if it has already defined them the root document (case when wildcard and root contains elements defined in same namespace).

I thought that it is your design to expect the wildcard to have it own namespaces prefixing defined within as you do when serializing.

Thanks.






From: Boris Kolpackov <boris at codesynthesis.com<mailto:boris at codesynthesis.com>>
Date: 2 June 2015 6:01:56 pm SGT
To: Farhat Latrach <farhat.latrach at gmail.com<mailto:farhat.latrach at gmail.com>>
Cc: "xsd-users at codesynthesis.com<mailto:xsd-users at codesynthesis.com>" <xsd-users at codesynthesis.com<mailto:xsd-users at codesynthesis.com>>
Subject: Re: [xsd-users] wildcard namespaces
Reply-To: xsd-users at codesynthesis.com<mailto:xsd-users at codesynthesis.com>
Hi Farhat,

Farhat Latrach <farhat.latrach at gmail.com<mailto:farhat.latrach at gmail.com>> writes:


Yes the generated code fails to extract the wildcard content.
The exception is related to the prefix namespace mappings.

Interesting. Would you be able to send me a test case that
reproduces this? That is, the schema, xml file, and a test
driver. This should definitely work out of the box so I
would like to fix it.

Boris

This email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please delete all copies and notify the sender immediately. You may wish to refer to the incorporation details of Standard Chartered PLC, Standard Chartered Bank and their subsidiaries at https://www.sc.com/en/incorporation-details.html


More information about the xsd-users mailing list