[xsd-users] CodeSynthesis - Namespaces and schemas

Andrew.King2 at barclayscapital.com Andrew.King2 at barclayscapital.com
Wed Feb 1 09:30:09 EST 2012


Hi,

Please can you help me to understand what I am doing wrong. It is to do with XML generation using CodeSynthesis. I have the following piece of code:

xml_schema::namespace_infomap map;

map["fpml"].name = "http://www.fpml.org/FpML-5/confirmation";
map["fpml"].schema = "/xmls/OTC/fpml-main-5-1.xsd";

map["xsi"].name = "http://www.w3.org/2001/XMLSchema-instance";
map["xsi"].schema = "";

std::ostringstream oss;
requestConfirmation( oss, conf, map );

return oss.str();

and this generates XML in the following format (some of the data has been clipped out for brevity, but nothing else has been altered)

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<fpml:requestConfirmation xmlns:fpml="http://www.fpml.org/FpML-5/confirmation" actualBuild="6" fpmlVersion="5-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fpml.org/FpML-5/confirmation /xmls/OTC/fpml-main-5-1.xsd">
  :
  <fpml:isCorrection>false</fpml:isCorrection>
  <fpml:correlationId correlationIdScheme="ICE">1</fpml:correlationId>
  <fpml:sequenceNumber>1</fpml:sequenceNumber>
     :
        <fpml:relatedParty>
          <fpml:partyReference href="PH"/>
          <fpml:role partyRoleScheme="http://www.fpml.org/coding-scheme/party-role">1</fpml:role>
        </fpml:relatedParty>
      :
          <fpml:currency currencyScheme="http://www.fpml.org/ext/iso4217-2001-08-15">AUD</fpml:currency>
      :
  <fpml:party id="PH">
    <fpml:partyId partyIdScheme="http://www.fpml.org/ext/iso9362">1234</fpml:partyId>
  </fpml:party>
  :
</fpml:requestConfirmation>

As you can see, the fpml namespace has been added to every tag, and some of the tags have been given scheme attributes whilst others have not.

Ideally, I'd like the above XML to look like the following:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<fpml:requestConfirmation xmlns:fpml="http://www.fpml.org/FpML-5/confirmation" actualBuild="6" fpmlVersion="5-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fpml.org/FpML-5/confirmation /xmls/OTC/fpml-main-5-1.xsd">
  :
  <isCorrection>false</isCorrection>
  <correlationId>1</correlationId>
  <sequenceNumber>1</sequenceNumber>
     :
        <relatedParty>
          <partyReference href="PH"/>
          <role>1<role>
        <relatedParty>
      :
          <currency>AUD</currency>
      :
  <party id="PH">
    <partyId>1234</partyId>
  </party>
  :
</requestConfirmation>

Please can you explain where I am going wrong? Your help would be greatly appreciated

Kind regards
Andrew King

Barclays Capital


_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________


More information about the xsd-users mailing list