How to specify a child element in XML schema with a name but any content?

Posted by mackenir on Stack Overflow See other posts from Stack Overflow or by mackenir
Published on 2010-04-19T12:59:49Z Indexed on 2010/04/19 13:03 UTC
Read the original article Hit count: 195

Filed under:

I am trying to write some XML schema code to specify that a particular element 'abc' may have a child element with name 'xyz', and that element may have any attributes, and any child elements.

At the moment I have this:

    <xs:element name="abc">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="xyz">
            <xs:complexType>
              <xs:sequence>
                <xs:any/>
              </xs:sequence>
              <xs:anyAttribute/>               
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>

But when I validate my XML against the schema, I get validation failures complaining about the child elements of the xyz element.

© Stack Overflow or respective owner

Related posts about xml-schema