私の質問はWhat xsd will let an element have itself as a sub element infinitely?と非常によく似ています。XML/XSD - 再帰的に自身の内部で複合型を参照するにはどうすればよいですか?
私がしたいことは、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>
<BoneGroup>
<Bone>
<BoneGroup>
<Bone>
<BoneGroup>
<Bone/>
</BoneGroup>
</Bone>
</BoneGroup>
</Bone>
</BoneGroup>
</Skeleton>
に
<Skeleton>
<Bone>
<Bone>
<Bone/>
</Bone>
</Bone>
</Skeleton>
私は新しいを作成しましたBoneへの参照を持っていたBoneGroupという要素がBoneGroupへの参照を持っていましたが、それはうまくいきませんでした。
ありがとうペトロ!投稿したXML/XSDは、より大きなデータセットから手動で入力されましたが、残念ながらその中にいくつかの小さなタイプミス(例: 'Skeleton'と 'Skeletal'とxsd:string)がありました。 *それを心に留めれば、問題の根源は私の ''の配置でした。あなたが言ったのと同じように、それはその上のシーケンス内に置かれていたはずです。* xmlns:testをXSDに追加するのを忘れていました。これは私の別の愚かな間違いでした。とにかく、助けてくれてありがとう。あなたの援助は非常に高く評価されます。 –
@ Petruの答えが役に立つのであれば、それを正しい答えとして「チェック」する必要があります。 –