2013-04-01 4 views
-2

Пожалуйста скажите мне предложение, где исправить ... я перепробовала много, но не мог проверить на http://xmlvalidator.new-studio.org/ мой XML являетсяне может проверить мой XML против XSD

<?xml version="1.0" standalone="yes"?> 
<timeofownership> 
<user name="Sana Smith"> 
<location type="Appartment"> 
    <articles> 
    <pid>AA</pid> 
    <product>Laptop</product> 
    <OwnFor>30 Days 3 Months 4 Years</OwnFor> 
    </articles> 
</location> 
</user> 
<user name="Rooney Mara"> 
<location type="House"> 
    <articles> 
    <pid>DD</pid> 
    <product>iPhone</product> 
    <OwnFor>10 Days 4 Months 1 Years</OwnFor> 
    </articles> 
</location> 
</user> 
<user name="Rooney Mara"> 
<location type="House"> 
    <articles> 
    <pid>TT</pid> 
    <product>iPad</product> 
    <OwnFor>10 Days 4 Months 0 Years</OwnFor> 
    </articles> 
    </location> 
</user> 
<user name="Sana Smith"> 
<location type="House"> 
    <articles> 
    <pid>BB</pid> 
    <product>Desktop</product> 
    <OwnFor>5 Days 3 Months 3 Years</OwnFor> 
    </articles> 
</location> 
</user> 
<user name="Peter Parker"> 
    <location type="House"> 
    <articles> 
    <pid>CC</pid> 
    <product>Fridge</product> 
    <OwnFor>30 Days 7 Months 0 Years</OwnFor> 
    </articles> 
    </location> 
    </user> 
<user name="Mia Chu"> 
    <location type="Appartment"> 
    <articles> 
    <pid>ZZ</pid> 
    <product>PS3</product> 
    <OwnFor>30 Days 2 Months 0 Years</OwnFor> 
    </articles> 
    </location> 
    </user> 
    </timeofownership> 

И схемы XSD IS-

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
<xs:element name="timeofownership" > 
<xs:complexType> 
    <xs:sequence> 
    <xs:element name="user" minOccurs="0" maxOccurs="unbounded"> 
     <xs:complexType> 
     <xs:element name="location"> 
      <xs:complexType> 
      <xs:element name="articles"> 
       <xs:complexType> 
       <xs:sequence> 
        <xs:element name="pid" type="xs:string"/> 
        <xs:element name="product" type="xs:string"/> 
        <xs:element name="OwnFor" type="xs:string"/> 
       </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
      <xs:attribute name="type" type="xs.string"/> 
      </xs:complexType> 
     </xs:element> 
     <xs:attribute name="name" type="xs:string"/> 
     </xs:complexType> 
    </xs:element> 
    </xs:sequence> 
</xs:complexType> 
</xs:element> 
</xs:schema> 

Просьба дать мне указание для этого. спасибо в ожидании.

+1

Что такое сообщение об ошибке? –

+1

Является ли это опечаткой в ​​вашем атрибуте 'type':' type = "xs.string" '? (вместо 'xs: string') – Filburt

+0

ошибка is-" Строка 1 Столбец 72: cvc-elt.1: Не удается найти объявление элемента «timeofownership» ». –

ответ

1

В своем определении для узлов location и user, которые вы забыли обернуть ваши элементы внутри своего рода узла группировки.

Вы не можете сделать:

<xs:complexType> 
    <xs:element name="foo"> 
    ... 
    </xs:element> 
    <xs:attribute name="bar" type="xs:string"/> 
<xs:complexType> 

Вы должны обернуть его, в вашем случае, вероятно, с xs:all

<xs:complexType> 
    <xs:all minOccurs="1"> 
    <xs:element name="foo"> 
     ... 
    </xs:element> 
    </xs:all> 
    <xs:attribute name="bar" type="xs:string"/> 
</xs:complexType> 
+0

все еще не подтверждают успех .. ошибка show is- "Строка 1 Столбец 72: cvc-elt.1: Не удается найти объявление элемента« timeofownership »». –

+0

@MM Извините, я не смог воспроизвести ошибку. [Схема с предлагаемыми изменениями] (http://pastebin.com/cG7Y4xEJ) отлично работает как на веб-сайте, который вы связали, так и в визуальной студии. В этой заметке, в отсутствие лучшего редактора, вы действительно должны получить его копию, если вы собираетесь работать с XML-схемой; это поймало бы большинство из этих проблем. – Alan

+0

Большое спасибо @Alan. –

Смежные вопросы