[Standards] XEP-0080: examples 1 and 2 don't pass validity check with XML Schema

Sergey Fedoseev fedoseev.sergey at gmail.com
Wed Feb 23 04:33:18 UTC 2011


2011/2/23 Matthijs van der Vleuten <zr40.nl at gmail.com>:
>> $ xmlstarlet val -s geoloc.xsd -e example1.xml
>> example1.xml:1: Element '{http://jabber.org/protocol/geoloc}geoloc',
>> attribute '{http://www.w3.org/XML/1998/namespace}lang': The attribute
>> '{http://www.w3.org/XML/1998/namespace}lang' is not allowed.
>
> XML itself defines the xml:lang attribute. Are you sure your validator is correct?
>

Yes, it defines it, so we need to import it.

--- geoloc.xsd
+++ geoloc.xsd
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://jabber.org/protocol/geoloc"
xmlns="http://jabber.org/protocol/geoloc"
elementFormDefault="qualified">
+<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/xml.xsd"/>

   <xs:annotation>
     <xs:documentation>
@@ -34,6 +35,7 @@
         <xs:element name="timestamp" minOccurs="0" type="xs:dateTime"/>
         <xs:element name="uri" minOccurs="0" type="xs:anyURI"/>
       </xs:sequence>
+      <xs:attribute ref="xml:lang"/>
     </xs:complexType>
   </xs:element>


>> example1.xml:6: Element '{http://jabber.org/protocol/geoloc}accuracy':
>> This element is not expected. Expected is one of
>> ( {http://jabber.org/protocol/geoloc}postalcode,
>> {http://jabber.org/protocol/geoloc}region,
>> {http://jabber.org/protocol/geoloc}room,
>> {http://jabber.org/protocol/geoloc}speed,
>> {http://jabber.org/protocol/geoloc}street,
>> {http://jabber.org/protocol/geoloc}text,
>> {http://jabber.org/protocol/geoloc}timestamp,
>> {http://jabber.org/protocol/geoloc}uri ).
>> example1.xml - invalid
>
> The XEP-0080 schema does define an accuracy element, although only since version 1.6. I suspect you're using the schema of version 1.5, since the speed element was added in that version.

The problem is that 'accuracy' element must be first with this schema,
because of using sequence.



More information about the Standards mailing list