xml complex types

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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>
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

Top