Your SlideShare is downloading. ×
0
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Schemas 2 - Restricting Values
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Schemas 2 - Restricting Values

373

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
373
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. CIS-189 XML
  • 2.  Qualification refers to whether a value (element, attribute) must be qualified by a its namespace ◦ When an element (or attribute) doesn’t have a namespace declaration it’s unqualified ◦ Determines how name is used in data (instance) document A schema has the attributes elementFormDefault and attributeFormDefault ◦ Set to qualified or unqualified ◦ By setting to qualified, must include a namespace when use attributes or elements
  • 3. <schema attiributeFormDefault=“unqualified”elementFormDefault=“unqualified”> Element and attributes can be specified individually as qualified (or not) <element form=“unqualified”> <attribute form=“qualified”>
  • 4.  Have several different ways to specify how elements fit together Sequence: specifies that elements must be in order, and there’s variability in when and how many times a child element occurs All: elements may appear (or not), and in any order Choice: one of several child elements may appear Group: a set of elements may be referenced by name
  • 5.  Allows elements to appear in any order or not at all Rules governing use 1. Must be only content model declaration of a <complexType> definition  For example, can’t follow with <sequence> 2. Can only have element declarations as children 3. The children of the <all> element may appear once – or not at all
  • 6. <element name=“name”> <complexType> <all> <element name=“first” type=“xs:string” /> <element name=“middle” type=“xs:string” /> <element name=“last” type=“xs:string” /> </all> </complextType></element>
  • 7.  Similar in syntax to sequence Only one member of list can appear in the document Allow a middle initial or a middle name<choice> <element name=“middleInitial” type=“xs:string” /> <element name=“middleName type=“xs:string” /></choice>Note: Best case would restrict Middle Initial to onecharacter with a simple type.
  • 8.  A group allows you to tie elements together, and then reference then with a single nameDefinition:<group name=“nameFields”> <element name=“first” type=“xs:string” /> <element name=“middle” type=“xs:string” /> <element name=“last” type=“xs:string” /></group>Use:<element name=“name”> <complexType> <group ref=“nameFields” /> </complexType></element>
  • 9.  Can create a group of attributes similar to element groups Allows re-use of common members without multiple definitions ◦ Attribute groups cannot be recursive (refer to themselves
  • 10.  Create limits on acceptable values as a simple type A facet is a single property or trait of a simple type Twelve facets can be applied to limit acceptable values
  • 11.  minExclusive: smallest value, excluding what’s specified minInclusive: smallest value, including what’s specified maxExclusive: largest value, excluding what’s specified maxInclusive: largest value, including what’s specified totalDigits: total number of digits of a numeric type
  • 12.  fractionDigits: number of decimal places length: number of items in a list or characters in a string minLength: minimum number of list items or characters maxLength: maximum number of list items or characters enumeration: specify member of a list whitespace: how whitespace should be treated pattern: restrict string types by pattern
  • 13. Specifying a positive integer<xs:simpleType name="creditHours"> <xs:restriction base="xs:integer"> <xs:minInclusive value="0" /> </xs:restriction></xs:simpleType>
  • 14. Specifying a list:<xs:simpleType name="cisDepartments"> <xs:restriction base="xs:string"> <xs:enumeration value="CIS" /> <xs:enumeration value="CNA" /> <xs:enumeration value="CS" /> </xs:restriction></xs:simpleType>
  • 15.  Specify a 3 digit value<xs:simpleType name="courseNumbering"> <xs:restriction base="xs:string"> <xs:pattern value="b[0-9]{3}b" /> </xs:restriction></xs:simpleType>
  • 16. <?xml version="1.0" encoding="utf-8"?><xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:mstns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema”> <xs:element name="course"> <xs:complexType> <xs:sequence> <xs:element name="department" type="cisDepartments" /> <xs:element name="number" type="courseNumbering" /> <xs:element name="title" type="xs:string" /> <xs:element name="credits" type="creditHours" /> </xs:sequence> </xs:complexType> </xs:element>
  • 17. <xs:simpleType name="creditHours"> <xs:restriction base="xs:integer"> <xs:minInclusive value="0" /> </xs:restriction></xs:simpleType><xs:simpleType name="cisDepartments"> <xs:restriction base="xs:string"> <xs:enumeration value="CIS" /> <xs:enumeration value="CNA" /> <xs:enumeration value="CS" /> </xs:restriction></xs:simpleType><xs:simpleType name="courseNumbering"> <xs:restriction base="xs:string"> <xs:pattern value="b[0-9]{3}b" /> </xs:restriction></xs:simpleType></xs:schema>
  • 18.  A list allows an element or attribute to store multiple values ◦ Uses enumerated values ◦ Values are separated by whitespace, so whitespace cannot be part of the content ◦ Can be built-in XML or a defined simpleType data type
  • 19. Define<simpleType name=“Degrees”> different <restriction base=“string”> values <enumeration value=“AA” /> <enumeration value=“AS” /> <enumeration value=“AAS” /> </restriction></simpleType> Define<simpleType name=“DegreesList”> data type <list itemType=“Degrees”/> using</simpleType> values<element name=“degreesEarned” type=“DegreesList” /> Define element storing different values
  • 20.  <union> allows the combination of two data type for an element or attribute If have a possiblePoints element, expected value would be an integer; <union> would allow a string entry to note a “Missing” value Separate data types with whitespace<simpleType name=“CreditValue”><union memberTypes=“xs:integer xs:string /></simpleType
  • 21. <xs:simpleType name="zipCode"> <xs:union> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[0-9]{5}" /> </xs:restriction> </xs:simpleType> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[0-9]{5}-[0-9]{4}" /> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType>

×