Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Referencing Variations

From: "Gavin Kistner" <gavin.kistner@-----.--->
To: <xmlschema-dev@--.--->
Date: 4/21/2006 6:21:00 AM
I have an XML file that looks something like this:

<root>
   <scene>
      <a foo="1" bar="yay" s="yum">
         <b jim="x" jam="1 2" s="yum"/>
         <a foo="1" bar="yay" s="yum">
            <a foo="1" bar="yay" s="yum"/>
            <b jim="x" jam="1 2" s="yum">
               <a foo="1" bar="yay" s="yum"/>
            </b>
         </a>
      </a>
   </scene>
   <library>
      <a foo="1" bar="yay" />
      <b jim="x" jam="1 2" />
   </library>
</root>

Everywhere the 'a' element shows up, it has the same set of common
attributes.
Everywhere the 'b' element shows up, it has the same set of common
attributes.

When 'a' or 'b' appear within the 'scene' element, they:
  * Have some extra attributes available
  * Are allowed to have a bunch of children, including themselves

How can I do this? I figure that I want to create global complexTypes
that get referenced by the elements in each scope, but then I'm at a
loss for how to reference those elements.

Following is my failed attempt at a schema for the above sample:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema
		xmlns:xs="http://www.w3.org/2001/XMLSchema"
		elementFormDefault="qualified">
  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>

        <xs:element name="scene">
          <xs:complexType>
            <xs:choice maxOccurs="unbounded">
              <xs:element name="a">
                <xs:complexType>
                  <xs:complexContent>
                    <xs:extension base="a">
                      <xs:choice maxOccurs="unbounded">
                        <!-- I want to recursively refer to
                             the definitions of 'a' and 'b'
                             within the 'scene' scope -->
                        <xs:element ref="a" />
                        <xs:element ref="b" />
                      </xs:choice>
                      <xs:attributeGroup ref="scene-attributes" />
                    </xs:extension>
                  </xs:complexContent>
                </xs:complexType>
              </xs:element>
              
              <xs:element name="b">
                <xs:complexType>
                  <xs:complexContent>
                    <xs:extension base="b">
                      <xs:choice maxOccurs="unbounded">
                        <!-- I want to recursively refer to
                             the definitions of 'a' and 'b'
                             within the 'scene' scope -->
                        <xs:element ref="a" />
                        <xs:element ref="b" />
                      </xs:choice>
                      <xs:attributeGroup ref="scene-attributes" />
                    </xs:extension>
                  </xs:complexContent>
                </xs:complexType>
              </xs:element>
            </xs:choice>
          </xs:complexType>
        </xs:element>

        <xs:element name="library">
          <xs:complexType>
            <xs:choice maxOccurs="unbounded">
              <xs:element name="a">
                <xs:complexType>
                  <xs:complexContent>
                    <xs:extension base="a" />
                  </xs:complexContent>
                </xs:complexType>
              </xs:element>
            </xs:choice>
          </xs:complexType>
        </xs:element>

      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="a">
    <xs:attribute name="foo" use="required" type="xs:integer" />
    <xs:attribute name="bar" use="required" type="xs:string" />
  </xs:complexType>

  <xs:complexType name="b">
    <xs:attribute name="jim" use="required" type="xs:string" />
    <xs:attribute name="jam" use="required" type="xs:integer" />
  </xs:complexType>

  <xs:attributeGroup name="scene-attributes">
    <xs:attribute name="s" type="xs:string" fixed="yum" />
  </xs:attributeGroup>

</xs:schema>

From noah_mendelsohn@u... Mon Apr 24 16:06:02 2006
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org with esmtp (Exim 4.50)
	id


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent