[xsd-users] segmentation fault when using --type-map

Wahid hamishagi at yahoo.com
Mon Mar 12 02:45:30 EDT 2012


Hi, I am new to this interesting area and this is my first question.

I am reading the "C++/Parser Mapping Getting Started Guide" section 4(type mapping).

I tried to repeat the same example given in this tutorial but get segmentation fault when executing the driver example. 

Here are the details. I will appreciate your kind help:

people schema:


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:simpleType name="gender">
    <xs:restriction base="xs:string">
      <xs:enumeration value="male"/>
      <xs:enumeration value="female"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="person">
    <xs:sequence>
      <xs:element name="first-name" type="xs:string"/>
      <xs:element name="last-name" type="xs:string"/>
      <xs:element name="gender" type="gender"/>
      <xs:element name="age" type="xs:short"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="people">
    <xs:sequence>
      <xs:element name="person" type="person" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="people" type="people"/>

</xs:schema>

people.xml:
<?xml version="1.0" encoding="UTF-8"?>
<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="file:/home/vahid/workspace1/people1/people.xsd">
      <person>
    <first-name>John</first-name>
    <last-name>Doe</last-name>
    <gender>male</gender>
    <age>32</age>
  </person>
  <person>
    <first-name>Jane</first-name>
    <last-name>Doe</last-name>
    <gender>female</gender>
    <age>28</age>
  </person>
</people>

people.hxx :
#include <string>
#include <vector>

enum gender
{
  male,
  female
};

class person
{
public:
  person (const std::string& first,
          const std::string& last,
          ::gender gender,
          short age)
    : first_ (first), last_ (last),
      gender_ (gender), age_ (age)
  {
  }

  const std::string&
  first () const
  {
    return first_;
  }

  const std::string&
  last () const
  {
    return last_;
  }

  ::gender
  gender () const
  {
    return gender_;
  }

  short
  age () const
  {
    return age_;
  }

private:
  std::string first_;
  std::string last_;
  ::gender gender_;
  short age_;
};

typedef std::vector<person> people;

and finally people.map:
include "people.hxx";
gender ::gender ::gender;
person ::person;
people ::people;

the commands are:
1-xsd cxx-parser  --generate-print-impl --generate-test-driver --type-map people.map  people.xsd

2-c++ -I.../libxsd -c *.c*
3-c++ *.o -o driver -lxerces-c
4-  ./driver

the output is:
first-name: John
last-name: Doe
age: 32
Segmentation fault

how to solve this issue and, more importantly, why am i getting this? 
thank you

vahid







More information about the xsd-users mailing list