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>&#60;</td><td>&lt;</td></tr> <tr><td>gt</td><td>&#62;</td><td>&gt;</td></tr> <tr><td>ndash</td><td>&#x2013;</td><td>&ndash;</td></tr> <tr><td>mdash</td><td>&#x2014;</td><td>&mdash;</td></tr> <tr><td>oslash</td><td>&#248;</td><td>&oslash;</td></tr> <tr><td>ccedil</td><td>&#231;</td><td>&ccedil;</td></tr> <tr><td>frac13</td><td>&#x2153;</td><td>&frac13;</td></tr> <tr><td>ltri</td><td>&#x25C3;</td><td>&ltri;</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 – 2023 Hugh Field-Richards. All Rights Reserved.