{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

WTA5 XML Schema - (XML Schema A schema is an alternative to...

Info icon This 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 box4 The syntax of Schema is similar to XML syntax. Thus a schema document is an XML document. box4 Difference b/w DTD & Schema Example : square6 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. square6 This ensures that the parser checks the existence of the marks element in the XML document, but it cannot ensure it as numeric! square6 Thus we cannot control the contents of the element marks. box4 All features of the DTD cannot be replaced by schema, (eg. entities). box4 An XML document that conforms to the rules of a schema is called as a valid XML document.
Image of page 1

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

View Full Document Right 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” > box4 indicates root element. box4 Namespace & URI. The URI specifies a particular instance of the schema specifications to which our XML document is adhering. box4 Specifies a schema file which we want to associate with our XML document. 4
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> box4 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. box4 Specifies that we want to use an element <MESSAGE> in our XML document and that its data type is defined as string. box4 Specifies the end of the schema. 5 Elements in XML Schema box4 Simple elements square6 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. box4 Complex elements square6 Can contain sub-elements, attributes, etc. They are made up of one or more simple element. 6
Image of page 3

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

View Full Document Right Arrow Icon
3/31/2011 4 Example : student information box4 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”?> <xsd:schema xmlns:xsd=“http://www.w3.org/2001/XMLSchema”>
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern