XML Схема выдачи валидации - PullRequest
1 голос
/ 13 марта 2020

Я очень новичок в XML, и у меня возникают проблемы с проверкой, а также хотелось бы получить отзыв, если мои XML и XSD файлы хорошо структурированы.

Я постоянно получаю сообщение об ошибке при проверке XML по XSD -> Тип элемента "xs: схема" должен быть завершен соответствующим конечным тегом ""

XML ниже

<?xml version="1.0" encoding="UTF-8"?>
<alumnos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="alumnos.xsd">
        <alumno id=001>
            <nombre>Samuel</nombre>
            <apellido>Van Bladel</apellido>
            <email>Samuelvanbladel@gmail.com</email>
            <foto>https://google.com</foto> 
            <expediente>NX-0001R</expediente>
            <curso>1</curso> 
            <modulo>Mark up languages
            <nota>10/10</nota>
            <comentario>Muy bien hecho hasta el techo.</comentario>
            </modulo>
            <modulo>Java
            <nota>9/10</nota>
            <comentario>Codigo muy bien structurada.</comentario>
            </modulo>
        </alumno>

        <alumno id=002>
            <nombre>Deniz</nombre>
            <apellido>Turki</apellido>
            <email>DenizTurki@gmail.com</email>
            <foto>https://google.com</foto> 
            <expediente>NX-0002R</expediente>
            <curso>2</curso> 
            <modulo>Mark up languages
            <nota>10/10</nota>
            <comentario>Muy bien hecho hasta el techo.</comentario>
            </modulo>
            <modulo>Java
            <nota>9/10</nota>
            <comentario>Codigo muy bien structurada.</comentario>
            </modulo>
        </alumno>

        <alumno id=003>
            <nombre>Denisa</nombre>
            <apellido>Hermann</apellido>
            <email>Denisahermann@gmail.com</email>
            <foto>https://google.com</foto> 
            <expediente>NX-0003R</expediente>
            <curso>3</curso> 
            <modulo>Mark up languages
            <nota>10/10</nota>
            <comentario>Muy bien hecho hasta el techo.</comentario>
            </modulo>
            <modulo>Java
            <nota>9/10</nota>
            <comentario>Codigo muy bien structurada.</comentario>
            </modulo>
        </alumno>

        <alumno id=004>
            <nombre>Bruno</nombre>
            <apellido>porto</apellido>
            <email>BrunoPorto@gmail.com</email>
            <foto>https://google.com</foto> 
            <expediente>NX-0004R</expediente>
            <curso>4</curso> 
            <modulo>Mark up languages
            <nota>10/10</nota>
            <comentario>Muy bien hecho hasta el techo.</comentario>
            </modulo>
            <modulo>Java
            <nota>9/10</nota>
            <comentario>Codigo muy bien structurada.</comentario>
            </modulo>
        </alumno>

</alumnos>

XSD

<?xml version="1.0" encoding="UTF-8" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001XMLSchema-instance"
>


<!-- definition of simple elements -->
                    <xs:element name="nombre">
                      <xs:simpleType>
                        <xs:restriction base="xs:string">
                          <xs:minLength value="0"/>
                          <xs:maxLength value="20"/>
                        </xs:restriction>
                      </xs:simpleType>
                    </xs:element>

                    <xs:element name="apellido">
                      <xs:simpleType>
                        <xs:restriction base="xs:string">
                          <xs:minLength value="0"/>
                          <xs:maxLength value="30"/>
                        </xs:restriction>
                      </xs:simpleType>
                    </xs:element>

                    <xs:element name="comentario">
                      <xs:simpleType>
                        <xs:restriction base="xs:string">
                          <xs:minLength value="0"/>
                          <xs:maxLength value="50"/>
                        </xs:restriction>
                      </xs:simpleType>
                    </xs:element>

                    <xs:element name="modulo">
                      <xs:simpleType>
                        <xs:restriction base="xs:string">
                          <xs:minLength value="0"/>
                          <xs:maxLength value="10"/>
                        </xs:restriction>
                      </xs:simpleType>
                    </xs:element>

                    <xs:element name="nota" type="xs:string" >
                      <xs:simpleType>
                         <xs:restriction base="xs:integer">
                           <xs:minLength value="0"/>
                           <xs:maxLength value="10"/>
                         </xs:restriction>
                      </xs:simpleType>
                    </xs:element>

                    <xs:element name="email"/> 
                        <xs:simpleType > 
                          <xs:restriction base="xs:string"> 
                            <xs:pattern value="[^@]+@[^\.]+\..+"/> 
                          </xs:restriction> 
                        </xs:simpleType> 
                    </xs:element>

                    <xs:element name="foto">
                    <xs:simpleType>
                        <xs:restriction base="xs:anyURI">
                            <xs:pattern value="http://.+" />
                        </xs:restriction>
                        </xs:simpleType>
                    </xs:element>

                    <xs:element name="expediente">
                    <xs:simpleType>
                        <xs:restriction base="string">
                            <xs:pattern value="NX + [0-9][0-9][0-9][0-9][0-9] + R"/>
                        </xs:restriction>
                    </xs:simpleType>


<!-- definition of attributes -->
    <xs:attribute name="id" type="xs:integer" use="required"/>

<!-- definition of complex elements -->

    <xs:element name="alumno">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="nombre"/>
                <xs:element ref="apellido"/>
                <xs:element ref="modulo"/>
                <xs:element ref="nota"/>     
                <xs:element ref="expediente"/> 
                <xs:element ref="foto"/> 
                <xs:element ref="email"/>
                <xs:element ref="comentario"/>
            </xs:sequence>    
        </xs:complexType>
    </xs:element>

    <xs:element name="modulo">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="nota"/>     
                <xs:element ref="comentario"/>
            </xs:sequence>    
        </xs:complexType>
    </xs:element>


  </xs:element>
</xs:schema>

Если вы видите какие-либо ошибки в одном из них, не стесняйтесь указывать на них. Все они имеют ограничения от шаблонов до максимальной длины.

Спасибо !!!!

1 Ответ

2 голосов
/ 13 марта 2020

Вы закрыли тег ниже в вашем XSD.
<xs:element name="email"/> Это является причиной ошибки. Правильный путь <xs:element name="email">

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...