lecture11

lecture11 - PIC 40A Lecture 11: XML Schema: ComplexTypes...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: PIC 40A Lecture 11: XML Schema: ComplexTypes and Attributes An XSD document skeleton <?xml version="1.0" encoding="us-ascii"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.pic.ucla.edu/~k/newSchema" xmlns="http://www.pic.ucla.edu/~k/newSchema" elementFormDefault="qualified"> <!- top-level named declarations (direct children of root xsd:schema) xsd:element xsd:simpleType xsd:complexType xsd:attribute xsd:attributeGroup xsd:group--> </xsd:schema> complexTypes Recall an xsd:complexType element in an XSD document defines a content model and attribute list for an element in the target namespace A complexType may be either anonymous and local to its parent element named and global (top-level) Declaring a complexType Use an xsd:complexType element: <xsd:complexType> <!-- definition here --> </xsd:complexType> If this complexType is top-level, you must assign its name attribute a value so that any xsd:element which would like to use that content model can specify that name in its type attribute. To allow mixed content , set mixed attribute to "true" The simplest complexType Empty content without attributes Anonymous (local and child of an xsd:element ) <xsd:complexType /> Named (global) <xsd:complexType name="emptyType" /> An element that uses this global complexType <xsd:element name="break" type="emptyType" > Empty complexType with attributes Place xsd:attribute elements in the complexType's content. eg of an empty element that carries a required attribute <xsd:complexType> <xsd:attribute name="price" type="xsd:decimal" use="optional" default="2.30" /> </xsd:complexType> use attribute may also be set to "required" or "prohibited" default attribute need not be provided to fix the attribute's value, specify it as the value of the fixed attribute Attribute Groups You can place attributes into a top-level group and reference them later <xsd:attributeGroup name="profileType"> <xsd:attribute name="student" type="xsd:string"/> <xsd:attribute name="gpa" type="xsd:decimal"/> </xsd:attributeGroup> Referencing an Attribute Group Place an xsd:attributeGroup element in the content of a xsd:complexType element and assign its ref attribute the value of the attributeGroup 's name <xsd:complexType> <!-- element or group content --> <!-- attributeGroup replaces individual declarations --> <xsd:attributeGroup ref="profileType"/> </xsd:complexType> Content for complexType The Four Group Elements xsd:all xsd:choice xsd:sequence xsd:group Controlling the number of element or group occurrences U s e minOccurs and maxOccurs attributes of one of the four group elements to control frequency of the group....
View Full Document

Page1 / 31

lecture11 - PIC 40A Lecture 11: XML Schema: ComplexTypes...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online