Avatar billede fredand Forsker
07. februar 2007 - 10:17 Der er 1 løsning

Whats wrong with this XSD?

Hello!

Our customer has provide us with this xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="Document">
        <xs:complexType>
            <xs:attribute name="Id" type="xs:string" use="required"/>
            <xs:attribute name="Name" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string"/>
                </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="Category" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string"/>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
    <xs:element name="DocumentList">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Document" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="Folder">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="DocumentList"/>
            </xs:sequence>
            <xs:attribute name="Id" type="xs:string" use="required">   
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:pattern value="[0-9]{4}-[0-9]{4}"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
</xs:schema>

But during my validation in my Java code with this xsl and in XML Spy I got the message that this XSL is not valid, the message looks like this in XML Spy:

This schema doesn'tmappear to be valid by itself (as part of another schema, it might still be OK):
Schema error - undefind schema component 'xs:simpleType' encountered - only one type or simpleType may be used

It also points/marks the rows:
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:pattern value="[0-9]{4}-[0-9]{4}"/>
                    </xs:restriction>
                </xs:simpleType>

So I guess ther must be a problem here.

Do you see the problem?

Best regards
Fredrik
Avatar billede fredand Forsker
07. februar 2007 - 14:54 #1
Hello!

The error was attribute type="xs:string"

It should look like:

            <xs:attribute name="Id" use="required">               
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:pattern value="[0-9]{4}-[0-9]{4}"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>

Best regards
Fredrik
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester