#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    20
    Rep Power
    0

    multiple attributes in a simple type within agroup


    Hi I'm having problems validating my schema and xsd files I think there maybe a problem placing multiple attributes in a simple type within a group below is my code

    xsd:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <!--definition of an element group -->
    <xsd:group name="computerFeatures">
    <xsd:sequence>
    <!--definition of simple type elements -->
    <xsd:element name="cpu" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="memory" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="hd" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="drive" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="video" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="modem" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    </xsd:sequence>
    </xsd:group>

    <xsd:group name="computerOptions">
    <xsd:sequence>
    <!--definition of simple type elements -->
    <xsd:element name="airport" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:attribute ref="picture">
    <xsd:attribute ref="price">
    </xsd:element>

    <xsd:element name="ipod" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:complexType>
    <xsd:attribute ref="picture">
    <xsd:attribute ref="price">
    </xsd:complexType>
    </xsd:element>

    <xsd:element name="app" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:complexType>
    <xsd:attribute ref="picture">
    <xsd:attribute ref="price">
    </xsd:complexType>
    </xsd:element>

    </xsd:sequence>
    </xsd:group>

    <!--definition of attributes-->
    <xsd:attribute name="storeName" type="xsd:string"/>
    <xsd:attribute name="picture" type="xsd:string"/>
    <xsd:attribute name="price" type="xsd:float"/>
    <xsd:attribute name="tax" type="xsd:float"/>
    <xsd:attribute name="shipping" type="xsd:float"/>

    <!--definition of complex type elements -->
    <xsd:element name="model">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:group ref="computerFeatures" minOccurs="1" maxOccurs="1"/>
    <xsd:group ref="computerOptions" minOccurs="1" maxOccurs="1"/>
    </xsd:sequence>
    <xsd:attribute name="picture" type="xsd:string"/>
    <xsd:attribute name="price" type="xsd:float"/>
    <xsd:attribute name="tax" type="xsd:float"/>
    <xsd:attribute name="shipping" type="xsd:float"/>
    </xsd:complexType>
    </xsd:element>

    <xsd:element name="computerStore">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="model" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="storeName" type="xsd:string"/>
    <xsd:attribute ref="picture"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>

    xml file:

    <?xml version="1.0" encoding="UTF-8"?>

    <computerStore storeName="Mac Store">
    <model picture="imac.jpg" price="799" tax="0.14" shipping="20" >
    <cpu>600MHz PowerPC G3</cpu>
    <memory>128MB SDRAM</memory>
    <hd>40GB Ultra ATA drive</hd>
    <drive>CD-ROM</drive>
    <video>Rage 128 Ultra graphics</video>
    <modem>56K internal modem</modem>
    <options>
    <airport picture="airport.gif">AirPort</airport>
    <ipod picture="ipod.gif">iPod</ipod>
    <app picture="app.gif">Apple Protection Plan</app>
    </options>
    </model>
    </computerStore>

    I been validating the two files at http://www.xmlforasp.net/content.asp...chemaValidator

    Can anyone tell me whats wrong with my xsd

    Thanx
    getchoo
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Double check your closing tags. You've got some <xsd:element> tags that close with />, that later have a closing tag </...>

IMN logo majestic logo threadwatch logo seochat tools logo