[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Universal Schema to Validate an Arbitrary Well-Formed Docu

  • To: "Peter Rodgers" <pjr@1...>,<xml-dev@l...>
  • Subject: RE: Universal Schema to Validate an Arbitrary Well-Formed Document
  • From: "Dare Obasanjo" <dareo@m...>
  • Date: Wed, 19 May 2004 08:25:49 -0700
  • Thread-index: AcQ9so0NKmokYO8nRh67a8wtnlYJ2gAAwOMy
  • Thread-topic: Universal Schema to Validate an Arbitrary Well-Formed Document

universal schema
It can't be done. You need to at least provide a name for the top level element. What you can do is specify that the content model of an element can be any content. 
 
-- 
PITHY WORDS OF WISDOM
There are always two solutions to the problem: yours and the boss's. 

________________________________

From: Peter Rodgers [mailto:pjr@1...]
Sent: Wed 5/19/2004 8:03 AM
To: xml-dev@l...
Subject:  Universal Schema to Validate an Arbitrary Well-Formed Document



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'"


-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://www.oasis-open.org/mlmanage/index.php>




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.