Introduction

Website: http://xmlsoft.org/

The XML libraries and tools

Architecture of libxml2

the architecture of libxml

XML itself

XML is a W3C Recommendation

Inserting metadata in text to associate structure to content

<p> Classic example based on
<a href="http://www.w3.org/">HTML</a> markup</p>

The mathematical representation is a tree: an XML tree for the given markup

The tree parser Interface

import libxml2
doc = libxml2.parseFile("ex1.xml")
p = doc.children
print p.name
doc.freeDoc()

See example 1, XML

The SAX interface

The reader interface

import libxml2

input = libxml2.inputBuffer(open("ex2.xml"))
reader = input.newTextReader("ex2.xml")
ret = reader.Read()
while ret == 1:
    print reader.Name()
    ret = reader.Read()

See example 2, XML

XML Namespaces

<p xmlns="http://www.w3.org/1999/xhtml"> Classic example based on
<a href="http://www.w3.org/">HTML</a> markup</p>
<x:p xmlns:x="http://www.w3.org/1999/xhtml"> Classic example based on
<x:a href="http://www.w3.org/">HTML</x:a> markup</x:p>

Validation: DTDs

<!DOCTYPE p [
<!ELEMENT p (#PCDATA | a | em)*>
<!ELEMENT a (#PCDATA)>
<!ATTLIST a href CDATA #REQUIRED >
<!ELEMENT em (#PCDATA)>
]>

See example 3, XML

Validation: XML Schemas

Validation: XML Schemas Datatypes

image of the hierarchy of data types

Validation: Relax-NG

<element name="p"
   xmlns="http://relaxng.org/ns/structure/1.0">
  <zeroOrMore>
    <choice>
      <text/>
      <element name="a">
        <attribute name="href"/>
        <text/>
      </element>
    </choice>
  </zeroOrMore>
</element>

See example 4, XML, RNG

Validation: streaming

See example 5, XML, RNG

XPath: addressing language

Examples:

/p/a
//a
//a[@href = "index.html"]

Try "xmllint --shell" to test XPath expressions

XPointer: fragment and selection

XInclude: inclusion mechanism

See example 6, XML, Included

XSLT: the transformation language

See example 7, XML, Stylesheet

EXSLT: XSLT extensions

XMLSig: signand encrypt

Catalogs and I/O handling

Conclusions

Questions and Answers

Beach, sand and sea