1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

xml complex types

Discussion in 'Software Development' started by tovachanah, Jan 23, 2007.

Thread Status:
Not open for further replies.
  1. tovachanah

    tovachanah Thread Starter

    Joined:
    Feb 15, 2006
    Messages:
    48
    can a complex type be w/i a complex type or is that forbidden

    current schema
    <?xml version = "1.0" encodeing = "UTF-8"?>
    <!-- Homework 1 for CIS 2858 -->
    <!-- Leslee Herschfus -->
    <!-- [email protected] -->

    <xsd:schema xmlns:xsd = "http:/ /www.w3.org/2001/XMLSchema">

    <xsd:annotation>
    <xsd:documentation xml: lang = "en">
    food element definition for homework 1
    each food product has a unique id consisting of
    a lower case letter and a 2 digit integer. the element
    consists of a name, quantity and price.
    if the item is perishable, the food element has a nutritional
    description (amt of protein, fats, and calcium)
    if the item is non-perishable, the stock element contains
    the warehouse(s) id and name, and amt of stock available
    <xsd:documentation>
    <xsd:annotation>

    <product xmins= "x-schema: homework 1-schema.xml>
    <xsd:element name="product" type = "prdcttype/>

    <xsd:complextype name=prdcttype>
    <xsd:sequence>
    <xsd:atribute name = "productid" use="required" >
    <xsd:restriction base = "xsd:string">
    <xsd:pattern value= [a-z](1)\d(2)"/>
    <xsd:restriction>
    <xsd:attribute name = "perishable" use="required" >
    <xsd:restriction base = "xsd:string">
    <xsd:enumeration value= "yes"
    <xsd:enumeration value= "no"
    <xsd:restriction>


    <xsd:element name = "name" use="required" type = "string" maxOccurs=1/>

    <xsd:element name = "manufacturer" use="required" type = "string" maxOccurs=1/>

    <xsd:element name = "quantity" use="required" type = "nonNegativeInteger" maxOccurs=1/>

    <xsd:element name = "price" use="required" type= decimal maxOccurs=1>


    <xsd:element name = "food" use=optional>
    <xsd:complextype>
    <xsd:sequence>
    <xsd:element ref = "nutrition"/>
    <xsd:complextype>
    <xsd:sequence>
    <xsd:element name = "calcium" use="required" type= nonNegativeInterger maxOccurs=1>
    <xsd:element name = "protein" use="required" type= decimal maxOccurs=1>
    <xsd:element name = "fat" use="required" type= decimal maxOccurs=1>
    <xsd:sequence>
    <xsd:complextype>
    <xsd:element ref = "expiration date" use=required type=date maxOccurs=1/>

    <xsd:element name = "stock" use=optional maxOccurs=1>
    <xsd:complextype>
    <xsd:sequence>
    <xsd:element name = "warehouse" use=optional minOccurs=1>
    <xsd:complextype>
    <xsd:sequence>
    <xsd:element name = "stockamt" use="required" type=nonNegativeInteger maxOccurs=1>
    <xsd:sequence>
    <xsd:attribute name = "id" use="required" type= string minOccurs=1>
    <xsd:complextype>
    <xsd:sequence>
    <xsd:complextype>


    xml
    ?xml version = "1.0?>
    <products xmlns = "x-schema:homework1-schema.xml">
    <product id = "p12" perishable = "yes">
    <name>Ice Cream</name>
    <manufacturer>XSZ Co.</manufacturer>
    <quantity>25</quantity>
    <price>2</price>
    <food>
    <nutrition>
    <calcium>10.30</<calcium>
    <proteins>35.5</proteins>
    <fat>10</fat>
    </nutrition>
    <expirationdate>2007-09-12</expireationdate>
    </food>
    <product>
    <product id = "p13" perishable = "no">
    <name>AA Batteries</name>
    <manufacturer>DCells</manufacturer>
    <quantity>100</quantity>
    <price>4</price>
    <stock>
    <warehouse id = "w12">
    XSZ Warehouse
    <stockamt>25000</stockamt>
    </warehouse>
    <warehouse id = "w13">
    RZA Warehouse
    <stockamt>5000</stockamt>
    </warehouse>
    </stock>
    <product>
    </products>
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/537826

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice