제 질문은 What xsd will let an element have itself as a sub element infinitely?과 매우 흡사합니다.XML/XSD - 재귀 적으로 자체 내에서 complexType을 참조하려면 어떻게해야합니까?
내가 원하는 것은 XML 내에 스켈레톤을 생성 할 수있는 XML 구조를 활용하는 것입니다. XML에는 자체 특성 및 요소 데이터가 포함 된 Bone complexTypes의 재귀 목록을 포함하는 최상위 수준 complexType이 있습니다.
내가 사용 XML
은 여기에 있습니다 : 내가 사용하고<SkeletalMapping xmlns="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="test SkeletalDefinition.xsd">
<Skeleton sourceSkeleton="Max" targetSkeleton="UDK" version="1.0">
<Bone name="Origin" target="ROOT">
<PivotPoint x="0.0" y="0.0" z="0.0" />
<Bone name="UpperBody" target="SPINE">
<PivotPoint x="0.0" y="0.033" z="0.438" />
<Bone name="Head" target="HEAD">
<PivotPoint x="0.0" y="0.006" z="0.667" />
</Bone>
<Bone name="RightArm" target="RIGHT_ARM">
<PivotPoint x="-0.203" y="0.05" z="0.477" />
<Bone name="LRightHand" target="RIGHT_HAND">
<PivotPoint x="-0.586" y="0.074" z="0.067" />
</Bone> <!-- LeftHand -->
</Bone> <!-- LeftArm -->
<Bone name="LeftArm" target="LEFT_ARM">
<PivotPoint x="0.203" y="0.05" z="0.477" />
<Bone name="LeftHand" target="LEFT_HAND">
<PivotPoint x="0.587" y="0.074" z="0.066" />
</Bone> <!-- LeftHand -->
</Bone> <!-- LeftArm -->
</Bone> <!-- UpperBody -->
<Bone name="RightLeg" target="RIGHT_LEG">
<PivotPoint x="-0.14" y="-0.019" z="-0.467" />
<Bone name="RightFoot" target="RIGHT_FOOT">
<PivotPoint x="-0.17" y="0.083" z="-0.889" />
</Bone> <!-- RightFoot -->
</Bone> <!-- RightLeg -->
<Bone name="LeftLeg" target="LEFT_LEG">
<PivotPoint x="0.14" y="-0.019" z="-0.467" />
<Bone name="LeftFoot" target="LEFT_FOOT">
<PivotPoint x="0.17" y="0.083" z="-0.889" />
</Bone> <!-- LegFoot -->
</Bone> <!-- LeftLeg -->
</Bone> <!-- Origin -->
</Skeleton>
XSD입니다 : 내가 사용하고
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Vec3">
<xs:attribute name="x" type="xs:float"/>
<xs:attribute name="y" type="xs:float"/>
<xs:attribute name="z" type="xs:float"/>
</xs:complexType>
<xs:element name="Bone">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element ref="Bone" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:element name="PivotPoint" type="Vec3" minOccurs="0" maxOccurs="1"/>
<xs:attribute name="name" type="xsd:string" use="required"/>
<xs:attribute name="target" type="xsd:string" />
</xs:complexType>
</xs:element>
<xs:element name="Skeleton">
<xs:complexType>
<xs:sequence>
<xs:element ref="Bone" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="sourceSkeleton" type="xs:string" />
<xs:attribute name="targetSkeleton" type="xs:string" />
<xs:attribute name="version" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="SkeletonMapping">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="Skeleton"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
편집기는 XML 플러그인과 ++ 메모장입니다. XML 및 XSD 구문은 유효성 검사를 통과하지만 XSD의 XML 도구 유효성 검사에서 XML을 구문 분석 할 수 없다고 표시되는 이유를 알 수 없습니다.
<Skeleton>
<Bone>
<Bone>
<Bone/>
</Bone>
</Bone>
</Skeleton>
<Skeleton>
<BoneGroup>
<Bone>
<BoneGroup>
<Bone>
<BoneGroup>
<Bone/>
</BoneGroup>
</Bone>
</BoneGroup>
</Bone>
</BoneGroup>
</Skeleton>
에, 나는 새로운 창조하는 :
는 사람이 어떻게에서 뼈 상속을 깨는 시도했습니다 나는, 이것은 알려 주시기 바랍니다 해결할 수있는 방법을 알고있는 경우 요소 BoneGroup은 Bone을 참조했고, Bone은 BoneGroup에 대한 참조를 가지고 있었지만, 더 잘 작동하지 않았습니다.
고맙습니다. 페트로! 내가 게시 한 XML/XSD는 훨씬 큰 데이터 세트에서 수동으로 입력되었지만 불행히도 약간의 오타가있었습니다 (예 : 'Skeleton'vs. 'Skeletal'및 xsd : string). * 마음 속에서 문제의 근본 원인은 ''를 배치 한 것입니다. 당신이 말했듯이, 위의 시퀀스 내에 있어야합니다. * XSD에 xmlns : test를 추가하는 것을 잊었습니다. 이것은 내 바보 같은 또 다른 실수였습니다. 어쨌든, 도와 줘서 고마워. 귀하의 도움은 대단히 감사하겠습니다. –
@ Petru의 대답이 도움이 되었다면 정답으로 "확인"해야합니다. –