我有想要写的模式为两个XML示例:这个XML例子可以写出一个模式吗?
实施例1:
<attributes>
<attribute type="test" value="yes"/>
</attributes>
实施例2:
<attributes>
<attribute type="test">
<value x="100" y="50">yes</value>
</attribute>
</attributes>
实施例3:
<attributes>
<attribute type="test" value="no">
<value x="100" y="50">yes</value>
</attribute>
</attributes>
它是p可以有一个适用于这些模式? “价值”是一个属性,另一个是一个元素?
更新 对,我想我明白我的问题了。
我有这样的XSD:
<xs:complexType name="Attribute">
<xs:sequence >
<xs:element name="value" type="Value" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use="required">
</xs:attribute>
<xs:attribute name="value" type="xs:string" >
</xs:attribute>
</xs:complexType>
但是,当我尝试使用JAXB从XSD生成Java类我得到一个错误:
[xjc] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 275 of file:common.xsd
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 286 of file:common/common.xsd
[xjc] failure in the XJC task. Use the Ant -verbose switch for more details
我想这是在JAXB的限制而不是XSD。它会尝试创建两个名为getValue()的方法,这将失败。
它是什么让你觉得它不会是可能的? – 2011-01-31 22:47:28