[xsd-users] Help me: Borland C++ Builder 2007 compiled program has unwanted prefix and all property values are missing.

James Mei jxmei3 at gmail.com
Mon Oct 12 07:41:13 EDT 2009


Hi Boris

Thanks for the fast reply. Really appreciate your help.

After I changed the libxsd/xsd/cxx/tree/containers.hxx, the program compiles
and run in BCB 2007. However it still does not read the properties value and
has "p1" prefix in front of every tag.

Here is the updated main program:

int main (int argc, char* argv[])
{
  try
  {
    using namespace SC_SCL;
    auto_ptr<SCL> h (SCL_ (argv[1], xml_schema::flags::dont_validate));

    xml_schema::namespace_infomap map;
    map[""].name = "http://www.codesynthesis.com/xsd/SCL";
    map[""].schema = "SCL.xsd";

    ofstream outfile(argv[2], ios::out);
    SCL_ (outfile, *h, map);
//    SCL_(outfile, *h);

  }
  catch (const xml_schema::exception& e)
  {
    cerr << e << endl;
    return 1;
  }
}

input XML

<?xml version="1.0" encoding="utf-8"?>
<SCL xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns="http://www.iec.ch/61850/2003/SCL"
xsi:schemaLocation="http://www.iec.ch/61850/2003/SCL SCL.xsd">
  <Header id="SEL"/>
  <Communication>
    <SubNetwork name="NONE">
      <ConnectedAP iedName="SEL_421" apName="P1">
        <Address>
          <P type="OSI-AP-Title">1,1,1,999,1</P>
          <P type="OSI-AE-Qualifier">12</P>
          <P type="OSI-PSEL">00000001</P>
          <P type="OSI-SSEL">0001</P>
          <P type="OSI-TSEL">0001</P>
          <P type="IP">209.254.235.118</P>
        </Address>
..................

Output XML
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<p1:SCL xmlns:p1="http://www.iec.ch/61850/2003/SCL" xmlns="
http://www.codesynthesis.com/xsd/SCL" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.codesynthesis.com/xsd/SCL SCL.xsd">

  <p1:Header id="" nameStructure="" revision=""/>

  <p1:Communication>
    <p1:SubNetwork name="">
      <p1:ConnectedAP apName="" iedName="">
        <p1:Address>
          <p1:P type=""/>
          <p1:P type=""/>
          <p1:P type=""/>
          <p1:P type=""/>
          <p1:P type=""/>
          <p1:P type=""/>
        </p1:Address>

Again, the "p1" prefix is still there and all the properties values are
missing.

Best Regards
James


On Mon, Oct 12, 2009 at 5:52 PM, Boris Kolpackov <boris at codesynthesis.com>wrote:

> Hi James,
>
> James Mei <jxmei3 at gmail.com> writes:
>
> > During compilation, it prompts the follow error:
> >
> > [BCC32 Error] SCL.cxx(273): E2093 'operator!' not implemented in type
> > 'xsd::cxx::tree::optional<tCommunication>' for arguments of the same type
>
> The optional container implements "conversion to bool" via conversion
> to a function pointer. This is the recommended way but it is probably too
> much for BCB to handle. You can try to use the simpler but more dangerous
> approach by converting directly to bool. For this, change the following
> lines in libxsd/xsd/cxx/tree/containers.hxx:
>
> typedef optional self_; // Simplifier for Sun C++ 5.7.
> typedef void (self_::*bool_convertible) ();
>
> operator bool_convertible () const
> {
>  return x_ != 0 ? &self_::true_ : 0;
> }
>
> To this:
>
> operator bool () const
> {
>  return x_ != 0;
> }
>
> Note that there are two places in containers.hxx where you need to
> change this.
>
>
> > Unexpected result 1: All the tags has an "p1:" prefix.
>
> It is automatically assigned since you haven't specified the namespace-
> prefix mapping for http://www.codesynthesis.com/xsd/SCL (BTW, you probably
> don't want to use www.codesynthesis.com in your XML namespaces; if you
> need
> some dummy domain name, www.example.com is a good choice).
>
> If you want your output XML to look similar to the input, change your
> serialization code like so:
>
> xml_schema::namespace_infomap map;
> map[""].name = "http://www.codesynthesis.com/xsd/SCL";
> map[""].schema = "SCL.xsd";
>
> ofstream outfile(argv[2], ios::out);
> SCL_(outfile, *h, map);
>
>
> Boris
>


More information about the xsd-users mailing list