XHTML Serializer

Warning
Note that this is a change from all versions prior to 1.13.0.

XHTMLSerializers are similar to the HTMLSerializer except that they produce valid XHTML as an XML document. For example:

<map:components> ... <map:serializers default="xml"> <map:serializer name="xhtml" mime-type="text/html" src="resource://lib/serialization/XHTMLSerializer"> <map:property name="doctype-public" value="-//W3C//DTD XHTML 1.0 Transitional//EN"/> <map:property name="doctype-system" value="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <map:property name="encoding" value="UTF-8"/> </map:serializer> </map:serializers> </map:components> <map:pipelines> <map:pipeline> <map:match pattern="*.html"> <!-- generate --> <!-- some transformations --> <map:serialize type="html"/> </map:match> </map:pipeline> </map:pipelines>

Again, given a suitable HTML input this would produce:

<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- Remaining head tags from DOM --> </head> <body> <!-- Remaining body tags from DOM --> </body> </html>

A typical use of the serializer would be:

<map:components> ... <map:serializers default="xml"> <map:serializer name="xhtml" src="resource://lib/serialization/XHTMLSerializer"> <doctype-public>-//W3C//DTD XHTML 1.0 Strict//EN</doctype-public> <doctype-system>http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</doctype-system> <encoding>iso-8859-1</encoding> </map:serializer> </map:serializers> </map:components> <map:pipelines> <map:pipeline> <map:match pattern="*.html"> <!-- generate --> <!-- some transformations --> <map:serialize type="html"/> </map:match> </map:pipeline> </map:pipelines>
Copyright 2006 – 2023 Hugh Field-Richards. All Rights Reserved.