Xsd xml模式属性ref
我有这个xml模式Xsd xml模式属性ref,xsd,attributes,Xsd,Attributes,我有这个xml模式 <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://hidden/abc" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://hidden/abc" elementFormDefault="qualified" attributeFormDefault="unquali
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://hidden/abc" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://hidden/abc" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="1.8">
<xs:element name="inv_constraint">
<xs:complexType>
<xs:sequence>
---lots of stuff---
</xs:sequence>
<xs:attribute name="unaryOperator">
<xs:annotation>
<xs:documentation>Negate an entire expression.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="not"></xs:enumeration>
<xs:enumeration value="-"></xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
---很多东西---
否定整个表达式。
然后是使用它的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<OCL xmlns="http://hidden/abc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://hidden/abc abc.XSD">
------ lots of stuff
<inv_constraint unaryOperator="not">
<property src="A1" ref="PR1"/>
<matOperation operator="ge">
<value>0</value>
</matOperation>
</inv_constraint>
------很多东西
0
如果我将xml模式更改为使用ref=“”属性,如下所示:
...
<xs:attribute ref="unaryOperator"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:attribute name="unaryOperator">
<xs:annotation>
<xs:documentation>Negate an entire expression.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="not"></xs:enumeration>
<xs:enumeration value="-"></xs:enumeration>
</xs:restriction>
</xs:simpleType>
。。。
否定整个表达式。
然后,我的xml变成:
<inv_constraint xmlns:ns1="http://hidden/abc" ns1:unaryOperator="not">
但我想用裁判
让我的xml像
<inv_constraint unaryOperator="not">
我怎么做?
谢谢在XML模式中,所有全局元素、属性或类型定义都必须是限定的。因此,即使您已将attributeFormDefault定义为“unqualified”,所有全局定义的属性也将以命名空间为前缀。解决方法是在属性组或全局类型内定义此属性,然后可以引用此命名组或扩展此命名类型
<xs:attributeGroup name="unaryGroup">
<xs:attribute name="unaryOperator">
<xs:annotation>
<xs:documentation>Negate an entire expression.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="not"></xs:enumeration>
<xs:enumeration value="-"></xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
否定整个表达式。
需要此属性时,请参考attributeGroup而不是属性。属性组不需要包含元素使用的所有属性,这也应该是有效的:
<xs:complexType name="UnaryType">
<xs:attributeGroup ref="unaryGroup"/>
<xs:attribute name="otherAttribute" type="xs:string"/>
</xs:complexType>