Loading ...
Sorry, an error occurred while loading the content.

validation issue for extensible schema - XMLSpy issue ?

Expand Messages
  • Laurent Le Meur
    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
    Message 1 of 1 , Feb 14 4:22 AM
    • 0 Attachment
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.