[xsd-users] wildcard namespaces

Latrach, Farhat Farhat.Latrach at sc.com
Mon Jun 1 05:13:46 EDT 2015


Hi Boris,

I have had an issue parsing "wildcard" elements when the namespaces mappings used in the wildcard element are defined in a parent element.

I do agree with the design of expecting the wildcard element to be independent and contains its proper namespaces/ or namespaces mapping; This was not easy for me to agree on with the sender.

To resolve the issue I managed to parse in a DOMDocument then add them to  the wildcard's DOMElement.

Here is my workaround:

 xsd::cxx::xml::dom::auto_ptr<xercesc::DOMDocument> doc ....
  .....
  .....
//wildcard
::xercesc::DOMElement& wildcard = xmlRequest->payload().any();

::xercesc::DOMElement* rootElement = doc.get()->getDocumentElement();
  DOMNamedNodeMap* theAttributes = rootElement ->getAttributes(); // namespaces are always expected at root (my specific case)
for ( size_t i =0 ; i < theAttributes->getLength (); i ++ )
{
  DOMNode* rootNode = theAttributes ->item(i);

  if ( xsd::cxx::xml::transcode<char>( rootNode ->getNodeName() ).find("xmlns") != std::basic_string<char>::npos )
   {
    wildcard. setAttributeNS( xsd::cxx::xml::string("http://www.w3.org/2000/xmlns/").c_str(),  rootNode ->getNodeName(),
     rootNode->getNodeValue() );
   }
}

Is there a better way?

Is it possible to have an xml_schema::namespace_infomap in the generated cxx-tree parsing functions like a reference to an empty map to be populated(suggestion)?

Thanks.

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