[xsd-users] xsd-tree missing attribute/element content with type of xs:anySimpleType

hedisen2010 hedisen2010 at gmail.com
Sat Nov 23 08:24:59 EST 2013


Hello everyone:

I've got a problem where using xsd-tree mapping.
When I tried to serialization back to xml, the content of a attribute with type of 'xs:anySimpleType' is missing.

I can not modify that xml schema file, so I write a small test schema.  

<?xml version="1.0" encoding="utf-8"?>
<xs:schema
    targetNamespace="http://www.example.org/testxsd"
    elementFormDefault="qualified"
    xmlns="http://www.example.org/testxsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:complexType name="SimpleItem_t">
    <xs:attribute name="Name" type="xs:string" use="required"/>
    <xs:attribute name="Type" type="xs:QName" use="required"/>
    <xs:attribute name="Value" type="xs:anySimpleType" use="required"/>   
  </xs:complexType>
  
  <xs:element name="SimpleItem" type="SimpleItem_t" />
  
</xs:schema>

For generalize reason, attribute 'Type' indicates really data type of 'Value', it may be any xml schema qualified simple type name.
Then some test code

std::string itemXml(
    "<SimpleItem xmlns=\"http://www.example.org/testxsd\""
    "   Name=\"name\" Type=\"type\" Value=\"value\""
    "/>"
    );

std::istringstream is(itemXml);

std::auto_ptr<testxsd::SimpleItem_t> si(
    testxsd::SimpleItem(is,xml_schema::flags::dont_validate)  );

xml_schema::namespace_infomap nm;
nm[""].name = "http://www.example.org/testxsd";

testxsd::SimpleItem(std::cout,*si,nm);

Finally I got in output window:

<SimpleItem xmlns="http://www.example.org/testxsd" Name="name" Type="type" Value="" />

Notice that the content of attribute 'Value' is missing.

I don't know how to get the content back.

Hope for your reply.  Thanks.

2013-11-23 



Disen He


More information about the xsd-users mailing list