Transforming TEI P5 with customized XSL

Here should go questions about transforming XML with XSLT and FOP.
kellner
Posts: 13
Joined: Wed Nov 02, 2005 1:39 am

Transforming TEI P5 with customized XSL

Post by kellner »

Hello,

I've generated TEI P5 files from the template included with oXygen. While I can transform them into html using the transformation scenario included with oXygen, which relies on TEI XSL stylesheets, I can't transform them with customized XSL stylesheets - the transformation is successful, but the stylesheet rules are not applied and I get only plain text output.

What could be wrong? Both the XML and the XSL validate, but the rules are just not applied. I've tried both Saxon and Xalan.

The TEI P5 file is wrapped in this structure:

Code: Select all

<?oxygen RNGSchema="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="xml"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
...
</TEI>
My stylesheet looks basically like this:

Code: Select all


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xd="http://www.pnp-software.com/XSLTdoc"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
xmlns:edate="http://exslt.org/dates-and-times"
xmlns:estr="http://exslt.org/strings"
xmlns:exsl="http://exslt.org/common"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:local="http://www.pantor.com/ns/local"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:teix="http://www.tei-c.org/ns/Examples"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
extension-element-prefixes="exsl estr edate"
exclude-result-prefixes="html xd exsl estr edate a fo local rng tei teix"
version="1.0">
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"></xsl:output>
<xsl:template match="TEI">
<html>
<head>

<link rel="stylesheet" href="skt.css" type="text/css"></link>

<title>
<xsl:value-of select="teiHeader/fileDesc/titleStmt/title"></xsl:value-of>
</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<!-- here follow all sorts of templates for generating the content of <body> -->

</xsl:stylesheet>


Any suggestions? Thanks!
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

One of the major changes in TEI P5 is that the elements belong to a namespace, that is "http://www.tei-c.org/ns/1.0". Your template matches TEI elements from no namespace while the document root TEI element belongs to the TEI P% namespace. Note that XPath 1.0 does not have a notion of default namespace so everything that does not have a prefix belongs to no namespace. You need to match on tei:TEI instead of TEI in your template and also add a prefix to any other element reference in XPath expressions that you may have in your stylesheet.

<xsl:template match="TEI">

-->

<xsl:template match="tei:TEI">

Best Regards,
George
kellner
Posts: 13
Joined: Wed Nov 02, 2005 1:39 am

Post by kellner »

Ah, thank you! Now it works perfectly.

Best regards,
Post Reply