Formsoft Ltd
 
Welcome
HTML
XML
Applications
Clients
Resources
Contact Us
Extensible Markup Language (XML)

Extensible Markup Language is a human readable, portable, text-based format. It is flexible and can be extended by defining and adding new "tags". An XML document contains "raw" content. It does not contain information for style or format of the data. The separation of content from style allows the same XML document to be used with different XSL style sheets to produce documents for many different purposes. We can format your data into XML so that you can benefit from this flexibility. See below an XML document used on this site.

The structure of an XML document is defined by its Data Type Definition (DTD). Wherever possible we recommend using industry standard DTDs see XML.org. See below a DTD used on this site. DTDs allow the content of a document to be validated. However DTD validation is restricted to the simple ordering of "tags" and simple data types. To specify completely the structure of a document and it's data types we recommend the use of XML schemas.

Processing XML with JAXP, SAX, DOM & JDOM

The Java API for XML Processing (JAXP) provides two APIs, SAX and DOM, for processing XML documents. The Simple API for XML (SAX) creates events as it passes each part of a "tag". We recommend using SAX to process large documents efficiently. Unlike SAX, the Document Object Model (DOM) parser holds the structure of the document in memory. We recommend using DOM for small documents that need to be manipulated.

The JDOM API is compatible with DOM and SAX. It is designed specifically for Java. It is simple and efficient for parsing and modifying XML. We recommend using JDOM in preference to SAX and DOM wherever possible.

Extensible Stylesheet Language (XSL)

We can use Extensible Stylesheet Language (XSL) to transform your XML documents into other XML, HTML, XHTML, any text format, or even binary formats like PDF. Where XML defines the content XSL defines the style or format. See below for an example of how we can use XSL to separate content from style.

EXAMPLE

Resources XML is an XML document that defines all the links on the Resources page of this web site. The document contains no HTML or any other style information. The DTD below shows that "sections" contain "references" and that a "reference" may contain other "references".
<!ELEMENT resources (section+)>
<!ELEMENT section ( name, reference+)>
<!ELEMENT reference ( name, ref, reference*) >
<!ELEMENT name (#PCDATA)>
<!ELEMENT ref (#PCDATA)>

We can now transform this document into the HTML for the Resources page using the XSL below. Each "reference" is formatted into a HTML list of links and each "section" is formatted into the column of an HTML table. Should we wish to change the layout of the page we simply change the style sheet.
<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="resources">
  <table><xsl:apply-templates/></table>
</xsl:template>

<xsl:template match="section">
  <td valign="top" >
    <span class="sectext">
      <xsl:value-of select="name"/> 
    </span>
   	<ul>
      <xsl:apply-templates select="reference"/>
    </ul>
  </td>
</xsl:template>

<xsl:template match="reference">
  <li>
    <xsl:element name="a">
      <xsl:attribute name="href">
        <xsl:value-of select="ref" />
      </xsl:attribute>
      <xsl:value-of select="name" />
    </xsl:element>

    <xsl:if test="count(reference) > 0">  
      <ul>
        <xsl:apply-templates select="reference[not(self)]" />
      </ul>      		
    </xsl:if>
  </li>
</xsl:template>

</xsl:stylesheet>