lecture10

lecture10 - PIC 40A Lecture 10: XML Schema: Elements and...

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

View Full Document Right Arrow Icon
PIC 40A Lecture 10: XML Schema: Elements and SimpleType Content Models
Background image of page 1

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

View Full DocumentRight Arrow Icon
An example .xsd file intro <?xml version="1.0" encoding="us-ascii"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace ="http://www.pic.ucla.edu/~kouellet/newSchema" xmlns="http://www.pic.ucla.edu/~kouellet/newSchema" elementFormDefault="qualified"> Then we declare top-level elements , simpleTypes , and complexTypes for our target namespace (our XML application).
Background image of page 2
Declaring Elements Use the xsd:element tag. • The name attribute specifies the name of the element you are defining for your XML application. • The type attribute specifies the element's content model which can reference either a global simpleType or a global complexType. <xsd:element name="musicml" type="???"/>
Background image of page 3

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

View Full DocumentRight Arrow Icon
Declaring Elements Instead of using the type attribute, create in the content of xsd:element an anonymous local simpleType or complexType <xsd:element name="musicml"> <!–- Define an anonymous local type here --> </xsd:element> The anonymous local type can only be used by its parent musicml .
Background image of page 4
Referencing Declared Elements • use ref attribute instead of name when specifying an pre-declared global element inside a complexType <xsd:element ref="musicml " /> Do not specify the type attribute in this case.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Data Types: What’s the difference? simple types cannot have element content and cannot carry attributes complex types allow elements in their content and may carry attributes All attribute declarations must reference simpleTypes because they cannot contain other elements or other attributes
Background image of page 6
Derived Types •A derived type is a simpleType or complexType created by restricting or extending a base type • one can derive a complex type from a simple
Background image of page 7

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

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

Page1 / 23

lecture10 - PIC 40A Lecture 10: XML Schema: Elements and...

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

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