introduction to xslt & its use in grainger library full-text & metadata projects thomas g....
TRANSCRIPT
![Page 1: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/1.jpg)
Introduction to XSLT & its use in Grainger Library full-text & metadata projects
Thomas G. HabingGrainger Engineering Library
Presentation to ASIS&T, 12 November 2003http://dli.grainger.uiuc.edu/ASIS_XSLT/ (soon)
![Page 2: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/2.jpg)
17 April 2003 Intro to XSLT at Grainger 2
XSL Transformations (XSLT)
XSLT 1.0 – W3C Recommendation (16 November 1999)
XSL FO 1.0 – W3C Recommendation (15 October 2001)
XSLT 2.0 – W3C Working Draft (2 May 2003)
Language for transforming XML to XML, HTML Map from one semantic scheme to another
(generally of equivalent or lesser granularity) E.g., map
<auth><sn>Cole</sn><fn>Tim</fn></auth> to
<creator>Tim Cole</creator>
![Page 3: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/3.jpg)
17 April 2003 Intro to XSLT at Grainger 3
XSL Transformations (XSLT) – 2
Examples: XML to XHTML MARC to Dublin Core ISO Math Markup to MathML
Normalize collection of heterogeneous markup Extract subset of a complete document(s) Open multiple XML documents simultaneously
Search across multiple XML documents Read XSD to decide how to transform an XML file
![Page 4: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/4.jpg)
17 April 2003 Intro to XSLT at Grainger 4
XSL Transformations (XSLT) – 3
Full-featured procedural programming language Flow control (e.g., looping & conditional branching) Variables, input parameters supported Basic string manipulation, numeric calculations Modularity, calls to external functions, recursion
External functions execute within constraints of transforming XML parser being used
Single XML document as output (1.0)
![Page 5: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/5.jpg)
17 April 2003 Intro to XSLT at Grainger 5
XSL Transformations (XSLT) – 4 Implemented by transforming XML parsers Transforms can be done server or client side
Newer browsers (IE5, Mozilla / Netscape 7) XSLT documents are themselves XML<xsl:template match='//author'> <xsl:element name='dc:creator'> <xsl:value-of select='lastname'/>
<xsl:text>, </xsl:text><xsl:value-of select='firstname'/>
</xsl:element ></xsl:template> Valuable for interoperability or reusability
![Page 6: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/6.jpg)
17 April 2003 Intro to XSLT at Grainger 6
XML Path Language (XPath)
XPath 1.0 – W3C Recommendation (16 November 1999)
XPath 2.0 – W3C Working Draft (22 August 2003)
Language for addressing parts of an XML file Data model for XML Includes tests, pattern matching
Used in XSLT to access DOM elements
![Page 7: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/7.jpg)
17 April 2003 Intro to XSLT at Grainger 7
XML Path Language (XPath) – 2
XPath expressions evaluate to atomic values, individual nodes, or collections of nodes
XPath is syntax for identify document nodes in XSLT
//dc:title dc:dc/dc:subject[3] dc:dc/dc:* marc:datafield[@tag=100] |
marc:datafield[@tag=110] marc:datafield[@tag=260]/marc:subfield[@code='c'] . substring(dc:title,5,10)
![Page 8: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/8.jpg)
17 April 2003 Intro to XSLT at Grainger 8
XSLT Examples
XSLT for Dublin Core XML to XHTML Ballads DC
XSLT for MARC21 XML to HTML Ballads MARC
XSLT for MARC21 XML to DC XML Ballads MARC to DC
XSLT to search multiple DC XML files Search 5 DC Records
![Page 9: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/9.jpg)
17 April 2003 Intro to XSLT at Grainger 9
ZVON Tutorial
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
http://www.zvon.org/xxl/XSLTutorial/Output/contents.html
![Page 10: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/10.jpg)
17 April 2003 Intro to XSLT at Grainger 10
XSL Tools
TIBCO XMLTransform MarrowSoft Xselerator Treebeard
JAXP (Java XML Transforming Parser) MSXML SDK MSXSL (Command line transformer) EXSLT
![Page 11: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/11.jpg)
17 April 2003 Intro to XSLT at Grainger 11
XSLT Where Should It Happen
Client-side IE5+ or Mozilla
IE5 not yet fully compliant w/ XSLT and XPath standard Can reduce the load on your servers But performance on low-end clients can be BAD
Server-side Performance could be a problem on busy
servers, serving large, complex documents More control and flexibility over the conversion
(metamerge) Offline Preconversion
Best performance Not good for dynamic documents (metamerge)
![Page 12: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/12.jpg)
17 April 2003 Intro to XSLT at Grainger 12
How We Use XSLT
Most tags are converted to HTML spans with a class attribute equal to the original tag name,i.e. <sect> becomes <span class=“sect”><xsl:template match=“*”> <span> <xsl:attribute name=“class”> <xsl:value-of select=“local-name()”/> </xsl:attribute> <xsl:apply-templates/> </span></xsl:template>
If the tag must be a block element, that is specified in the CSS: span.sect {display:block}
This improves the modularity of the code
![Page 13: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/13.jpg)
17 April 2003 Intro to XSLT at Grainger 13
How We Use XSLT (cont.)
Some tags require special conversion,i.e. <emph type=“1”> becomes <span class=“emph_1”><xsl:template match=“emph”> <span> <xsl:attribute name=“class”> <xsl:value-of select=“local-name()”/>_ <xsl:value-of select=“@type”/> </xsl:attribute> <xsl:apply-templates/> </span></xsl:template>
CSS: span.emph_1 {font-style:italic} span.emph_2 {font-weight:bold}
![Page 14: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/14.jpg)
17 April 2003 Intro to XSLT at Grainger 14
How We Use XSLT (cont.)
Some elements need to have punctuation added, i.e.<ag><au>Tom</au><au>Tim</au><au>Bob</au></ag> becomes Tom, Tim, Bob.<xsl:template match=“au[position() = last()]”> <span><xsl:call-template name=“class-attr”/> <xsl:apply-templates/>. </span></xsl:template>
<xsl:template match=“au[position() != last()]”> <span><xsl:call-template name=“class-attr”/> <xsl:apply-templates/>,  </span></xsl:template>
![Page 15: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/15.jpg)
17 April 2003 Intro to XSLT at Grainger 15
How We Use XSLT (cont.)
Some elements need their children rearrangedi.e. <au><sn>Habing</sn><fn>Tom</fn></au> becomes Tom Habing<xsl:template match=“au”> <span><xsl:call-template name=“class-attr”/> <xsl:apply-templates select=“fn”/>  <xsl:apply-templates select=“sn”/> </span></xsl:template>
‘Real’ DTDs can require some fairly complex processing. So far XSLT seems to be able to handle nearly every
case we have come across However, some cases have required JScript
extensions to XSLT
![Page 16: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/16.jpg)
17 April 2003 Intro to XSLT at Grainger 16
How We Use XSLT (cont.)
Some elements are converted into HTML elements other than <span> Elements representing figures or images are
converted to the <img src=“…”> tag. Elements representing internal links with ID and
IDREF attributes are usually converted into <a name=“…”></a> or <a href=“#…”>…</a> tags.
Table elements are converted into corresponding HTML <table>, <tr>, or <td> tags.
In all cases, a class attribute is added which is the original XML tag name; this is used in the CSS.
![Page 17: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/17.jpg)
17 April 2003 Intro to XSLT at Grainger 17
XSLT Demos
ASM Handbook article2.xsl asm_ie5_html.css
Summary of Engineering Research SER2FO.xsl
Dublin Core XML Schemas DCDD.xsl DCDD2.xsl test_dcterms.xml sampleDCDD2.xml
![Page 18: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/18.jpg)
17 April 2003 Intro to XSLT at Grainger 18
TEI and XSLT
XSL stylesheets for TEI XML XSL TEI HTML stylesheet
parameterization
![Page 19: Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,](https://reader036.vdocuments.mx/reader036/viewer/2022071806/56649db25503460f94aa19ea/html5/thumbnails/19.jpg)
17 April 2003 Intro to XSLT at Grainger 19
Extreme XSLT
http://fxsl.sourceforge.net/ http://www.topxml.com/code/?p=1&ms
=10&l=designpatterns&sw=categ http://www.schematron.com/