[xsd-users] Evaluating XSD - XML format question

B.W.H. van Beest bwvb at xs4all.nl
Mon Aug 9 07:26:05 EDT 2010


Your are confusing the concept of an attribute (of the <MyMessage>
element (p1="1000" etc)) with that of a (sub)element. In your
xsd-schema, <MyMessage> only has attributes. There are no xsd:elements
defined in the complexType "MyMessageType"

Bertwim


Tom Richard Evensen wrote:
> Hi,
>
> We are currently evaluating XSD.
> While playing with the XSD-generated code in a test project, I came across an issue that I'm sure
> you can answer easily.
>
> I have a schema like this
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>    <xsd:element name="MyMessage" type="MyMessageType"/>
>    <xsd:complexType name="MyMessageType">
>       <xsd:attribute name="p1" type="xsd:long"/>
>       <xsd:attribute name="p2" type="xsd:long"/>
>       <xsd:attribute name="p3" type="xsd:long"/>
>       <xsd:attribute name="p4" type="xsd:float"/>
>    </xsd:complexType>
> </xsd:schema>
>
>
> The generated code is able read XML-files with this content
>
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <MyMessage p1="1000" p2="15" p3="12345678" p4="123456"/>
>
>
> but not with this content
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <MyMessage>
> <p1>1000</p1>
> <p2>15</p2>
> <p3>12345678</p3>
> <p4>123456</p4>
> </MyMessage>
>
>
>
> When trying to read the second version, I get two errors for each line telling me that "no character
> data is allowed by content model", and "no declaration found for element p?" (substitute ? with
> 1..4).
> In addition it tells me that "element p1 is not allowed for content model EMPTY".
>
> Shouldn't these to data representations be the same?
> What am I missing, or what am I doing wrong?
>
> I'm using the xsd-tree customization build in VS2010, and setting the property
> no_namespace_schema_location to the xsd-file above.
>
>
> Kind regards,
> Tom R. Evensen
>
>   



More information about the xsd-users mailing list