XHTML Serializer

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"> <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>

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 – 2017 Hugh Field-Richards. All Rights Reserved.