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 :
Other similar ressources:
http://IncrementalDevelopment.com/xsltrick/ the extreme XSLT
http://xsltsl.sourceforge.net/ "standard XSLT library" : low-level templates like tokenizing strings, etc
http://www.exslt.org/ extension functions for XSLT
I strongly recommend Michael Kay's book (the author of the Saxon processor), whose sources can be downloaded from wrox.com .
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 |
---|---|---|---|---|---|
from HTML table to XML; generates XML tags from first row <th> tags UPDATED |
production |
XHTML |
|||
selects a given tag according to the content of a subelement |
pedagogical |
query |
|||
selects only given tag at any embedding level, and its content recursively |
pedagogical |
query |
|||
identity transform |
pedagogical |
||||
identity transform 2 : a good starting point to write XSLT transforms |
design pattern |
||||
suppress empty elements (i.e. elements with no text content) |
production |
structure |
|||
extract href attributes; example of text mode output |
pedagogical |
XHTML |
|||
replace attributes with elements; reuses identity transform 2 |
production |
structure |
|||
split named first-level elements into files (XSLT 1.1) NEW |
pedagogical |
file structure |
one file per first-level element |
||
merge after last first-level element of document at URL $main all first-level elements of input document . |
production |
file structure |
|||
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 |
|||
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 |
||
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 |
||
generates C++ declarations from a XML Schema |
proof of concept |
XML_Schema |
|||
XML Schema ==> typical instance of XML document (not yet updated to XML Schema Recommandation) |
proof of concept |
XML_Schema |
|||
XML Schema ==> DTD |
proof of concept |
XML_Schema |
|||
XML Schema ==> HTML GUI (not yet updated to XML Schema Recommandation) |
proof of concept |
XML_Schema |
|||
From any XML, make a skeleton for an XML Schema; also offers statistics about number of elements NEW |
production |
XML_Schema |
|||
How to do in XSLT the equivalent of a SQL join |
pedagogical |
reference |
|||
generate C++ code from MathML declarations representing 3D geometry |
proof of concept |
MathML |
|||
substitute occurences of element <e1> in namespace N1 into element <e2> in namespace N2 |
pedagogical |
structure |
To transform:
With Saxon (http://users.iclway.co.uk/mhkay/saxon/):
java -classpath /home/jars/saxon.jar com.icl.saxon.StyleSheet $*
With XT
type on a Windows NT command window:
xt Data XSLT
or
xt Data XSLT result
xt is a command-line (or Java) XSLT processor available from www.jclark.com .
Projects:
table_2_columns2XML.xslt : generate XML markup from HMTL table with field name and value
XMLSchmema2DTD.xslt : generate DTD from XML Schema
implement Xinclude
wrapParags.xslt : wrap HTML paragraphs in docBook:simplesec elements
mathDiffer.xslt: differentiate an expression in MathML
[tentative] RDF Schema <==> XML Schema
XML Fragment FCS (Fragment Context Specification) ==> XPath expression
symetries, rotations, and other simple geometrical transforms for SVG (W3C's Scalable Vector Graphics); also user transforms defined by 2 expressions in $x and $y