Shammer's Philosophy

My private adversaria

the content of an element information item must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*).

attribute要素をXML Schemaで定義するときには、complexType要素の中に含めなければならないらしい。
最初のSchema定義ではこれを間違えていて、complexTypeの外に定義していた。

<element name="sampleElement">
  <complexType>
    <〜複数のタグ〜>
  </complexType>
  <attribute name="sampleAttribute" type='string' use='required'/>
</element>

というように、定義されていたが、こうなっていると

the content of an element information item must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*).

というエラーになる。正しくは、

<element name="sampleElement">
  <complexType>
    <〜複数のタグ〜>
    <attribute name="sampleAttribute" type="string" use="required"/>
  </complexType>
</element>

というようになっているのが正しい。
XML Schemaの内容を見てみれば、これがあるべきだとすぐにわかるが。
やっぱり感覚でなく、しっかりマニュアルを読まなければダメだな。



話は変わるけれども・・・このXML解析をやり始めた当初は、

JavaのカテゴリでなくXMLのカテゴリにしようかと考えたが、結局Javaにしてしまった。

ここまでXMLの内容ばかりになると、さすがにカテゴリを作らないといけないのでは?

とまた思ってみたり。。。サブカテゴリみたいなヤツまで作れればいいのに。