1 / 10

CA201 Word Application

CA201 Word Application. XML Week # 10 By Tariq Ibn Aziz Dammam Community college. Objectives. In this chapter you will learn to: XML Document Create XML Schema. XML Document in Word. Let's have a look at this XML document called “ Simple.xml ” XML document has a root element persons.

hoang
Download Presentation

CA201 Word Application

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CA201Word Application XML Week # 10 By Tariq Ibn Aziz Dammam Community college

  2. Objectives • In this chapter you will learn to: • XML Document • Create XML Schema Tariq Aziz, Dammam Community College

  3. XML Document in Word • Let's have a look at this XML document called “Simple.xml” • XML document has a root element persons. • The “persons” element contains 1 child element “person”. • “person” appears twice and contain name, address, city, and country elements. Tariq Aziz, Dammam Community College

  4. XML Document in Notepad <?xml version="1.0" encoding="ISO-8859-1"?> <persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="simple.xsd"> <person> <name>Ola Nordmann</name> <address>Langgt 23</address> <city>4000 Stavanger</city> <country>Norway</country> </person> </persons> Tariq Aziz, Dammam Community College

  5. XML Document • The line above: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" tells the XML parser that this document should be validated against a schema. • The line: xsi:noNamespaceSchemaLocation="simple.xsd" specifies WHERE the schema resides (here it is in the same folder as "simple.xml"). Tariq Aziz, Dammam Community College

  6. Create XML Schema • Open a file in Notepad and name it “Simple.xsd” • To create the schema we could simply follow the structure in the XML document and define each element as we find it. • We will start with the standard XML declaration followed by the xs:schema element that defines a schema <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> ... ... </xs:schema> Tariq Aziz, Dammam Community College

  7. Create XML Schema[2] <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> ... ... </xs:schema> • In the schema above we use the standard namespace (xs), • The URI associated with this namespace is the Schema language definition, which has the standard value of http://www.w3.org/2001/XMLSchema. Tariq Aziz, Dammam Community College

  8. Complex Type • Next, we have to define the “persons" element. • This element contains other elements, therefore we consider it as a complex type. • The child elements of the “person" element is surrounded by a xs:sequence element that defines an ordered sequence of sub elements <xs:element name="persons"> <xs:complexType> <xs:sequence> ... ... </xs:sequence> ... </xs:complexType> </xs:element> Tariq Aziz, Dammam Community College

  9. SML Schema <?xml version="1.0" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="persons"> <xs:complexType> <xs:sequence> <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string" /> <xs:element name="note" type="xs:string" /> <xs:element name="quantity" type="xs:positiveInteger" /> <xs:element name="price" type="xs:decimal" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Tariq Aziz, Dammam Community College

  10. Chapter Key Points Tariq Aziz, Dammam Community College

More Related