私の全体的な目標は、いくつかの小さなxsdで大きなxsdを分解することです。 xsdが "types.xsd"と呼ばれ、他のxsdsの1つが "request.xsd"と呼ばれているとします。要素への参照は、対象のxmlへの(不要な)名前空間を追加します
私は1つの中央ID "evalancheId"を要素として宣言していますref)してください。ただし、結果として得られるXMLには、参照された要素の名前空間接頭辞「ns:evalancheId」が付いています。
types.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://hansgrohe.com/pi/PA/C4C/Contact/10"
xmlns="http://hansgrohe.com/pi/PA/C4C/Contact/10">
<xsd:element name="evalancheId" type="xsd:int"/>
<xsd:complexType name="contactComplexType">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" name="givenName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="40"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<!-- ... -->
</xsd:sequence>
</xsd:complexType>
request.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://hansgrohe.com/pi/PA/C4C/Contact/10"
xmlns="http://hansgrohe.com/pi/PA/C4C/Contact/10">
<xsd:include schemaLocation="types.xsd"/>
<xsd:element name="updateContactReq" type="contactUpgradeComplexType"/>
<xsd:complexType name="contactUpgradeComplexType">
<xsd:complexContent>
<xsd:extension base="contactComplexType">
<xsd:sequence>
<xsd:element ref="evalancheId" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
result.xml
<ns:updateContactReq xmlns:ns="http://hansgrohe.com/pi/PA/C4C/Contact/10">
<givenName>Jay</givenName>
<ns:evalancheId>0815</ns:evalancheId>
</ns:updateContactReq>
actually_wanted.xml
<ns:updateContactReq xmlns:ns="http://hansgrohe.com/pi/PA/C4C/Contact/10">
<givenName>Jay</givenName>
<evalancheId>0815</evalancheId>
</ns:updateContactReq>
質問
- 私は名前空間を取り除くことができますどのように "NS:evalancheId" とまだevalancheId要素を再利用
多くのありがとうと親切にとらえて Tschenser