Question

I can't find the problem an tried different things. I would really appreciate any kind of help. I had a valid .xsd document, but changed some parts of the xml and now I'm unable to get it valid and I don't find the fault. The error-message is below. Does someone see what is wrong there? The exceptions start, where the sequence of attributes starts.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Projekt1" xmlns:proj="urn:Projekt1">
    <xs:element name="projekte" type="proj:ProjekteForm"/>

    <xs:complexType name="ProjekteForm">
        <xs:sequence>
            <xs:element name="person" type="proj:ProjekteForms" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="ProjekteForms">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="link" type="xs:string"/>
            <xs:element name="zhaw" type="xs:string"/>
                <sequence>
                    <xs:attribute name="width" type="xs:integer"/>
                    <xs:attribute name="height" type="xs:integer"/>
                </sequence>
            <xs:element name="homepage" type="xs:string"/>
            <xs:element name="googlemapsx" type="xs:float"/>
            <xs:element name="googlemapsy" type="xs:float"/>
            <xs:element name="facebook" type="xs:string"/>
            <xs:element name="skype" type="xs:string"/>
            <xs:element name="twitter" type="xs:string"/>
        </xs:sequence>
        <xs:attribute name="id" type="xs:integer"/>
    </xs:complexType>
</xs:schema>

Which content is meant down here? On another place in the document, it works also like this.

Message:
Not valid. Error - Line 16, 52: org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 52; s4s-elt-must-match.1: The content of 'sequence' must match (annotation?, (element | group | choice | sequence | any)). A problem was found starting at: attribute. Error - Line 17, 53: org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 53; s4s-elt-must-match.1: The content of 'sequence' must match (annotation?, (element | group | choice | sequence | any)). A problem was found starting at: attribute.

EDIT: Maybe it's helpful if I upload also the xml. But the question ist just about the validity of the .xsd.

<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="Projekt1.xsl" xmlns:x="urn:Projekt1" exclude-result-prefixes="x"?>
<x:projekte xmlns:x="urn:Projekt1">
    <person id= "1">
        <name>Franz Mommar</name>
        <link>http://www.dfki.de/~wahlster/Portrait_Photos/</link>
        <zhaw width="100" height="100">Portrait_Wahlster_Photo_by_Jim_Rakete.jpg</zhaw>
        <homepage>http://www.werni.ch</homepage>
        <googlemapsx>285.2342</googlemapsx>
        <googlemapsy>234.3598</googlemapsy>
        <facebook>franzmoammar</facebook>
        <skype>franz.moammar</skype>
        <twitter>franzmoammar</twitter>
    </person>
    <person id= "2">
        <name>Rüdiger Mannheim</name>
        <link>http://www.dfki.de/~wahlster/Portrait_Photos/</link>
        <zhaw width="100" height="100">Wahlster_Anschnitt_gross.jpg</zhaw>
        <homepage>http://www.humor.li</homepage>
        <googlemapsx>45.2342</googlemapsx>
        <googlemapsy>32.3598</googlemapsy>
        <facebook>rüdigermann</facebook>
        <skype>ruedi</skype>
        <twitter>geronimo</twitter>
    </person>
</x:projekte>
Was it helpful?

Solution

As stated in the error message, a <sequence> element cannot contain any <attribute> elements. Also, looking at e.g. these docs, <sequence> shouldn't be directly nested in <element>.

Also, your <sequence> elements are lacking the xs namespace prefix.

As for a solution, replace <sequence> with <xs:complexType>, and you should be fine.

EDIT: Actually, I'm not sure where your attributes are supposed to go:

  • Are they supposed to be attributes of the type ProjekteForms? In that case, put them at the end of that complex type definition, together with your id attribute.
  • Or are they supposed to be attributes of your <zhaw> element? Your sample Xml suggest this, but in your XSD, your definition of <zhaw> does not enclose the sequence with the attributes, as you are using the single-tag-form of the element. Replace <xs:element name="zhaw" type="xs:string"/> with <xs:element name="zhaw">...</xs:element> (with the complex type with attributes inside). Note that you have to omit the type attribute as a type is already specified by the enclosed <xs:complexType> element. In order to allow text content, add the attribute mixed="true" to the <xs:complexType> element.

The latter solution would look like this:

<xs:element name="zhaw">
    <xs:complexType mixed="true">
        <xs:attribute name="width" type="xs:integer"/>
        <xs:attribute name="height" type="xs:integer"/>
    </xs:complexType>
</xs:element>

OTHER TIPS

You can't have a sequence of attributes in your XSD. zhaw might need to be defined as complexType with simpleContent as can be seen (example) in http://msdn.microsoft.com/de-de/library/ms256106.aspx

<xs:element name="zhaw">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="width" type="xs:integer"/>
        <xs:attribute name="height" type="xs:integer"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top