Note that there are some explanatory texts on larger screens.

plurals
  1. POPrevent xmlns="" attribute from being added to HTML elements generated by XSLT 1.0
    text
    copied!<p>I am in the process of creating a template for phpdoc 2 and I am trying to figure out how to prevent the attribute <code>xmlns="http://www.w3.org/1999/xhtml"</code> from being added to the root level elements of the generated HTML when the documentation is created from my template. My .xsl files in the template generate files containing html fragments, which is why the <code>&lt;html&gt;</code> tag is not the root level element. It appears phpdoc 2 uses XSLT v1.0, so that limits my options a bit. After doing some searching, the most common answer was to use the <code>exclude-result-prefixes</code> attribute on the <code>&lt;xsl:stylesheet&gt;</code> tag of each .xsl file, and set its value to either <code>#all</code> or <code>#default</code>, since you cannot just use <code>xmlns</code> as a namespace to exclude directly. But I tried that, setting the <code>exclude-result-prefixes</code> on every .xsl file in my template, and it did not work.</p> <p>As requested, here's one of one of my .xsl files, api-doc.xsl:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="#all"&gt; &lt;xsl:output indent="no" method="html"/&gt; &lt;xsl:include href="chrome.xsl"/&gt; &lt;xsl:include href="api-doc/property.xsl"/&gt; &lt;xsl:include href="api-doc/class.xsl"/&gt; &lt;xsl:include href="api-doc/constant.xsl"/&gt; &lt;xsl:include href="api-doc/function.xsl"/&gt; &lt;xsl:include href="api-doc/docblock.xsl"/&gt; &lt;xsl:include href="api-doc/file.xsl"/&gt; &lt;xsl:template name="content"&gt; &lt;xsl:apply-templates select="/project/file[@path=$path]"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>This is a snippet of api-doc/file.xsl:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="#all"&gt; &lt;xsl:output indent="no" method="html"/&gt; &lt;xsl:template match="file"&gt; &lt;div class="text-content"&gt; &lt;!-- ... --&gt; &lt;/div&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>The element <code>&lt;div class="text-content"&gt;&lt;/div&gt;</code> is what has the <code>xmlns="http://www.w3.org/1999/xhtml"</code> attribute added to it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload