Unit 2 XML
Unit 2 XML
XML schema is a language which is used for expressing constraints about XML
documents. There are so many schema languages which are used now a days for example
Relax- NG and XSD (XML schema definition).
An XML schema is used to define the structure of an XML document. It is like DTD but
provides more control on XML structure.
1. simpleType
2. complexType
simpleType
The simpleType allows you to have text-based elements. It contains less attributes, child
elements, and cannot be left empty.
complexType
The complexType allows you to hold multiple attributes and elements. It can contain
additional sub elements and can be left empty.
2
XQuery: Introduction and Simple Example
XQuery is a query language designed to query XML data. It allows you to extract and
manipulate information from XML documents.
<books>
<book>
<title>Learning XML</title>
<author>Erik T. Ray</author>
<price>39.95</price>
</book>
<book>
<title>Programming Web Services with SOAP</title>
<author>James Snell</author>
<price>29.95</price>
</book>
<book>
<title>XQuery Kick Start</title>
<author>James McGovern</author>
<price>49.95</price>
</book>
</books>
Suppose you want to retrieve all the book titles from this XML file.
XQuery Code:
for $book in doc("books.xml")/books/book
return $book/title
Output:
Learning XML
Programming Web Services with SOAP
XQuery Kick Start
You can modify the query to filter the books based on price.
XQuery Code:
Explanation:
1. The where clause filters books with a price less than 40.
2. It returns only the titles of books that meet this condition.
Output:
Learning XML
Programming Web Services with SOAP
This is a simple introduction to how XQuery works with XML data to extract and filter
information.
1. Fundamental Components:
● XML Processors: These parse and validate XML documents. They are categorized
into tree-based (DOM) and event-based (SAX) processors, offering flexibility
depending on the application's memory and access needs.
● XSLT Processors: Transform XML documents into other formats like HTML or PDF
using stylesheets. Widely used processors include Apache’s Xalan and Microsoft’s
XSLT engines.
● Storage Systems: XML documents can be stored in different ways, including
Database Management Systems (DBMS), Content Management Systems (CMS), or
native XML stores (e.g., Tamino, TEXTML Server).
2. Server Infrastructure:
● Data Servers: Facilitate access and aggregation of XML data from various sources,
often providing XML documents in response to requests. They support mapping
between database schemas and XML structures, enabling smooth data interchange.
● Application Servers: Handle business logic and integrate XML through SOAP
messaging and XSLT transformations, enabling XML document exchange between
components. Examples include BEA WebLogic, IBM WebSphere, and Microsoft
.NET.
● Content Servers: Responsible for dynamic presentation and delivery of XML content
(e.g., HTML generation through XSLT). They also manage searching and syndicating
XML-based content.
● CMSs manage the storage, version control, and distribution of XML content. They
support collaborative content creation, including XML documents. Examples include
Vignette and Interwoven TeamSite.
● CMS also assists with indexing and delivering content, ensuring that documents are
available in different formats and media.
5. Development Tools:
● Development tools help manipulate XML documents and generate code for XML
transformation and processing. Popular tools include Altova XMLSpy and TIBCO
TurboXML, which provide tree-based views and auto-generate XSLT stylesheets.
Conclusion:
The XML software infrastructure is comprehensive, supporting various tasks from XML
parsing, transformation, and storage, to integration with web services and content
management systems. It is critical to choose the right components based on the needs of
data-oriented or content-oriented applications to ensure efficiency and scalability.
Layout tools, transformation tools, and authoring tools are essential components of XML
software infrastructure for content management and presentation.
Layout tools help designers create visual layouts for XML content, allowing them to define
how elements should appear in different formats using XSL (Extensible Stylesheet
Language) without requiring deep technical knowledge.
Transformation tools enable developers to convert XML data between different formats or
from XML to non-XML formats using XSLT (Extensible Stylesheet Language
Transformations). They provide visual mapping and debugging features to simplify
transforming data from one structure to another.
Authoring tools are used to create and edit XML documents, offering word-processing-like
interfaces for content creators, and often include features for structured content input,
template-based creation, and placeholders for dynamic data, streamlining the process of
generating high-quality, structured XML content.