WTA5 XML Schema - 3/31/2011 (XML Schema) A schema is an...

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

View Full Document Right Arrow Icon
3/31/2011 1 1 (XML Schema) A schema is an alternative to DTD 2 Introduction b The syntax of Schema is similar to XML syntax. Thus a schema document is an XML document. b s If we want to represent the marks of a student in an XML document. We can add <marks> element within <student> element. This element is declared as PCDATA in our DTD file. s This ensures that the parser checks the existence of the marks element in the XML document, but it cannot ensure it as numeric! s Thus we cannot control the contents of the element marks. b All features of the DTD cannot be replaced by schema, (eg. entities). b An XML document that conforms to the rules of a schema is called as a valid XML document.
Background image of page 1

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

View Full DocumentRight Arrow Icon
3/31/2011 2 XML document : message.xml <?xml version=“1.0”?> <MESSAGE xmlns:xsi=“http://www.w3.org/2001/XMLSchema- instance” xsi:noNamespaceSchemaLocation=“message.xsd”> Hello World! </MESSAGE> 3 <?xml version=“1.0”?> <xsd:schema xmlns:xsd=“http://www.w3.org/2001/XMLSchema”> <xsd:element name=“MESSAGE” type=“xsd:string”/> </xsd:schema> Schema : message.xsd Explanation of XML Declaration (message.xml) < MESSAGE xmlns:xsi=“http://www.w3.org/2001/XMLSchema- instance” xsi:noNamespaceSchemaLocation=“message.xsd” > b indicates root element. b instance of the schema specifications to which our XML document is adhering. b Specifies a schema file which we want to associate with our XML document. 4
Background image of page 2
3/31/2011 3 Explanation of XML Schema (message.xsd) <?xml version=“1.0”?> <xsd:schema xmlns:xsd=“http://www.w3.org/2001/XMLSchema”> <xsd:element name=“MESSAGE” type=“xsd:string”/> </xsd:schema> b Indicates that this is schema because its root is named schema. Namespace prefix is xsd. Namespace URI means that our schema declarations conform to the schema standards specified on this site, and we can use this within the file with namespace xsd. b Specifies that we want to use an element <MESSAGE> in our XML document and that its data type is defined as string. b Specifies the end of the schema. 5 Elements in XML Schema b Simple elements s Can contain only text. They cannot have sub- elements or attributes. The text that they can contain, various data types such as strings, numbers, dates, etc. b Complex elements s Can contain sub-elements, attributes, etc. They are made up of one or more simple element. 6
Background image of page 3

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

View Full DocumentRight Arrow Icon
3/31/2011 4 Example : student information b Individual blocks of information as simple elements and encapsulated by a complex element in the form of the root element. student.xml <?xml version=“1.0”?> <STUDENT xmlns:xsi=“http://www.w3.org/2001/XMLSchema- instance” xsi:noNamespaceSchemaLocation=“student.xsd”> <ROLL_NUMBER>100</ROLL_NUMBER> <NAME>Pallavi Joshi</NAME> <MARKS>80</MARKS> <RESULT>Distinction</RESULT> </STUDENT> 7 Designate StudentType as complexType User defined data type without prefix xsd Schema File : student.xsd <?xml version=“1.0”?>
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/04/2011 for the course IT 103 taught by Professor Php during the Spring '11 term at University of Mumbai.

Page1 / 23

WTA5 XML Schema - 3/31/2011 (XML Schema) A schema is an...

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

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