OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Universal Schema to Validate an Arbitrary Well-Formed Document

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: Universal Schema to Validate an Arbitrary Well-Formed Document
  • From: Peter Rodgers <pjr@1060.org>
  • Date: Wed, 19 May 2004 16:03:34 +0100

Any assistance to the following problem gratefully received.

Problem:

I require an XML Schema (XSD) which will validate an arbitrary
well-formed document as valid. You might call this the universal schema.

Why:

WSDL v1.1 is closely coupled to XML Schema - I want to provide a WSDL
service definition (and hence XSD) which allows that an arbitrary
document may be received for a given service/port.  There are good
reasons why we want to do this.

RNG Solution:

I've formulated a relatively simple solution to the problem in RelaxNG
(provided below).

I've looked around and found no documented solution for XML Schema - is
this me being stupid? Does this problem have a solution in XML Schema?

It seems straightforward to permit an arbitrary document structure below
a specified root element but what I want is an arbitrary root element.

Thanks in advance

Peter Rodgers
1060 NetKernel  http://www.1060.org

The test document used is:

<test/>

Freeform RelaxNG
----------------

<?xml version="1.0" encoding="UTF-8"?>
<grammar  xmlns="http://relaxng.org/ns/structure/1.0";>
    <start>
        <ref name="non-null-freeform"/>    
     </start>

    <define name="non-null-freeform">
        <choice>
            <element>
                <anyName/>
                <zeroOrMore>
                    <attribute>
                        <anyName/>
                    </attribute>
                </zeroOrMore>
                <ref name="freeform"/>
            </element>
        </choice>
    </define>

    <define name="freeform">
        <zeroOrMore>
        <choice>
            <text/>
            <element>
                <anyName/>
                <zeroOrMore>
                    <attribute>
                        <anyName/>
                    </attribute>
                </zeroOrMore>
                <ref name="freeform"/>
            </element>
        </choice>
        </zeroOrMore>
    </define>    
</grammar>

Result: Valid

Trang Conversion to XSD
-----------------------

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified">
  <xs:group name="non-null-freeform">
    <xs:sequence>
      <xs:any processContents="skip"/>
    </xs:sequence>
  </xs:group>
  <xs:group name="freeform">
    <xs:sequence>
      <xs:any minOccurs="0" maxOccurs="unbounded"
processContents="skip"/>
    </xs:sequence>
  </xs:group>
</xs:schema>

Result: Fails to validate  "Cannot find the declaration of element
'test'"





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS