Human Injection Laboratories

Textpattern XHTML Helpers Plugin


This is a plugin for Textpattern 4.5.4.



This plugin defines a number of tags to handle the differences between HTML and XHTML. With this Tags you can generate XML declarations, DOC types, namespaces, language attributes and content type meta tags. The difference to handwritten markup is the fallback to SGML based HTML instead of XHTML in case of user agents don’t accept XHTML.

XML Declaration

<txp:shs_xml_declaration/> generates a XML-Declaration when XHTML is accepted. Using this Tag the Mime-Type in the HTTP-Response is automaticly set to “appllication/xhtml+xml”.

Document Type Definition

The second tag <txp:shs_doctype /> generates a DTD-Declaration. You can select between different HTML and XHTML DTDs. With the attribute xhtmltype you can select the XHTML-DTD to generate if XHTML is acceped by the user agend. As a fallback you can spezifie an old HTML-DTD with the attribute htmltype.

The Following Values are accepted for both attributes:

Attribute Value DTD Declaration
html_4_transitional <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “”>
html_4_strict <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “”>
xhtml_1_0_transitional <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>
xhtml_1_0_strict <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “”>
xhtml_1_1 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “”>
xhtml_mathml_svg <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN” “”>
html5 <!DOCTYPE html>


<txp:shs_doctype html="html_4_strict" xhtml="xhtml_1_0_strict" />


With <txp:shs_namespace /> namespace declarations are generated if XHTML is accepted by the user agent. Otherwise, nothing is added to your page.

By default the XHTML namespace “” is printet out. In additional you can add SVG, MathML, XLink ore other namespace declarations by using the
attributes svg, mathml, xlink and other.

The Attributes svg, mathml and xlink can use as an boolean attributes. A Value of 0 hide the namspace declaration,
a value of 1 generates a declaration with a prefix of svg, m or xlink. Alterative you can set your own prefix as the attributes value: mathml="math".

With the Attribute other you can add additional namespaces to your page.

Use this Tag inside your <HTML> tag.


<html <txp:shs_namespace svg="1" mathml="math" other='exp=""' /> >

Language Attributes

<txp:shs_language /> generates the Attributes “xml:lang” and “lang” in XHTML mode and only “lang” in HTML mode.
The attributes value is set by the lang attribute of <txp:shs_language />.

You can use this Tag in your <HTML> tag.


<html <txp:shs_language lang="de"> >

Meta Tag: Content Type

Most Pages contains an <META> tag declaring the mime typ. With <txp:shs_content_type /> such a tag is generated.

In XHMTL mode it is application/xhtml+xml: <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />.

For Browsers acceptin HTML only it looks like <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

If you using HTMl5 you can also generate the simplified version <meta charset="UTF-8" /> by using the Attribute html5 with a value of “1”.

Use this tag in your <HEAD> tag.


   <txp:shs_content_type />
   <txp:shs_content_type html5="1" />

Conditional Tag

The content of the conditional tag <txp:shs_if_xhtml_accepted> is parsed if the user agend accept XHTML.


<txp:shs_xml_declaration />

<txp:shs_doctype htmltype="html_4_strict"
	xhtmltype="xhtml_1_0_strict" />

<html <txp:shs_namespace svg="1" mathml="math" other='exp=""' /> <txp:shs_language lang="de-DE" />>

   <txp:shs_content_type />

   <txp:else />



This software is licensed under the following GPL license:

 * Copyright 2011 Sebastian Spautz
 * Textpattern Webmention Plugin is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * see