알 수없는 깊이의 XML을 확인하기 위해 XSD를 생성하려고합니다. 이 작업은 XML의 XSLT를 통해 수행됩니다. XML은 클래스 설명처럼 다소 구조화되어 있으며 모든 노드에는 특성 및 하위에 대한 정보가 들어 있습니다. XSD는 인스턴스가 들어있는 다른 XML을 확인해야합니다. 따라서 XSD는 인스턴스가 클래스의 모든 속성을 가지고 있고 조상이라고 판단해야합니다.XSD 여러 수준의 확장 문제
그래서 나는 서로를 확장하는 유형으로 내 문제를 해결하려고했습니다.
XML 테스트 파일 :
<!-- language:xml -->
<?xml version="1.0" encoding="UTF-8"?>
<CAEXFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
FileName="Visu_Ruehrreaktor.aml"
SchemaVersion="2.15"
xsi:noNamespaceSchemaLocation="Validation.xsd">
<HMI>
<HMIGraphic Name="Visu_Ruehrreaktor"
RefBaseSystemUnitPath="HMISUCLib/Graphic"
ID="dce863ca-795b-4d54-9a4c-789b0204f243">
<h>1080</h>
<w>1920</w>
<HMIVisuObjectTextBoxTermination Name="Text01"
RefBaseSystemUnitPath="HMISUCLib/VisuObject/TextBox/Termination"
ID="c0215848-b8b6-4f76-aa2c-3996a053f3fc">
<text/>
<tagname>Text01</tagname>
<x>178</x>
<y>152</y>
<h>37</h>
<w>139</w>
<role/>
<type>0001</type>
<rotation>01</rotation>
<com_id/>
</HMIVisuObjectTextBoxTermination>
</HMIGraphic>
</HMI>
</CAEXFile>
XSD :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xs:complexType name="HMI_type">
<xs:choice maxOccurs="unbounded">
<xs:element name="HMIGraphic" type="HMIGraphic_type" minOccurs="0"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="HMIVisuObject_type">
<xs:choice maxOccurs="unbounded">
<xs:element name="tagname" minOccurs="1" maxOccurs="1"/>
<xs:element name="x" minOccurs="1" maxOccurs="1"/>
<xs:element name="y" minOccurs="1" maxOccurs="1"/>
<xs:element name="h" minOccurs="1" maxOccurs="1"/>
<xs:element name="w" minOccurs="1" maxOccurs="1"/>
<xs:element name="role" minOccurs="1" maxOccurs="1"/>
<xs:element name="type" minOccurs="1" maxOccurs="1"/>
<xs:element name="rotation" minOccurs="1" maxOccurs="1"/>
</xs:choice>
<xs:attribute name="Name" type="xs:string" use="required"/>
<xs:attribute name="RefBaseSystemUnitPath" type="xs:string" use="required"/>
<xs:attribute name="ID" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType name="HMIVisuObjectTextBox_type">
<xs:complexContent>
<xs:extension base="HMIVisuObject_type">
<xs:choice maxOccurs="unbounded">
<xs:element name="text" minOccurs="1" maxOccurs="1"/>
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="HMIVisuObjectTextBoxTermination_type">
<xs:complexContent>
<xs:extension base="HMIVisuObjectTextBox_type">
<xs:choice maxOccurs="unbounded">
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="HMIGraphic_type">
<xs:choice maxOccurs="unbounded">
<xs:element name="HMIVisuObject" type="HMIVisuObject_type" minOccurs="0"/>
<xs:element name="HMIVisuObjectTextBox"
type="HMIVisuObjectTextBox_type"
minOccurs="0"/>
<xs:element name="HMIVisuObjectTextBoxTermination"
type="HMIVisuObjectTextBoxTermination_type"
minOccurs="0"/>
<xs:element name="h" minOccurs="1" maxOccurs="1"/>
<xs:element name="w" minOccurs="1" maxOccurs="1"/>
</xs:choice>
<xs:attribute name="Name" type="xs:string" use="required"/>
<xs:attribute name="RefBaseSystemUnitPath" type="xs:string" use="required"/>
<xs:attribute name="ID" type="xs:string" use="required"/>
</xs:complexType>
<xs:element name="CAEXFile">
<xs:complexType>
<xs:all>
<xs:element name="HMI" type="HMI_type" minOccurs="0"/>
</xs:all>
<xs:anyAttribute processContents="skip"/>
</xs:complexType>
</xs:element>
</xs:schema>
문제는 그 유효성 검사를 실행하고 유형의 요소를 찾아 그 어느 때 HMIVisuObjectTextBoxTermination_type 내가 말하는 오류가 발생한다 을 그 텍스트은 요소로 사용할 수 없습니다.
출력/To_Check.aml : 15 : 요소 텍스트 : 스키마 유효성 오류 : 요소 'text':이 요소는 필요하지 않습니다. 예상되는 것은 (tagname, x, y, h, w, 역할, 유형, 순환) 중 하나입니다.
기본적으로이 유형의 체인의 루트 요소 요소 만. 내가 뭘 잘못하고 어떻게이 문제를 해결할 수 있습니다. 사전
두 파일을 모두 추가했습니다. 나는 그것이 도움이되기를 바랍니다. – Tyreal