You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Neil Graham <ne...@ca.ibm.com> on 2003/04/02 00:35:03 UTC

fix for the personal.xsd sample

Hi folks,

When the xml:base support was added to the parser, a means for testing that
support was found by integrating xml:base attributes into the
personal-schema.xml sample.  While this is good in itself (testing is
always good :) ), the trouble is that personal.xsd wasn't modified to
permit the presence of xml:base on elements.

Since the parser doesn't complain about this, it's not surprising that no
one seems to have noticed this previously.  The fact that the parser
*should* complain about this is illustrated by (for example) section 2.12
of the XML 1.0 2nd edition [1] where xml:lang (xml:base is discussed
elsewhere) is clearly required to be declared explicitly.  In XML schema,
the situation is also quite clear:  although namespace declarations may not
be declared in a schema (as discussed in section 3.2.1 [2]), the normative
schema for schemas explicitly imports a schema defining the xml:*
attributes, so that they may be used in the schema itself.  The
documentation of the relevant <import> states:  "Get access to the xml:
attribute groups for xml:lang as declared on 'schema' and 'documentation'
below".  So it seems there's no doubt that the parser's being more lax than
it should be.

I don't propose to fix that bug here, but I am attaching a patch for
personal.xsd that enables it to properly validate personal-schema.xml.  To
avoid people having to be connected to the network whenever they play with
this file, I've used the form of <xs:import/> that doesn't have a
schemaLocation hint (in other words, the form that simply declares that
components from that namespace will be expected in the schema); I've then
used attribute wildcards on the elements in personal-schema.xml that make
use of xml:base.

It's rather a nice bi-product of this, I think, that we now have an
<xs:annotation> in personal.xsd, as well as atttribute wildcards; so you
could argue there's good didactic reasons to put this fix down as well as
practical ones.  :)

Anyway, if someone wouldn't mind committing this, that would be wonderful.

Thanks!
Neil

[1]:  http://www.w3.org/TR/REC-xml#sec-lang-tag

[2]:  http://www.w3.org/TR/xmlschema-1/#Attribute_Declaration_details

Index: personal.xsd
===================================================================
RCS file: /home/cvs/xml-xerces/c/samples/data/personal.xsd,v
retrieving revision 1.4
diff -u -r1.4 personal.xsd
--- personal.xsd  6 Dec 2001 17:45:01 -0000     1.4
+++ personal.xsd  1 Apr 2003 22:27:59 -0000
@@ -1,6 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>

+ <xs:import namespace="http://www.w3.org/XML/1998/namespace">
+   <xs:annotation>
+     <xs:documentation>
+        The schemaLocation of the relevant file is
+        "http://www.w3.org/2001/xml.xsd"; however,
+        we don't want to assume people are always
+        connected to the 'net when playing with this file.
+     </xs:documentation>
+   </xs:annotation>
+ </xs:import>
+
  <xs:element name="personnel">
   <xs:complexType>
    <xs:sequence>
@@ -43,6 +54,7 @@
     </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="salary" type="xs:integer"/>
+   <xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace"
processContents="skip"/>
   </xs:complexType>
  </xs:element>

@@ -52,12 +64,29 @@
     <xs:element ref="family"/>
     <xs:element ref="given"/>
    </xs:all>
+   <xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="skip"/>
   </xs:complexType>
  </xs:element>

- <xs:element name="family" type='xs:string'/>
+ <xs:element name="family">
+   <xs:complexType>
+     <xs:simpleContent>
+       <xs:extension base='xs:string'>
+          <xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="skip"/>
+        </xs:extension>
+     </xs:simpleContent>
+   </xs:complexType>
+ </xs:element>

- <xs:element name="given" type='xs:string'/>
+ <xs:element name="given" >
+   <xs:complexType>
+     <xs:simpleContent>
+       <xs:extension base='xs:string'>
+          <xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="skip"/>
+        </xs:extension>
+     </xs:simpleContent>
+   </xs:complexType>
+ </xs:element>

  <xs:element name="email" type='xs:string'/>

Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  neilg@ca.ibm.com



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org