xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dane Foster" <dfos...@equitytg.com>
Subject Re: Schema Question
Date Thu, 09 Nov 2000 00:43:24 GMT
I don't see it.  The restriction that I'm trying to apply is based upon the value of the parent
type's attribute, not it's element type.  I sent out another email with additional samples
of what I'm trying to accomplish but I'll do it here again.

The following scenario is an invalid constructs:

<!--Scenario Three -->
<myElement TYPE="type1">
    <type-2-element>This is an incorrect construct because the value of the 'TYPE' attribute
of 'myElement' is "type1", therefore the children of 'myElement' should be 'type-1-element's,
not 'type-2-element's</type-2-element>
  ----- Original Message ----- 
  From: Eric Ye 
  To: general@xml.apache.org 
  Cc: xerces-j-dev@xml.apache.org ; dfoster@equitytg.com 
  Sent: Wednesday, November 08, 2000 6:28 PM
  Subject: Re: Schema Question

  Good question to demonstrate powerfulness of schema:

  With 04/07 schema spec, here is the syntax:

  in your schema :
  <schema ....xmlns:NS="your targetNamespace" targetNamespace ="your targetNamesapce">
      <complexType name="type1">
          <element name="type-1-element"/>

      <complexType name="type2" base="NS:type1" derivedBy="restriction">
          <element name="type-2-element"/>    

      <element name="myelement" type="NS:type1"/>

  in your instance XML document use xsi:type attribute: 

  by default myelement will have "type1"'s content model ,  if you do this:
  <NS:myelement xmlns:xsi="...." xsi:type="type2"......

  then myelement will have "type2"'s content model.

  With the CR(10/24) version, the syntax is a little bit different for the schema part, here
it is:

      <complexType name="type1">
             <element name="type-1-element"/>

      <complexType name="type2" >
         <complexContent >
            <restriction base="type1>
                <element name="type-2-element"/>    

  See, it is much more cumbersome than the 04/07 version, we should let the W3C working Group
know that schema syntax is getting more and more diverted from simplicity and flexibility.

  Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

    ----- Original Message ----- 
    From: Dane Foster 
    To: general@xml.apache.org 
    Sent: Wednesday, November 08, 2000 10:11 AM
    Subject: Schema Question

    I know that most of the post to this list deal with Xerces and Xalan so this may not be
the place to ask this question.  If it's not please let me know.  Anyway, my question is this,
in the current Schema specification (..2000/10/XMLSchema), how do I specify that if an element
contains a particular attribute it's children must be a specific element?


    Notes*: The myElement node's 'type' attribute can be one of two values "type1" or "type2".
 If the value is type1 then the root node(s) of the myElement sub-tree must be 'type-1-element'.
 If the value is type2 then the root node(s) of the myElement sub-tree must be 'type-2-element'.

    <!--Scenario one-->
    <myElement type="type1">
      <type-1-element>Element data goes here</type-1-element>

    <!--Scenario two-->
    <myElement type="type2">
      <type-2-element>Element data goes here</type-2-element>

    Dane Foster

View raw message