XML and XML Schema

An XML Schema describes the structure of an XML document.

XML Schema also called as XSD( XML Schema Definition)

Simple Element:

A simple element is an XML element that can contain only text. It cannot contain any other elements or attributes.

XML element:

<age>36</age>

corresponding simple element definition:

<element name=”age” type=”integer”/>

Attribute:

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

attribute syntax:

<xs:attribute name=”xxx” type=”yyy”/>

Example:

XML element with an attribute:

<lastname lang=”EN”>Bala</lastname>

corresponding attribute definition:

<xs:attribute name=”lang” type=”xs:string”/>

Complex Element:

A complex element is an XML element that contains other elements and/or attributes.

XML Document:

<employee>
<firstname>Bala</firstname>
<lastname>Reddy</lastname>
</employee>

XML Schema:

we can declare the complex type in two ways:

1)
<element name=”employee”>
<complexType>
<sequence>
<element name=”firstname” type=”string”/>
<element name=”lastname” type=”string”/>
</sequence>
</complexType>
</element>

if you declare the complext type in the above format  only “employee” element can use specified compelx type.

2) 

<element name=”employee” type=”PersonDetails”/>

<complexType name=”PersonDetails”>
<sequence>
<element name=”firstname” type=”string”/>
<element name=”lastname” type=”string”/>
</sequence>
</complexType>

if you declare the complext type in the above format  , more than one element can refer to the same complex type.

like below:

<element name=”employee” type=”PersonDetails”/>
<element name=”customer” type=”PersonDetails”/>

Cardinality in XML Schema:

By default cardinality for an element is “1”, i.e minOccurs,maxOccurs is “1”

example:

<element name=”Name” type=”string” minOccurs =”0″ maxOccurs=”unbounded” />

above element minOccurs is 0, means the element is optional and maxOccurs is unbound it can repeat n number of times.

Inline Schema:

if we declare the schema inside the wsdl file then we called it as a inline schema.

Relevant Courses:

Oracle SOA suite 12c online training 

Oracle Service Bus 12c online training

Oracle weblogic administration training

0 responses on "XML and XML Schema"

Leave a Reply

© 2017 SCM Teck. All rights reserved.
X