[xsd-users] XSD Generate Insertion and XSD:AnyAttribute

Southworth Damon (AA-AS/EOS32) damon.southworth at uk.bosch.com
Thu Dec 8 14:08:00 EST 2016


Hi Boris,

I think I have come across another bug with the code generated by the xsd-tree compiler with the -generate-insertion option.
A new schema that we have included into the project turned out to use XSD:AnyAttribute, for which we had to use the --generate-wildcard option.
Whilst the generated code correctly reads the XML files and populates an attribute_set, when it is serialized to a binary format the data is lost.

The code generated for XML serialisation is fine...

void
  operator<< (::xercesc::DOMElement& e, const TypeWithAnyAttr& i)
  {
    e << static_cast< const ::xml_schema::type& > (i);

    // any_attribute
    //
    for (TypeWithAnyAttr::any_attribute_const_iterator
         b (i.any_attribute ().begin ()), n (i.any_attribute ().end ());
         b != n; ++b)
    {
      ::xercesc::DOMAttr* a (
        static_cast< ::xercesc::DOMAttr* > (
          e.getOwnerDocument ()->importNode (
            const_cast< ::xercesc::DOMAttr* > (&(*b)), true)));

      if (a->getLocalName () == 0)
        e.setAttributeNode (a);
      else
        e.setAttributeNodeNS (a);
    }
  }

Whereas the binary serialisation does nothing.

::xsd::cxx::tree::ostream< ACE_OutputCDR >&
  operator<< (::xsd::cxx::tree::ostream< ACE_OutputCDR >& s,
              const TypeWithAnyAttr &)
  {
    return s;
  }

Regards,

Damon




More information about the xsd-users mailing list