‘computers and internet’ Tagged Posts

Mastering The Essentials Of XML Schema

XML schema definition languages are derived from the recommendations of the World Wide Web Consortium (W3C). They use XML 1.0 syntax and their role ...

 

XML schema definition languages are derived from the recommendations of the World Wide Web Consortium (W3C). They use XML 1.0 syntax and their role is to explicit describe the structure of XML documents and constrain the data which they may contain. They offer a distinct improvement on the more limited schema features offered by the Document Type Definition (DTD) recommendation which formed part of the original XML specification released in 1998. The most widely used schema language is the one defined by the W3C in 2001: W3C XML Schema. However, there are alternatives, such as RELAX NG and Schematron.

Schema documents are the more sophisticated successors to DTDs and overcome some key limitations associated with them. Firstly, DTDs do not support data types. Secondly, DTDs do not support namespaces. Thirdly, DTDs do not allow developers to accurately define the number of permitted occurrences of elements within their parent element.

An XML schema is concerned with the structure of an XML instance document by defining what each element must or may contain. An element is limited by its type. For example, an element of complex type can contain child elements and attributes, whereas a simple-type element can only contain text. The diagram below gives a first look at the types of XML Schema elements.

Three main purposes are fulfilled by schema documents. Firstly, they can be used to validate XML documents. Secondly, they can be used as a dictionary or grammar for the creation of a given class of XML document. And, thirdly, they can be used to provide documentation for XML documents.

Each XML schema is itself an XML document and contains definitions of all elements and attributes permitted in a given class of XML documents. The schema also specifies the structure or hierarchy to which elements must adhere and the type of content each particular element may contain. Elements may be of the simple or complex type. Complex type elements may contain child elements as well as attributes. Simple type element may only contain data. XML documents using a particular schema are referred to as instances of the schema. An XML instance that correctly adheres to its associated schema is said to be valid.

Validation is usually the principal role of schema documents. Validation offers many benefits. It ensures the consistency of data within a document. It ensures that data has the right structure and internal hierarchy. It ensures that data within the document structure is of the correct type. It allows us to receive data from multiple sources.

Most XML documents are produced by programs and scripts written to extract information held in databases and transform it into XML. However, it is also possible for human beings to create XML documents. Schemas can be used during this process to assist in the document creation process. XML schemas also provide a mechanism for documenting XML documents and form an important part of the specification of XML vocabularies.

The author is a training consultant with Macresource Computer Training, a UK IT training company offering XML Classes in London and throughout the UK.

Overview of XML Technologies

 

Core XML

Extensible Markup Language (XML) is a specification by the Worldwide Web Consortium (W3C) for creating markup languages such as XHTML. The XML specification is being used in an increasingly wide range of applications for exchanging data between different environments, platforms and media. One of the main reasons for its rapidly growing popularity is its flexibility. It allows developers to define their own hierarchy of tags which reflect the structure of their data. In addition to the core XML specification, a number of other technologies have been developed for working with XML projects.

XML Schema

Closely linked with XML documents, we have XML schema. XML schema documents and schema languages are used to validate and document XML markup languages. They allow developers to explicitly lay down the syntactical and structural ground rules for particular classes of XML documents. A number of schema languages have been developed but perhaps the two most important are those defined by the W3C: Document Type Definition (DTD) which was built into the original XML specification and the more XML schema language developed a few years later.

XSL, XSLT AND XSL-FO

XML also offers technologies for transforming XML documents. Extensible Stylesheet language (XSL) comprises two parts: XSL Transformations (XSLT) and XSL Formatting Objects (XSL-FO). XSLT stylesheets are essentially XML documents which transform a given class of XML document (referred to as the source tree) into a different class of XML document (referred to as the output tree). XSLT documents can be compared to CSS documents but are much more powerful. XSL-FO documents are written in XML and control the formatting layout in an output document in a very detailed manner. It allows the definition of layout masters from which are derived page sequences for generating the final document pages. Flow objects are then used to bind data to the various regions of pages.

XPath, XLink, XPointer and XQuery

XPath, XML Linking Language (XLink), and XML Pointer Language (XPointer) are all provide solutions for linking and addressing when working with XML documents. XPath is a declarative language which uses expressions that resemble the directory paths used to describe locations in computer file systems. XPath expressions are used in XSLT documents to address specific nodes within the hierarchy of the XML source document.

XLink is essentially a method of creating hyperlinks within XML documents. It overcomes some of the limitations of the hyperlinks used in XHTML, such as the fact that each hyperlink has only one source and one destination. XPointer allows you to create links which point to very specific points within the hierarchy of an XML document by including XPath expressions in its syntax. XQuery is designed to query XML data in much the same way that SQL is used to query databases. It uses XPath expressions to extract elements and attributes within the structure of an XML document.

Author is a developer and trainer with Macresource Computer Training, a UK IT training company offering XML training courses in London and throughout the UK.