- From: Laurent Le Meur <laurent.lemeur@afp.com>
- Date: Fri, 14 Feb 2003 13:22:45 +0100
- To: <xmlschema-dev@w3.org>, "newsml" <newsml@yahoogroups.com>
Hi, I'm looking for a way to create an extensible schema, that can act as a container for any structure, but with the capability to validate xml instances against the container schema AND the payload schema. My parser is XMLSpy5 rel3, and I reach bizarre conclusions. the container schema : a.xsd ----------------------------- A simple test schema : a can contain anything ; unqualified elements. Use the <any> element with processContents="strict", the only option that provoques validation of the inner structure with XMLSpy. <xsd:schema xmlns="urn:newsml:iptc.org:a" targetNamespace="urn:newsml:iptc.org:a" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0"> <xsd:element name="a"> <xsd:complexType> <xsd:complexContent> <xsd:restriction base="xsd:anyType"> <xsd:sequence> <xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:restriction> </xsd:complexContent> </xsd:complexType> </xsd:element> </xsd:schema> the payload schema : b.xsd --------------------------- A simple test schema : b can contain bb* (string) ; unqualified elements <xsd:schema targetNamespace="urn:newsml:iptc.org:b" xmlns="urn:newsml:iptc.org:b" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0"> <xsd:element name="b"> <xsd:complexType> <xsd:sequence> <xsd:element ref="bb" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="bb" type="xsd:string"/> </xsd:schema> first tests ------------- Instance1 is valid (fine): <a xmlns="urn:newsml:iptc.org:a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:newsml:iptc.org:a a.xsd urn:newsml:iptc.org:b b.xsd "> <b xmlns="urn:newsml:iptc.org:b" ><bb>ffff</bb></b> </a> Instance2, with a 'c' element, is invalid (so far so good ; at least I've got what I wanted): <a xmlns="urn:newsml:iptc.org:a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:newsml:iptc.org:a a.xsd urn:newsml:iptc.org:b b.xsd "> <b xmlns="urn:newsml:iptc.org:b" ><bb>ffff</bb><c/></b> </a> Now the issues --------------- Instance3 is invalid (I just reversed 'a' and 'b' schemaLocation information ; ????): <a xmlns="urn:newsml:iptc.org:a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:newsml:iptc.org:b b.xsd urn:newsml:iptc.org:a a.xsd"> <b xmlns="urn:newsml:iptc.org:b" ><bb>ffff</bb><c/></b> </a> Instance4 is valid (I entered a false URL for the 'b' namespace, the validator should say no!; same result if I suppress the 'b' information in schemaLocation ; ????): <a xmlns="urn:newsml:iptc.org:a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:newsml:iptc.org:a a.xsd urn:newsml:iptc.org:b c.xsd "> <b xmlns="urn:newsml:iptc.org:b" ><bb>ffff</bb><c/></b> </a> I tend to believe that XMLSpy uses the 'strict' processContents option in 'a' as a 'lax' option, and the 'lax' option as a 'skip' option. Does anybody has seen such problems in "real life", with other validating parser ? Laurent Le Meur Agence France Presse Member of IPTC (www.iptc.org) - creators of NewsML: the XML news wrapper
Received on Friday, 14 February 2003 08:31:23 UTC