XSLT transforms library

Copyright J.M. Vanel 2000-2001 - under GNU Public Licence
Last update:

 A nice collection of useful XSLT transforms, models and reusable fragments under GPL, involving HTML tables, XML Schema, HTML GUI, MathML, SQL analogy, etc. This has been developped as part of the "Worlwide Botanical Knowledge Base" project, ( http://wwbota.free.fr/ ).

The transforms fall within the following (mutually exclusive) categories :

proof of concept
aims at showing the possibilities of XSLT in various domains; far from production quality
pedagogical
small examples
design pattern
starting points of frequent use to write transforms, not for direct use but after editing (about design patterns see the book "Design Patterns" by E. Gamma et al.)
production
XSLT transforms of production quality, for direct use
template library
for use as imported stylesheet, of production quality

Other similar ressources:

I strongly recommend Michael Kay's book (the author of the Saxon processor), whose sources can be downloaded from wrox.com .

Vision

Create a series of useful transforms, either acting on the structure of the document, or performing generic transforms (e.g. creating an index of words), or acting on well-knows documents (e.g. XML Schema, SVG, XHTML, ...), or merging or splitting in various ways. These transforms should be able to be re-assembled (by chaining-piping, import, or other combinations) to perform complex tasks out of simple bricks. This is coherent with the vision of an XML-centered application (see Extensible browsers and XML-compliant applications on this site). This way we could also do something as useful and flexible as the Unix shells commands (wc, sed, grep, ...), and C++ Standard Template library. This is a sub-project under GNU Public Licence, so contributions are wellcome!

An application of XSLT transforms library is XMLPublication, a Web document publication framework through XML. As an example, XMLPublication was used with this HTML page as the source for generation (see XMLPub generated pages). Currently there are some XSLT transforms here that are outdated with respect to the XMLPublication distribution, and also many useful transforms there that are not here, but this will be fixed .


 

XSLT

XML source

Description

Category

Domain

Output

HTMLtable2XML.xslt

FinancialReport_1.htm

from HTML table to XML; generates XML tags from first row <th> tags UPDATED

production

XHTML

FinancialReport_1.xml

queryOnSubElement.xslt

test.xml

selects  a given tag according to the content of a subelement

pedagogical

query

queryOnSubElement.xml

selectTagName.xslt

pense-bete.xml

selects only given tag at any embedding level, and its content recursively

pedagogical

query

selectTagName.xml

identquery.xslt 

test.xml

identity transform

pedagogical

identquery2.xslt 

test.xml

identity transform 2 : a good starting point to write XSLT transforms

design pattern

suppressEmptyElements.xslt

emptyElements.xml

suppress empty elements (i.e. elements with no text content)

production

structure

emptySuppressed.xml

selectHREF.xslt

testHREF.xml

extract href attributes; example of text mode output

pedagogical

XHTML

selectHREF.txt

attributes2elements.xslt

testHREF.xml

replace attributes with elements; reuses identity transform 2 

production

structure

attributes2elements.xml

split.xslt

document-to-split.xml

split named first-level elements into files (XSLT 1.1) NEW

pedagogical

file structure

one file per first-level element

append.xslt

merge after last first-level element of document at URL $main all first-level elements of input document .

production

file structure

wrapper.xslt

wrap a nodeset fragment of XML inside an XML document. An attribute marker is used to tell where to insert the fragment.

library

file structure

difference-by-value.xslt

test-difference-by-value.xslt

auto-sufficient stylesheet

difference by string value of first-level elements of trees in $v1 and $v2. Outputs a list of nodes in $v1 not having same string value as one of $v2 .

library

string, set

make-words-list.xslt

test-make-words-list.xslt: auto-sufficient stylesheet

from a whitespace-separated string, outputs an sorted list of unique words occuring in $string .

library

string

XMLSchemac++.xslt

sampleXMLSchema.xml

generates C++ declarations from a XML Schema

proof of concept

XML_Schema

XMLSchema.cpp

XMLSchema2Example.xslt

sampleXMLSchema.xml

XML Schema ==> typical instance of XML document (not yet updated to XML Schema Recommandation)

proof of concept

XML_Schema

instanceFromSchema.xml

XMLSchema2DTD.xslt

sampleXMLSchema.xml

XML Schema ==> DTD 

proof of concept

XML_Schema

DTDFromSchema.dtd

XMLSchema2GUI.xslt

sampleXMLSchema.xml

XML Schema ==> HTML GUI (not yet updated to XML Schema Recommandation)

proof of concept

XML_Schema

GUIFromSchema.xml

example2Schema.xslt

relationalDB.xml

From any XML, make a skeleton for an XML Schema; also offers statistics about number of elements NEW

production

XML_Schema

skeletonSchema.xml

SQL-join.xslt

relationalDB.xml

How to do in XSLT the equivalent of a SQL join

pedagogical

reference

join.xml

Mathml2c.xslt

sphere.MathML.xml

generate C++ code from MathML declarations representing 3D geometry

proof of concept

MathML

sphere.cpp

substituteEltName.xslt

substituteEltName.xml

substitute occurences of element <e1> in namespace N1 into element <e2> in namespace N2

pedagogical

structure

substitutedElt.xml

To transform:
java -classpath /home/jars/saxon.jar com.icl.saxon.StyleSheet $*

Projects: