2012-04-09 12 views
1

私はこの質問を何度も投稿したことがわかります。しかし、私は今、新しいエラーが発生している、私は助けが必要です。ここに私が受け取っている誤りがある。 "s4s-elt-invalid-content.1: '#AnonType_orders'の内容が無効です。要素 'element'が無効であるか、置き忘れられているか、頻繁に発生しています。ここxsd検証の問題

は私のXSDファイルである:ここ

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
<xs:simpleType name="reach"> 
     <xs:restriction base = "xs:integer"> 
      <xs:enumeration value = "50" /> 
      <xs:enumeration value = "75" /> 
      <xs:enumeration value = "100" /> 
     </xs:restriction> 
</xs:simpleType> 
<xs:simpleType name = "language"> 
    <xs:restriction base = "xs:string"> 
     <xs:enumeration value = "Spanish" /> 
     <xs:enumeration value = "Chinese" /> 
     <xs:enumeration value = "English" /> 
     <xs:enumeration value = "German" /> 
     <xs:enumeration value = "French" /> 
    </xs:restriction> 
    </xs:simpleType> 
<xs:simpleType name="caseColor"> 
    <xs:restriction base="xs:string"> 
     <xs:enumeration value="Lemonde" /> 
     <xs:enumeration value="Strawberry" /> 
     <xs:enumeration value="Lime" /> 
     <xs:enumeration value="Blueberry" /> 
    </xs:restriction> 
    </xs:simpleType> 
<xs:simpleType name="numOfBat"> 
    <xs:restriction base="xs:integer"> 
     <xs:enumeration value="1" /> 
     <xs:enumeration value="2" /> 
     <xs:enumeration value="3" /> 
     <xs:enumeration value="4" /> 
    </xs:restriction> 
    </xs:simpleType> 
<xs:simpleType name="numOfCam"> 
    <xs:restriction base="xs:string"> 
     <xs:pattern value="1|2" /> 
    </xs:restriction> 
    </xs:simpleType> 
<xs:simpleType name="volt"> 
    <xs:restriction base="xs:string"> 
     <xs:enumeration value="110-120" /> 
     <xs:enumeration value="220-240" /> 
    </xs:restriction> 
    </xs:simpleType> 
<xs:element name="orders"> 
<xs:complexType> 
<xs:element name ="order" maxOccurs="unbounded"> 
<xs:complexType> 
<xs:sequence> 
    <xs:element name="custName" type ="xs:string" /> 
       <xs:attribute name ="custID" /> 
<xs:element name="case" type="xs:caseColor" > 
</xs:element> 
<xs:element name="batteries" type="xs:numOfBat" default = 
"1"> 
</xs:element> 
<xs:element name="recharger" type="xs:volt" /> 
<xs:element name="arm"> 
    <xs:element name ="reaches" minOccurs="2" maxOccurs="3" 
type="xs:reach" /> 
</xs:element> 
<xs:element name ="camera" type="xs:numOfCam" /> 
<xs:element name = "speech" type="xs:language" /> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
</xs:complexType> 
</xs:element> 
</xs:schema> 

は私のxmlファイルです:

<?xml version="1.0" encoding="UTF-8"?> 
<orders> 
<order> 
<custName custID="11223"> John Doe </custName> 
<case> Strawberry </case> 
<batteries> 2 </batteries> 
<recharger> 110-120 V </recharger> 
<arm> 
    <reach> 50 </reach> 
    <reach> 100 </reach> 
</arm> 
<camera> 2 </camera> 
<speech> Spanish </speech> 
</order> 
<order> 
<custName custID="45392"> Jane Camp </custName> 
<case> Lime </case> 
<batteries> 4 </batteries> 
<recharger> 220-240 V </recharger> 
<arm> 3 
    <reach> 75 </reach> 
    <reach> 75 </reach> 
    <reach> 100 </reach> 
</arm> 
<camera> 1 </camera> 
<speech> Chinese </speech> 
</order> 
<order> 
<custName custID="69482"> George Carlton </custName> 
<case> Blueberry </case> 
<batteries> 1 </batteries> 
<recharger> 110-120 V </recharger> 
<arm> 
    <reach> 75 </reach> 
    <reach> 100 </reach> 
</arm> 
<camera> 2 </camera> 
<speech> French </speech> 
</order> 
</orders> 

答えて

0

私はあなたが検証のために使用しているツールを知りませんが、それが生成するメッセージがいるように見えますむしろ役に立たない。詳細については、こちらをサクソンによって生成されるメッセージです:

Saxon-EE 9.5.0.1J from Saxonica 
Java version 1.6.0_27 
Using license serial number M008277 
Loading schema document file:/Users/mike/Desktop/temp/test.xsd 
Error at xs:element on line 48 column 49 of test.xsd: 
    Element xs:element cannot appear here: expected one of {choice, sequence, assert, 
    openContent, annotation, attributeGroup, anyAttribute, simpleContent, all, attribute, 
    group, complexContent} 
Error at xs:attribute on line 52 column 48 of test.xsd: 
    Element <xs:attribute> is not allowed as a child of <xs:sequence> 
Error at xs:element on line 61 column 19 of test.xsd: 
    Element xs:element cannot appear here: expected one of {annotation, simpleType, key, 
    complexType, keyref, unique, alternative} 
Error at xs:element on line 61 column 19 of test.xsd: 
    Element <xs:element> is not allowed as a child of <xs:element> 
Schema processing failed: 4 errors were found while processing the schema 

私はあなたがこれらの明確を見つける願っています。基本的に、問題は、xs:elementがxs:complexTypeの子として現れないことです。おそらくxs:sequenceのようなものが必要です。

+0

など、type="reach"type="numOfBat"type="caseColor"は、私は私のコードを検証するために使用していますサイトです。 http://corefiling.com/opensource/schemaValidate.html – beginnerprogrammer

+0

私は間違って何をしているのか、エラーを修正する方法は本当に分かりません。助言がありますか? – beginnerprogrammer

+0

@JohnTinioは私の答えを見てください。あなたは私が見ているいくつかの問題があります。 – psubsee2003

3

あなたのxsdがひどく形成されています。具体的には、orders要素です。カスタムタイプの間違ったネームスペースも参照しています。私は私が見ている問題を実行します。

まず:あなたのordersノードはxs:complexTypeとして定義され、あなたがcomplexTypeの子としてorder要素を持っていますが、要素が許可子ノードではありません。

<xs:element name="orders"> 
    <xs:complexType> 
    <xs:sequence> 
     <xs:element name ="order" maxOccurs="unbounded"> 
     <!-- existing nodes --> 
     </xs:element> 
    </xs:sequence> 
    </xs:complexType> 
</xs:element> 

次:あなたは間にxs:sequenceまたはxs:allを配置する必要があり、あなたのarm要素が1つの要素を持っていますが、xs:elementは、このコンテキストでは許可されていません。 complexTypeとして定義し、次にsequenceまたはallとしてください。

<xs:element name="arm"> 
    <xs:complexType> 
     <xs:sequence> 
      <xs:element name ="reaches" minOccurs="2" maxOccurs="3" type="reach" /> 
     </xs:sequence> 
    </xs:complexType> 
</xs:element> 

第三:あなたのcustId属性が正しい位置に定義されていません。 xs:attributesは属性として定義されている要素の子ノードとして定義する必要がありますが、xs:simpleTypeは属性ノードを持つことができないため、代わりにcomplexTypeとして定義する必要があります。ここにあなたの問題の可能な解決策はここにある:

<xs:element name="custName"> 
    <xs:complexType> 
     <xs:simpleContent> 
      <xs:extension base="xs:string"> 
       <xs:attribute name="custID" type="xs:int" use="required" /> 
      </xs:extension> 
     </xs:simpleContent> 
    </xs:complexType> 
</xs:element> 

そして最後に:カスタムタイプ(reachnumOfBatvolt、等)のすべてを参照するとき、あなたは、xs:名前空間の一部としてしかし、これらをそれらを参照しています型はxs:名前空間で定義されていません。 XSDのtargetNamespaceを定義しないので、カスタム型はデフォルトの名前空間の一部になります。タイプからxs:を削除するだけです。

たとえば、あなたのようにそれらを宣言する必要があります。ここ