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

Re: Namespaces, W3C XML Schema (was Re: ANN: SAX FiltersforNamespaceProc

  • From: Peter Piatko <piatko@r...>
  • To: "Simon St.Laurent" <simonstl@s...>, Xml-Dev <xml-dev@l...>
  • Date: Wed, 01 Aug 2001 10:48:00 -0400

elementformdefault qualified
Here's another (still somewhat unrealistic) example:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:ex="http://www.example.org/"
            targetNamespace="http://www.example.org/"
            elementFormDefault="qualified">
    <xsd:element name="book">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="title" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="person">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="title">
                    <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:enumeration value="Mr."/>
                        <xsd:enumeration value="Ms."/>
                        <!-- and so on ... -->
                    </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="name" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Sample instance:

<ex:example xmlns:ex="http://www.example.org/">
    <ex:book>
        <ex:title>This is a book title</ex:title>
    </ex:book>
    <ex:person>
        <ex:title>Mr.</ex:title>
        <ex:name>Magoo</ex:name>
    </ex:person>
</ex:example>

Note that the "meaning" or definition of the <title> element depends on the
context.  *Not that I would advocate writing schemas this way.*  (Wouldn't
it be better to put <book> and <person> in separate namespaces?).  But
feature-laden XML Schema lets you do things like this and it seems
especially easy to do if you are feeling lazy.

I always thought that one of the intentions of
elementFormDefault="unqualified" was to mark context sensitive elements like
<title>.  This way, a recipient of the document at least knows there is
something special about them, even if he/she doesn't have the schema.

Thanks,

Peter Piatko

----- Original Message -----
From: "Simon St.Laurent" <simonstl@s...>
To: "Xml-Dev" <xml-dev@l...>
Sent: Wednesday, August 01, 2001 8:22 AM
Subject: RE: Namespaces, W3C XML Schema (was Re: ANN: SAX Filters
forNamespaceProcessing)


> On 31 Jul 2001 21:20:53 -0700, Aaron Skonnard wrote:
> > On the contrary, consider the following XML schema definition and sample
> > instance document:
> >
> > <!-- schema definition -->
> > <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
> >     xmlns:tns="http://example.org/foo"
> >     targetNamespace="http://example.org/foo"
> >     elementFormDefault="qualified">
> >   <s:element name="bar" type="s:string"/>
> >   <s:complexType name="fooType">
> >     <s:sequence>
> >       <s:element name="bar" type="s:string"/>
> >     </s:sequence>
> >   </s:complexType>
> >   <s:element name="foo" type="tns:fooType"/>
> > </s:schema>
> >
> > <!-- instance -->
> > <f:foo xmlns:f="http://example.org/foo">
> >   <f:bar/>   <--|
> > </f:foo>        |
> >                 |
> >                 |
> > Even when everything is qualified, you still can't figure out which bar
> > element this is just by looking at the QName and ignoring context (is it
> > the global or local qualified bar element?).
>
> This doesn't feel like the same problem to me - it feels like a bad case
> of non-deterministic content modeling.  I thought XML Schema went to
> great lengths to avoid that, but maybe this is legal.
>
> Can't say it feels like a remotely good idea to me.
>
>
>
>
> ------------------------------------------------------------------
> 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 unsubscribe from this elist send a message with the single word
> "unsubscribe" in the body to: xml-dev-request@l...
>
>


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.