Re: Tagging the remainder of a body

Hi Paul,

As you are no doubt aware, XSD alone isn't able to select different valid 
paths through an XML instance based on the value of an element body, or 
indeed that of an attribute.  The only forks in the road so to speak are 
with element names.

Looking at your examples, it would appear you can just get rid of the <type> 
element and have the <event> and <contact-information> be part of a choice 
in the schema.  Then you'd get something like:

 <message>
    <event>
       <stuff></stuff>
    </event>
 </message>

 <message>
    <contact-information>
       <address></address>
    </contact-information>
 </message>

Alternatively, if you really want a type element (as your e-mail suggests), 
you could do:

 <message>
    <type>
       <event>
          <stuff></stuff>
       </event>
    </type>
 </message>

 <message>
    <type>
       <contact-information>
          <address></address>
       </contact-information>
    </type>
 </message>

If neither of these are OK, then from what I've heard on this list, you'll 
need something like Schematron to impose the constraints (I'm afraid I 
haven't had the chance to get round to using it myself.)

HTH,

Pete.
----- Original Message ----- 
From: "Paul B. Monday" <Paul.Monday@Sun.COM>
To: <xmlschema-dev@w3.org>
Sent: Tuesday, February 14, 2006 4:12 AM
Subject: Tagging the remainder of a body


>
> I'm trying to leave a "type" tag in a body that determines the latter half 
> of an XML instance.  I can't find a decent way to do this but am thinking 
> I'm tackling the problem wrong from the outset.  Basically, I want to be 
> able to enforce that if a type is "Event", the latter half of the message 
> has an event but if the type is "Contact", the latter half of the message 
> has contact information...like this:
>
> <message>
>    <type>Event</type>
>    <event>
>       <stuff></stuff>
>    </event>
> </message>
>
> <message>
>    <type>Contact</type>
>    <contact-information>
>       <address></address>
>    </contact-information>
> </message>
>
>
> Am I approaching this wrong for XML?  Is there anyway to constrain the 
> following nodes like this?  selector, nor choice seem to allow this 
> linkage to occur...I'm not necessarily "new" to schema, but neither am I 
> "advanced" in schema...so apologies if this question seems naive...
>
> Paul Monday
> Sun Microsystems
>
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
                         for XML to C++ data binding visit
                         http://www.tech-know-ware.com/lmx
                         (or http://www.xml2cpp.com)
=============================================

Received on Tuesday, 14 February 2006 08:49:45 UTC