0

我通过编组生成了这个 xml 文件,然后我想通过验证它的模式来解组它。为什么这个 xml :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProjectConfiguration xmlns="http://ereg.egov.bg/segment/0009-900001">
    <CreationTime>2012-08-30T15:32:06.712+03:00</CreationTime>
    <Applications>
        <Application>
            <Version>1.0</Version>
            <CreationTime>2012-08-30T15:32:06.712+03:00</CreationTime>
            <FileName>ROSAppl-37</FileName>
        </Application>
    </Applications>
</ProjectConfiguration>

不是针对此架构的有效 xml:

<?xml version="1.0"?>
<xsd:schema 
targetNamespace="http://www.bulsi.bg/egov/ProjectConfiguration"
xmlns="http://www.bulsi.bg/egov/ProjectConfiguration"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>

<xsd:element name="ProjectConfiguration" type="ProjectConfigurationType" />

<xsd:complexType name="ProjectConfigurationType">
    <xsd:annotation>
        <xsd:documentation xml:lang="bg">Конфигурация на проекта</xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>  
        <xsd:element name="CreationTime" type="xsd:dateTime">
            <xsd:annotation>
                <xsd:documentation xml:lang="bg">Време на създаване</xsd:documentation>
            </xsd:annotation>
        </xsd:element>

        <xsd:element name="Applications" minOccurs="1" maxOccurs="1">
            <xsd:annotation>
                <xsd:documentation xml:lang="bg">Заявления</xsd:documentation>
            </xsd:annotation>
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="Application" type="ApplicationType" minOccurs="1" maxOccurs="unbounded" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>                      
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ApplicationType" >
    <xsd:annotation>
        <xsd:documentation xml:lang="bg">Данни за заявление за вписване</xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>
        <xsd:element name="Version" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation xml:lang="bg">Версия на заявлението</xsd:documentation>
            </xsd:annotation>
        </xsd:element>

        <xsd:element name="CreationTime" type="xsd:dateTime">
            <xsd:annotation>
                <xsd:documentation xml:lang="bg">Време на създаване</xsd:documentation>
            </xsd:annotation>
        </xsd:element>

        <xsd:element name="FileName" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation xml:lang="bg">Име на файл, в който е заявлението. Връзка между конфигурационни параметри и заявлението като файл</xsd:documentation>
            </xsd:annotation>
        </xsd:element>  
    </xsd:sequence>
</xsd:complexType>

</xsd:schema>

这是错误:Cvc-elt.1.a:找不到元素“ProjectConfiguration”的声明..“2”行,“71”列。

4

1 回答 1

1
  • 您的 XML 实例:xmlns="http://ereg.egov.bg/segment/0009-900001"
  • 您的 XML 架构:targetNamespace="http://www.bulsi.bg/egov/ProjectConfiguration"

这些 URI 应该匹配。

否则,<ProjectConfiguration>您的 Xml 文档中的元素将被假定属于http://ereg.egov.bg/segment/0009-900001未在您的架构中定义的名称空间。

于 2012-08-31T09:46:26.903 回答