1
votes

I have a problem in xsd, i dont know why stackoverflow is preventing me from asking. I want to have a tag that looks like this

      <tag order="1">
      <something>something</something>
      </tag>

but i also want to validate this using validation.

in xsd, i have

<xsd:element name="tag">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="something">
<xsd:sequence>
<xsd:complexType>

i can individually pass syntax test but when i put both validation and the xml file together, i kept getting errors that say order attribute is not allowed to appear in this tag. I want to use this order attribute because it is required. If anyone can kindly let me know how! Much appreciate!

1

1 Answers

1
votes

Just add the attribute declaration to the complex type:

<xsd:element name="tag">
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element name="something">
   <xsd:sequence>
   <xsd:attribute name="order" type="xs:integer"/>
  <xsd:complexType>
</xsd:element>