https://www.slideshare.net/slideshow/cyber-security-introductionpptx-255143441/25514344118888-XML schema.pptx

nivin112224 7 views 11 slides Aug 08, 2024
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

this c


Slide Content

Xml schema

XML Hierarchical (Tree) Data Model The XML data model’s basic object is the XML document . There are two main structuring concepts that are used to construct an XML document: Elements Attributes Attributes in XML provide additional information that describe elements. As in HTML, elements are identified in a document by their start tag and end tag . The tag names are enclosed between angled brackets <…>, and end tags are further identified by a backslash </…>.

Complex elements are constructed from other elements hierarchically, whereas simple elements contain data values. It is straightforward to see the correspondence between the XML textual representation and the tree structure. In the tree representation, internal nodes represent complex elements, whereas leaf nodes represent simple elements. That is why the XML model is called a tree model or a hierarchical model .

XML Schema An XML schema, commonly known as an XML Schema Definition (XSD), formally describes what a given XML document can contain, in the same way that a database schema describes the data that can be contained in a database The XML schema defines the shape, or structure, of an XML document , along with rules for data content and semantics such as what fields an element can contain, which sub elements it can contain and how many items can be present. It can also describe the type and values that can be placed into each element or attribute

The <schema> element is the root element of every XML Schema. <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="„> ... ... </xs:schema> XML Elements  Elements are the main building block of all XML documents, containing the data and determine the structure of the instance document. Two types  Simple type and complex type

A simple element is an XML element that can contain only text . It cannot contain any other elements or attributes. < xs:element name="xxx" type=" yyy "/> where xxx is the name of the element and yyy is the data type of the element. XML Schema has a lot of built-in data types. The most common types are: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time

A complex element is an XML element that contains other elements and/or attributes. There are four kinds of complex elements: empty elements elements that contain only other elements elements that contain only text elements that contain both other elements and text < xs:element name="Customer"> < xs:complexType > < xs:sequence > < xs:element name="Dob" type=" xs:date " /> < xs:element name="Address" type=" xs:string " /> </ xs:sequence > </ xs:complexType > </ xs:element >

Simple elements cannot have attributes . If an element has attributes, it is considered to be of a complex type. But the attribute itself is always declared as a simple type. < xs:attribute name="xxx" type=" yyy "/> XML Schema has a lot of built-in data types. The most common types are: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time

<?xml version="1.0" encoding="UTF-8"?> < shiporder orderid ="889923" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"> < orderperson >John Smith</ orderperson > < shipto > <name>Ola Nordmann</name> <address> Langgt 23</address> <city>4000 Stavanger</city> <country>Norway</country> </ shipto > <item> <title>Empire Burlesque</title><note>Special Edition</note><quantity>1</quantity> <price>10.90</price></item> </ shiporder >

<?xml version="1.0" encoding="UTF-8" ?> < xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema"> < xs:element name=" shiporder “>< xs:complexType > < xs:sequence > < xs:element name=" orderperson " type=" xs:string "/> < xs:element name=" shipto "> < xs:complexType > < xs:sequence > < xs:element name="name" type=" xs:string "/> < xs:element name="address" type=" xs:string "/> < xs:element name="city" type=" xs:string "/> < xs:element name="country" type=" xs:string "/> </ xs:sequence > </ xs:complexType ></ xs:element >< xs:element name="item" maxOccurs ="unbounded">

< xs:complexType > < xs:sequence > < xs:element name="title" type=" xs:string "/> < xs:element name="note" type=" xs:string " minOccurs="0"/> < xs:element name="quantity" type=" xs:positiveInteger "/> < xs:element name="price" type=" xs:decimal "/> </ xs:sequence > </ xs:complexType > </ xs:element > </ xs:sequence > < xs:attribute name=" orderid " type=" xs:string " use="required"/> </ xs:complexType > </ xs:element > </ xs:schema >