[xsd-users] Codesynthesis XSD Access Violation using xsd:any

Chew kk chew.on.it at gmail.com
Tue May 27 08:25:36 EDT 2014


Hi,

I'm getting an exception "Unhandled exception at 0x1202e9fd
(xerces-c_3_1D_vc100.dll) in driver.exe: 0xC0000005: Access violation
reading location 0xfeeefef6" when I tried to run the following code.
Appreciate if someone could help. I'm using generate-wildcard and
generate-serialization with the xsd. My intention is to keep the optional
element when the xsd serialize the xml after modification.

  xercesc::XMLPlatformUtils::Initialize ();

  if (argc != 2)
  {
    cerr << "usage: " << argv[0] << " hello.xml" << endl;
    return 1;
  }

  try
  {
    auto_ptr<hello_t> h (hello (argv[1],
             xml_schema::flags::keep_dom |
             xml_schema::flags::dont_initialize));
    for (hello_t::name_const_iterator i (h->name ().begin ());
         i != h->name ().end ();
         ++i)
    {
      cout << h->greeting () << ", " << *i << "!" << endl;
    }

    h->greeting("www");

    //getch();
    xml_schema::namespace_infomap map;
    map[""].schema = "hello.xsd";

    // Serialize to a file.
    //
    std::ofstream ofs("hello.xml");
    hello(ofs, *h,
map,"UTF-8",xml_schema::flags::keep_dom|xml_schema::flags::dont_initialize);
    xercesc::XMLPlatformUtils::Terminate ();
  }
  catch (const xml_schema::exception& e)
  {
    cerr << e << endl;
    return 1;
  }


Here's my xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:complexType name="hello_t">

    <xsd:annotation>
      <xsd:documentation>
        The hello_t type consists of a greeting phrase and a
        collection of names to which this greeting applies.
      </xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>

      <xsd:element name="greeting" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>
            The greeting element contains the greeting phrase
            for this hello object.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="name" type="xsd:string" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>
            The name elements contains names to be greeted.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="notes" minOccurs="0">
        <xsd:complexType>
        <xsd:sequence>
            <xsd:any minOccurs="0" maxOccurs="unbounded"
processContents="skip"/>
        </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="hello" type="hello_t">
    <xsd:annotation>
      <xsd:documentation>
        The hello element is a root of the Hello XML vocabulary.
        Every conforming document should start with this element.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

</xsd:schema>

Thank You,
Chew


More information about the xsd-users mailing list