xml schema

15
XML SCHEMA By D.AKSHAYA III B.TECH IT-A

Upload: akshaya-akshaya

Post on 13-Apr-2017

69 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Xml schema

XML SCHEMABy D.AKSHAYAIII B.TECH IT-A

Page 2: Xml schema

WHAT IS XML?Extensible Markup

Language (XML) is a markup language that defines a set of rules for encoding documents in a formatwhich is both human-readable and machine-readable

XML was designed to carry data, not to display data

Page 3: Xml schema

XML HTML Used to carry data Can create own tags Platform independent and language

independent Tags and attributes are case sensitive &

must be quoted XML elements must be properly nested All XML elements must have a closing

tag XML is used to create new internet

languages. Here are some examples: ◦ WSDL for describing available web services ◦ WAP and WML as markup languages for

handheld devices ◦ RSS languages for news feeds ◦ RDF and OWL for describing resources and

ontology ◦ SMIL for describing multimedia for the web

Used to display dataCant create own tagsNot language

independentTags are not case

sensitive & quotes is not complusory

Page 4: Xml schema

WHERE AND WHY XML?SCENARIOA web service client or server written in java must convert between its internal representation of data and character strings appropriate for representing the data in a SOAP document(or any kind of doc used for displaying the data in the web)Eg: Currency convertor From dollars : web service has to convert the java double value to represent the amount in string

Page 5: Xml schema

Contd..What would be the constraints in

this process??Data range decisionValue constraintsUsage of scientific notationPrecision issues and etc..

Page 6: Xml schema

Solution???XML SCHMEA (XML

VOCABULARY):

It has a definition of collection of standard data types.

It has the range of values that could be used for a particular data type and then datas on how to represent the values

Page 7: Xml schema

XML SCHEMAWELL FORMED XML DOCUMENTXML with correct syntax is "Well Formed" XML.

XML validated against a DTD is "Valid" XML.

 Example for XML Document <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me! </body></note>

Page 8: Xml schema

XML ELEMENT & VOCABULARY XML Element An XML element is everything from (including) the

element's start tag to (including) the element's end tag. An element can contain: other elements text attributes Or a mix of all of the above... XML vocabulary XML vocabulary is used to define element and attribute names element content Semantics of elements and attributes Some of the xml vocabularies are XHTML, RSS, XSL, DTD,

and Schema

Page 9: Xml schema

Xml schema and DTD

DTD SCHEMA Defines the structure with a list

of defined elements in the xml document.

<!DOCTYPE note[<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>

]>Extension: .dtdHas only two data types: CDATA & PDATA

It is an alternative to DTD to define the structure of an XML document.

<xs:element name="note"><xs:complexType>  <xs:sequence>    <xs:element name="to" type="xs:string"/>    <xs:element name="from" type="xs:string"/>    <xs:element name="heading" type="xs:string"/>    <xs:element name="body" type="xs:string"/>  </xs:sequence></xs:complexType></xs:element>

This definition file is stored with .xsl extension.

Can have primitive and complex data types.

Page 10: Xml schema

DATA TYPES IN XML SCHEMA

DATA TYPES

SIMPLE

PRIMITIVE(BUILT-IN) USER DEFINED

COMPLEX

PRIMITIVE(BUILT-IN) USER DEFINED

Page 11: Xml schema

A quick comparison..SIMPLE DATA TYPEValues are

represented in xml doc by character data

Used to represent individual values

COMPLEX DATA TYPEValues are

represented using mark up.

Used to represent structured data(highly organised).

Page 12: Xml schema

Built in data type..

Sim

ple

built

in d

ata

type

sThe data types defined by xml schema specification itself are called built-in data types.Eg: <latitude xsi:type=“xsd:decimal”>40.28</latitude>Xsd decimal is a reference to XML schema

Xml schema type is similar to java ‘s primitive types. Except for booleanXML schema types appear as type and message elements.Within types, user defined data types are the building blocks for user-defined types.Within message elements built in types are used to declare data type for an operation parameter or return value.

Page 13: Xml schema

XML NAMESPACESIt is a collection of element and

attributes names associated with an XML vocabulary. XML Namespaces provide a method to avoid element name conflicts.

doc1• <table>

  <tr>    <td>Apples</td>    <td>Bananas</td>  </tr></table>

Doc 2•<table>  <name> Coffee Table</name>  <width>80</width>  <length>120</length></table>

Namespace usage

• <h:table>  <h:tr>    <h:td>Apples</h:td>    <h:td>Bananas</h:td>  </h:tr></h:table>

<f:table>  <f:name>African Coffee Table</f:name>  <f:width>80</f:width>  <f:length>120</f:length></f:table>

Page 14: Xml schema

USER DEFINED TYPES..USER DEFINED SIMPLE

TYPES<simpleType

name=“memberType”><restriction base=“string”> <enumeration value=“platinum”/> <enumeration value=“gold”/></restriction></simpleType>Facets of simple data type: length,minlength,maxlength

USER DEFINED COMPLEX TYPE

<anExchangeValue xsi:type=“ExchangeValues”>

<dollars>1.0</dollars>

<euros>0.7468</euros>

</anExchangeValue>

Page 15: Xml schema

THANKS FOR LISTENING!