3
我有這樣的XML架構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="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>
如果我改變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">
,但我想使用ref ,並有我的XML像
<inv_constraint unaryOperator="not">
我該怎麼辦呢? 謝謝