XQuery
XQuery,
Query on one or more XML file to produce another XML file. It is designed to
query XML data not just XML files, but anything that can appear as XML,
including databases. It is a W3C Recommendation
Example:
Create
a new docment which contain only the isbn and title of textbooks.
<textbooks>
{ for $book in
doc("bookstore.xml")//book where $book/@cat="textbook"
return <textbook
isbn="$book/@isbn">{$book/title}</textbook>
}
</textbooks>
Result:
<textbooks>
<textbook
isbn="222222">
<title
lang="eng">Learning XML</title>
</textbook> <textbook
isbn="333333">
<title
lang="eng">intro. to Databases</title>
</textbook>
</textbooks>
Application of XML
Web Services: Web services
implementation is an important application of using XML in the real world. A
Web service is a piece of code that can be discovered, described, and accessed
using XML.
There
is a great deal of activity in this space, but the three main XML standards for
Web services are:
SOAP: Originally the Simple Object Access Protocol, SOAP defines an XML document format that describes how to invoke a method of a remote piece of code. My application creates an XML document that describes the method I want to invoke, passing it any necessary parameters, and then it sends that XML document across a network to that piece of code. The code receives the XML document, interprets it, invokes the method I requested, then sends back an XML document that describes the results.
WSDL: The Web Services Description Language is an XML vocabulary that describes a Web service. It's possible to write a piece of code that takes a WSDL document and invokes a Web service it's never seen before. The information in the WSDL file defines the name of the Web service, the names of its methods, the arguments to those methods, and other details.
UDDI: The Universal Description, Discovery, and Integration protocol defines a SOAP interface to a registry of Web services. If you have a piece of code that you'd like to deploy as a Web service, the UDDI spec defines how to add the description of your service to the registry. If you're looking for a piece of code that provides a certain function, the UDDI spec defines how to query the registry to find what you want.
Summary
By
the end of this module, you have to learnt:
- XML stands for Extensible Markup Language and is designed to transport and store data, not to display data. XML is not a replacement for HTML. XML tags are case sensitive
- XML was created to structure, store, and transport information. XML language has no predefined tags. With XML you invent your own tags
- XML documents form a tree structure that starts at "the root" and branches to "the leaves"
- XML documents must contain one element that is the parent of all other elements. This element is called the root element
- The syntax for writing comments in XML is similar to that of HTML. can be extended to carry more information XML with correct syntax is "Well Formed" XML
- XML validated against a DTD is "Valid" XML
- The purpose of a DTD (Document Type Definition) is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements and attributes
- XML Schema is an XML-based alternative to DTDs. It describes the structure of an XML document. XML Schemas are written in XML and therefore they are extensible
- The <schema> element is the root element of every XML Schema