Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: S4s-elt-character: Non-whitespace Characters Are Not Allowed In Schema Elements Other Than 'xs:appinfo' And 'xs:documentation'

I have this xml-Schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
        <xs:element name="Fussballmannschaft">
                <xs:complexType>
                        <xs:attribute name="Name" type="xs:string" />
                        <xs:attribute name="Stadt" type="xs:string" />
                        <xs:attribute name="Tabellenplatz" type="xs:string" />
                        <xs:element name="Spieler">
                                <xs:complexType>
                                        <xs:attribute name="SpielerID" type="xs:string" />
                                        <xs:keyref name="I_D" refer="Name" />
                                        <xs:attribute name="Name" type="xs:string" />
                                        <xs:element name="Torwart">
                                                <xs:attribute name="GehealteneElfmeter" type="xs:integer" />
                                                <xs:keyref name="ID_Torwart" refer="SpielerID" />
                                        </xs:element>
                                        <xs:element name="Verteidiger">
                                                <xs:attribute name="GewonneneZweikaempfe" type="xs:integer" />
                                                <xs:keyref name="ID_Verteidiger" refer="SpielerID" />
                                        </xs:element>
                                        <xs:element name="Stuermer">
                                                <xs:attribute name="GeschosseneTore" type="xs:integer" />
                                                <xs:keyref name="ID_Stuermer" refer="SpielerID" />
                                        </xs:element>
                                </xs:complexType>
                        </xs:element>
                </xs:complexType>
        </xs:element>
</xs:schema>

and this sample:

<Fussballmannschaft Name="BVB">
<Stadt>Dortmund</Stadt>
<Tabellenplatz>3</Tabellenplatz>
    <Spieler SpielerID="1">
        <I_D>BVB</I_D>
        <Name>Oliver</Name>
        <Torwart>
            <GehealteneElfmeter>20</GehealteneElfmeter>
            <ID_Torwart>1</ID_Torwart>
        </Torwart>
    </Spieler>

    <Spieler SpielerID="2">
        <I_D>BVB</I_D>
        <Name>Peter</Name>
        <Torwart>
            <GewonneneZweikaempfe>20</GewonneneZweikaempfe>
            <ID_Verteidiger>2</ID_Verteidiger>
        </Torwart>
    </Spieler>

    <Spieler SpielerID="3">
        <I_D>BVB</I_D>
        <Name>Paul</Name>
        <Torwart>
            <GeschosseneTore>20</GeschosseneTore>
            <ID_Stuermer>3</ID_Stuermer>
        </Torwart>
    </Spieler>
</Fussballmannschaft>

But the parser says:

S4s-elt-character: Non-whitespace Characters Are Not Allowed In Schema Elements Other Than 'xs:appinfo' And 'xs:documentation'. Saw 'Dortmund'.

Do you know where the problem is?

like image 506
Marc Avatar asked Jul 06 '18 22:07

Marc


1 Answers

The real reason you're getting this error,

S4s-elt-character: Non-whitespace Characters Are Not Allowed In Schema Elements Other Than 'xs:appinfo' And 'xs:documentation

is that you're attempting to validate your XML file as an XSD file.

So, fix the way you're invoking your validating parser so that you're validating your XML file against your XSD. See How to link XML to XSD using schemaLocation or noNamespaceSchemaLocation?

Additionally, there are a slew of other problems with your XSD itself. See collapsar's answer for help there.

like image 160
kjhughes Avatar answered Oct 20 '22 11:10

kjhughes