You are on page 1of 8

XML Schema Project due date TBA You are to build a schema which will be used for many

y applications in the e!istrar"s #ffice$ This is a fairly complicated schema% so & su!!est hat you do it in sta!es 'identified by the blan( lines$) #ptional parts be!in with *&f you feel !ood+, After a lot of discussion the e!istrar has the followin! information for you.$ A course is identified by a department prefi/ '0 or 1 letter code such as 23S") and a course number$ These are reasonably stable$ 4o course is assi!ned a number until it has been appro5ed by the curriculum committee for the school which offers it$ 0$ 6ach course also has a title% up to 78 characters lon!$ These are less stable% and% althou!h they appear on schedules and transcripts% they are not the identifiers for the course$ 1$ 6ach course is offered for a certain number of credits% with 7 the default 5alue$ 7$ The e!istrar refers to an actual offerin! of a course in a particular semester as a 2course offerin!"$ That is% a course offerin! is a particular course and section number offered in a particular semester$ &n that case% an instructor is also assi!ned to the course offerin! 'defaultin! to TBA)$ 9$ &f you feel !ood you may add a Boolean attribute consent% defaultin! to no$ :$ A student has a name and a student &; number 'and lots of other information which we will i!nore$) <$ A student also has an &; 6= to her transcript$ >$ &f you feel !ood you may add a field for email address$ ?$ A transcript has an &; 6= to a student % a !pa decimal% a list of 8@1 majors% and a list of up to .: semester records$ You may simplify your life by ma(in! the majors be same as the department prefi/es$ .8$ A semester record has a list of 8@: enrollment records$ ..$ An enrollment record tabulates the information for each course a student has enrolled in @@@ the course number etc% the !radin! option% and 'for courses in pre5ious semesters) the !rade recei5ed$

.0$ A class list has the course offerin! info and also the same% id and !radin! option for each student in the course$

Aere are a few models for you to consider6/ample .- ;efinin! a simple type by restrictin! to a ran!e of 5alues<simpleType name='one-hundred-or-more'> <restriction base='integer'> <minInclusive value='100'/> </restriction> </simpleType> The attributes (each in a separate < > are minInclusive! ma"Inclusive! min#"clusive and ma"#"clusive

6/ample 0- ;efinin! a simple strin! type by restrictin! its len!th<simpleType name='$orm-input'> <restriction base='string'> <ma"%ength value='&0'/> </restriction> </simpleType>

6/ample 1- ;efinin! a comple/ type with se5eral elements<"s'comple"Type name=()urchase*rderType(> <"s'se+uence> <"s'element name=(shipTo( type=(,-.ddress(/> <"s'element name=(billTo( type=(,-.ddress(/> <"s'element re$=(comment( min*ccurs=(0(/> <"s'element name=(items( type=(Items(/> </"s'se+uence> <"s'attribute name=(order/ate( type=("s'date(/> </"s'comple"Type>

6/ample 7- ;efinin! a comple/ type with an attribute<"s'comple"Type> <"s'attribute re$=("ml'lang( use=(re+uired(/> <"s'attribute re$=("ml'space( de$ault=(preserve(/> <"s'attribute name=(version( type=("s'number( $i"ed=(1 0(/> </"s'comple"Type>

XML representations which all in5ol5e attribute uses% illustratin! some of the possibilities for controllin! occurrence$ That is to say- after the child elements ha5e been defined% you define one or more attributes% each in its own ta!$ An attribute is defined either of the forms below 'the use clause is optional)B/s-attribute nameC,appro5ed, typeC,/s-boolean, useC,reDuired,E B/s-attribute refC,appo5ed, useC,reDuired,E 4#T6- &f the element is a comple/ type then you MFST use the B/s-attribute+E form that is you may 4#T put the attribute in the element ta!$

6/ample 9- ;efinin! a comple/ type with an attribute !roup<"s'attribute0roup name=(my.ttr0roup(> <"s'attribute /> </"s'attribute0roup> <"s'comple"Type name=(myelement(> <"s'attribute0roup re$=(my.ttr0roup(/> </"s'comple"Type>

Aere are some other e/amples 'from w1$or!)The followin! is the definition of a Guser@deri5edG datatype which limits 5alues to inte!ers less than or eDual to .88% usin! Gma/&nclusi5eG$
<simpleType name='one-hundred-or-less'> <restriction base='integer'> <ma"Inclusive value='100'/> </restriction> </simpleType>

The followin! is the definition of a Guser@deri5edG datatype which limits 5alues to inte!ers less than or eDual to .88% usin! Gma/6/clusi5eG$
<simpleType name='less-than-one-hundred-and-one'> <restriction base='integer'> <ma"#"clusive value='101'/> </restriction> </simpleType>

The followin! is the definition of a Guser@deri5edG datatype which limits 5alues to inte!ers !reater than or eDual to .88% usin! Gmin6/clusi5eG$
<simpleType name='more-than-ninety-nine'> <restriction base='integer'> <min#"clusive value='11'/> </restriction> </simpleType>

The followin! is the definition of a Guser@deri5edG datatype which limits 5alues to inte!ers !reater than or eDual to .88% usin! Gmin&nclusi5eG$
<simpleType name='one-hundred-or-more'> <restriction base='integer'> <minInclusive value='100'/> </restriction> </simpleType>

The followin! is the definition of a Guser@deri5edG datatype which could be used to represent the ma!nitude of a personHs body temperature on the 3elsius scale$ This

definition would appear in a schema authored by an Iend@userI and shows how to define a datatype by specifyin! facet 5alues which constrain the ran!e of the Gbase typeG$
<simpleType name='celsius2odyTemp'> <restriction base='decimal'> <total/igits value='3'/> <$raction/igits value='1'/> <minInclusive value='45 3'/> <ma"Inclusive value='30 &'/> </restriction> </simpleType>

An electronic commerce schema mi!ht define a datatype called Sku 'the barcode number that appears on products) from the Gbuilt@inG datatype strin! by supplyin! a 5alue for the GpatternG facet$
<simpleType name='-6u'> <restriction base='string'> <pattern value='7d849-:.-;<8=9'/> </restriction> </simpleType>

&n this case% Sku is the name of the new Guser@deri5edG datatype% strin! is its Gbase typeG and GpatternG is the facet$ A system mi!ht want to store lists of floatin! point 5alues$
<simpleType name='list*$>loat'> <list itemType='$loat'/> </simpleType>

&n this case% listOfFloat is the name of the new Guser@deri5edG datatype% float is its GitemTypeG and GlistG is the deri5ation method$ The followin! is the definition of a Guser@deri5edG datatype which mi!ht be used to accept form input with an upper limit to the number of characters that are acceptable$
<simpleType name='$orm-input'> <restriction base='string'> <ma"%ength value='&0'/> </restriction> </simpleType>

?e may also put several things together to $orm a comple" type'


<"s'comple"Type name=()urchase*rderType(> <"s'se+uence> <"s'element name=(shipTo( type=(,-.ddress(/> <"s'element name=(billTo( type=(,-.ddress(/> <"s'element re$=(comment( min*ccurs=(0(/> <"s'element name=(items( type=(Items(/> </"s'se+uence> <"s'attribute name=(order/ate( type=("s'date(/> </"s'comple"Type>

The XML representation of a comple/ type definition$

$6/ample =ore5er ff 'from 3ostello tutorial) BJ/ml 5ersionCI.$8IJE B/sd-schema /mlns-/sdCIhttp-KKwww$w1$or!K088.KXMLSchemaI tar!et4amespaceCIhttp-KKwww$boo(s$or!I /mlnsCIhttp-KKwww$boo(s$or!I element=orm;efaultCIDualifiedIE B/sd-element nameCIBoo(StoreIE B/sd-comple/TypeE B/sd-seDuenceE B/sd-element refCIBoo(I min#ccursCI.I ma/#ccursCIunboundedIKE BK/sd-seDuenceE BK/sd-comple/TypeE BK/sd-elementE B/sd-element nameCIBoo(IE B/sd-comple/TypeE B/sd-seDuenceE B/sd-element refCITitleI min#ccursCI.I ma/#ccursCI.IKE B/sd-element refCIAuthorI min#ccursCI.I ma/#ccursCI.IKE B/sd-element refCI;ateI min#ccursCI.I ma/#ccursCI.IKE B/sd-element refCI&SB4I min#ccursCI.I ma/#ccursCI.IKE B/sd-element refCIPublisherI min#ccursCI.I ma/#ccursCI.IKE BK/sd-seDuenceE BK/sd-comple/TypeE BK/sd-elementE B/sd-element nameCITitleI typeCI/sd-strin!IKE B/sd-element nameCIAuthorI typeCI/sd-strin!IKE B/sd-element nameCI;ateI typeCI/sd-strin!IKE B/sd-element nameCI&SB4I typeCI/sd-strin!IKE B/sd-element nameCIPublisherI typeCI/sd-strin!IKE BK/sd-schemaE or if you in@line the child elementsBJ/ml 5ersionCI.$8IJE B/sd-schema /mlns-/sdCIhttp-KKwww$w1$or!K088.KXMLSchemaI tar!et4amespaceCIhttp-KKwww$boo(s$or!I /mlnsCIhttp-KKwww$boo(s$or!I element=orm;efaultCIDualifiedIE B/sd-element nameCIBoo(StoreIE B/sd-comple/TypeE B/sd-seDuenceE

B/sd-element nameCIBoo(I ma/#ccursCIunboundedIE B/sd-comple/TypeE B/sd-seDuenceE B/sd-element nameCITitleI typeCI/sd-strin!IKE B/sd-element nameCIAuthorI typeCI/sd-strin!IKE B/sd-element nameCI;ateI typeCI/sd-strin!IKE B/sd-element nameCI&SB4I typeCI/sd-strin!IKE B/sd-element nameCIPublisherI typeCI/sd-strin!IKE BK/sd-seDuenceE BK/sd-comple/TypeE BK/sd-elementE BK/sd-seDuenceE BK/sd-comple/TypeE BK/sd-elementE BK/sd-schemaE 6/ample- ;efinin! an element by restriction to a certain pattern 'with re!ular e/pressions)% &n this case there are 1 possible patterns allowed for &SB4 numbers% each of which is specified in one B/sd-pattern+E ta!$ BJ/ml 5ersionCI.$8IJE B/sd-schema /mlns-/sdCIhttp-KKwww$w1$or!K088.KXMLSchemaI tar!et4amespaceCIhttp-KKwww$boo(s$or!I /mlnsCIhttp-KKwww$boo(s$or!I element=orm;efaultCIDualifiedIE <xsd:simpleType name="ISBNType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\d !"#\d $"#\d %"#\d !""&> <xsd:pattern value="\d !"#\d %"#\d $"#\d !""&> <xsd:pattern value="\d !"#\d '"#\d ("#\d !""&> <&xsd:restriction> <&xsd:simpleType> B/sd-element nameCIBoo(StoreIE B/sd-comple/TypeE B/sd-seDuenceE B/sd-element nameCIBoo(I ma/#ccursCIunboundedIE B/sd-comple/TypeE B/sd-seDuenceE B/sd-element nameCITitleI typeCI/sd-strin!IKE B/sd-element nameCIAuthorI typeCI/sd-strin!IKE B/sd-element nameCI)ateI typeCIxsd:g*earIKE B/sd-element nameCIISBNI typeCIISBNTypeIKE B/sd-element nameCIPublisherI typeCI/sd-strin!IKE BK/sd-seDuenceE

BK/sd-comple/TypeE BK/sd-elementE BK/sd-seDuenceE BK/sd-comple/TypeE BK/sd-elementE BK/sd-schemaE 6/ample of definin! a new type with a pattern 'phone number) B/sd-simpleType nameCITelephone4umberIE B/sd-restriction baseCI/sd-strin!IE B/sd-len!th 5alueCI>IKE B/sd-pattern 5alueCILdM1N@LdM7NIKE BK/sd-restrictionE BK/sd-simpleTypeE 3omment- This creates a new datatype called HTelephone4umberH$ 6lements of this type can hold strin! 5alues% but the strin! len!th must be e/actly > characters lon! and the strin! must follow the pattern- ddd@dddd% where HdH represents a Hdi!itH$ '#b5iously% in this e/ample the re!ular e/pression ma(es the len!th facet redundant$) o!er 3ostello summariOes this with+eneral ,orm o- .reating a Ne/ )atatype by Speci-ying ,acet 0alues B/sd-simpleType nameC InameIE B/sd-restriction baseC I/sd-sourceIE B/sd-facet 5alueC IvalueIKE B/sd-facet 5alueC IvalueIKE + BK/sd-restrictionE BK/sd-simpleTypeE =acets@ len!th @ minlen!th @ ma/len!th @ pattern @ enumeration @ min&nclusi5e @ ma/&nclusi5e @ min6/clusi5e @ ma/6/clusi5e $$$

Sources@ strin! @ boolean @ number @ float @ double @ duration @ dateTime @ time $$$ Please see 3ostello"s slides :8@:? and .0: and .1<@.7. for more information and e/amples$ Please see 3ostello"s slides <8@: about where you may put annotations 'documentation$) 3ostello"s slides ?9@.80 show you how to define new types from old comple/ types% either by restrictin! some 5alues or '1ere come in1eritancePPP) by addin! new elements$ Please read slides .87@.8< on declare 5s$ define and on !lobal 5s$ local typesKelements

You might also like