[xsd-users] Parsing mixed content

Boris Kolpackov boris at codesynthesis.com
Sun Feb 16 11:07:08 EST 2014


Hi Fred,

Fred OLeary <fred at essentel.com> writes:

> Our XSD for this is of the form:
>     <xs:complexType name="foobar" mixed="true">
>         <xs:attribute name="attriubute1" type="xs:string" use="optional"/>
>     </xs:complexType>

The simplest solution is to change (I would even say "fix") your schema:

  <xs:complexType name="foobar">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="attriubute1" type="xs:string" use="optional"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>


> I would like the generated classes to contain methods to retreive the
> content if is present and hopefully a method to indicate if content is
> available

If you cannot change your schema, then the other two options are:

1. Use the DOM association feature. This approach is shown in the
   'mixed' example.

2. Customize the generated class to extract the content and provide
   the desired API. This approach is shown in the 'custom/mixed'
   example. 

Boris



More information about the xsd-users mailing list