EntityTransformer
The EntityTransformer provides a mechanism of expanding
Entities within the DOM. It is declared and used as
<map:transformers default="xslt">
<map:transformer name="xslt" src="resource://lib/transforming/TRAXTransformer">
<map:use-request-parameters>true</map:use-request-parameters>
</map:transformer>
<map:transformer name="ent" src="resource://lib/transforming/EntityTransformer"/>
</map:transformers>
...
<map:pipeline>
<map:match pattern="**.html">
<map:generate src="context://content/{1}.xml" label="content-xml"/>
<map:transform type="ent"/>
<map:transform src="context://resources/transforms/page2html.xsl" label="transform-xml"/>
<map:serialize type="xhtml"/>
</map:match>
Note
In versions after 1.3.4 implicit entities defined by ISOlat1, ISOpub and ISOnum are
translated into their numerical form by the appropriate generator, FileGenerator and PXTemplateGenerator. The
EntityTransformer now only handles explictly declared
entities within a DOCTYPE statement within the XML
file.
As an example using the sitemap above consider the following XHTML input document:
test-1.xml
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
[
<!ENTITY testTitle "Entity Test 1" >
] >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Entity Test 1</title>
<style>
body { background-color: white; color: black; font-family: monospace; font-size: 14pt; }
td { text-align: center; }
</style>
</head>
<body>
<h1>&testTitle;</h1>
<table border="1" width="200px">
<tr><th>Name</th><th>Decimal</th><th>Name</th></tr>
<tr><td>lt</td><td><</td><td><</td></tr>
<tr><td>gt</td><td>></td><td>></td></tr>
<tr><td>ndash</td><td>–</td><td>–</td></tr>
<tr><td>mdash</td><td>—</td><td>—</td></tr>
<tr><td>oslash</td><td>ø</td><td>ø</td></tr>
<tr><td>ccedil</td><td>ç</td><td>ç</td></tr>
<tr><td>frac13</td><td>⅓</td><td>⅓</td></tr>
<tr><td>ltri</td><td>◃</td><td>◃</td></tr>
</table>
</body>
</html>
All the implicit entities lt, gt,
ndash, mdash, oslash, ccedil, frac13 and
ltri, are handled by
the generator pipeline component. Only the explicit entitiy, testTitle is
handled by the EntityTransformer.
Running the above through a suitable serializer will display as:
Copyright 2006 – 2024 Hugh Field-Richards. All Rights
Reserved.