2011-06-26 5 views
5

Bir XSD'ye karşı doğrulamak istediğim basit bir XML dosyası aldım. Bunun için LookingXSD'ye karşı XML doğrulanırken hata oluştu

<?xml version="1.0"?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     targetNamespace="http://schemas.testxyzxyz.de/xyz/BusinessModel" 
     xmlns="http://schemas.testxyzxyz.de/xyz/BusinessModel"> 

<xsd:element name="BusinessModel" type="BusinessModelType" /> 

<xsd:complexType name="BusinessModelType"> 
    <xsd:choice minOccurs="0" maxOccurs="unbounded"> 
     <xsd:element name="Entities" type="EntitiesType" /> 
    </xsd:choice> 
</xsd:complexType> 

<xsd:complexType name="EntitiesType"> 
    <xsd:sequence> 
     <xsd:element name="Entity" type="EntityType" maxOccurs="unbounded" /> 
    </xsd:sequence> 
</xsd:complexType> 

<xsd:complexType name="AttributeType"> 
    <xsd:attribute name="Name" type="xsd:string" use="required" /> 
    <xsd:attribute name="Type" type="xsd:string" use="required" /> 
</xsd:complexType> 

<xsd:complexType name="EntityType"> 
    <xsd:sequence> 
     <xsd:element name="Attribute" type="AttributeType" maxOccurs="unbounded" minOccurs="1" /> 
    </xsd:sequence> 
     <xsd:attribute name="Name" type="xsd:string" use="required" /> 
</xsd:complexType> 
</xsd:schema> 

: Burada

Invalid content was found starting with element 'Entities'. One of '{Entities}' is expected.

XML var:

<BusinessModel xmlns="http://schemas.testxyzxyz.de/xyz/BusinessModel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<Entities> 
    <Entity Name="Customer"> 
     <Attribute Name="Forename" Type="String" /> 
     <Attribute Name="Surname" Type="String" /> 
     <Attribute Name="Birthday" Type="Date" /> 
    </Entity> 
</Entities> 
</BusinessModel> 

yanı sıra XSD bazı rasgele doğrulayıcı ile doğrulamak zaman , hep aşağıdaki hatayı alıyorum saatten beri sorun ve hala bir hata bulamıyorum. Bana doğru yönü gösterir misin? ;)

cevap

3

XML Representation of Element Declaration Schema Components:

{target namespace}

If form is present and its actual value is qualified , or if form is absent and the actual value of elementFormDefault on the <schema> ancestor is qualified , then the actual value of the targetNamespace [attribute] of the parent <schema> element information item, or absent if there is none, otherwise absent.

elemeFormDefault varsayılan değeri unqualified olduğundan, aksi yerel unsurların niteliksiz olmalıdır belirtilmediği sürece.

xmlns="http://schemas.testxyzxyz.de/xyz/BusinessModel"'u ayarladığınızdan, Entities kalifiye oldu. Düzeltme, @polishchuk yazdığı gibi elementFormDefault="qualified" ayarlamaktır.

+0

Teşekkürler, bu sorunu çözdü :) –

0

bu şemayı deneyin:

<?xml version="1.0"?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://schemas.testxyzxyz.de/xyz/BusinessModel" xmlns:b="http://schemas.testxyzxyz.de/xyz/BusinessModel"> 
    <xsd:element name="BusinessModel" type="b:BusinessModelType" /> 
    <xsd:complexType name="BusinessModelType"> 
    <xsd:choice minOccurs="0" maxOccurs="unbounded"> 
     <xsd:element name="Entities" type="b:EntitiesType" /> 
    </xsd:choice> 
    </xsd:complexType> 
    <xsd:complexType name="EntitiesType"> 
    <xsd:sequence> 
     <xsd:element name="Entity" type="b:EntityType" maxOccurs="unbounded" /> 
    </xsd:sequence> 
    </xsd:complexType> 
    <xsd:complexType name="AttributeType"> 
    <xsd:attribute name="Name" type="xsd:string" use="required" /> 
    <xsd:attribute name="Type" type="xsd:string" use="required" /> 
    </xsd:complexType> 
    <xsd:complexType name="EntityType"> 
    <xsd:sequence> 
     <xsd:element name="Attribute" type="b:AttributeType" maxOccurs="unbounded" minOccurs="1" /> 
    </xsd:sequence> 
    <xsd:attribute name="Name" type="xsd:string" use="required" /> 
    </xsd:complexType> 
</xsd:schema>