Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>XSLT has a special built-in feature that supports generating output, which is XSLT</strong> itself.</p> <p>This is the <strong><code>&lt;xsl:namespace-alias&gt;</code></strong> XSLT directive.</p> <p><strong>As explaiened by</strong> <a href="http://www.w3.org/TR/xslt#literal-result-element" rel="noreferrer"><strong>the XSLT 1.0 Spec</strong></a>.:</p> <p>"<pre> &lt;!-- Category: top-level-element --> &lt;xsl:namespace-alias stylesheet-prefix = prefix | "#default" result-prefix = prefix | "#default" /> </pre></p> <p>A stylesheet can use the <code>xsl:namespace-alias</code> element to declare that one namespace URI is an <strong>alias</strong> for another namespace URI. When a literal namespace URI has been declared to be an alias for another namespace URI, then the namespace URI in the result tree will be the namespace URI that the literal namespace URI is an alias for, instead of the literal namespace URI itself. The <code>xsl:namespace-alias</code> element declares that the namespace URI bound to the prefix specified by the <code>stylesheet-prefix</code> attribute is an alias for the namespace URI bound to the prefix specified by the <code>result-prefix</code> attribute. Thus, the <code>stylesheet-prefix</code> attribute specifies the namespace URI that will appear in the stylesheet, and the <code>result-prefix</code> attribute specifies the corresponding namespace URI that will appear in the result tree. "</p> <p><strong>Here is a small example of a transformation that generates an <code>xsl:stylesheet</code> containing an <code>xsl:variable</code>,</strong> which is constructed in the wanted way:</p> <pre> &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xxx="my:dummyNS" exclude-result-prefixes="xxx" > &lt;xsl:output omit-xml-declaration="yes" indent="yes"/> &lt;xsl:namespace-alias result-prefix="xsl" stylesheet-prefix="xxx"/> &lt;xsl:template match="/*"> &lt;xxx:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> &lt;xxx:variable name="{@name}"> &lt;xsl:value-of select="."/> &lt;/xxx:variable> &lt;/xxx:stylesheet> &lt;/xsl:template> &lt;/xsl:stylesheet> </pre> <p>When this transformation is applied on the following XML document:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;v name="myVarName"&gt;myValue&lt;/v&gt;</code></p> <p>the wanted result is produced:</p> <pre> &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> &lt;xsl:variable name="myVarName">myValue&lt;/xsl:variable> &lt;/xsl:stylesheet> </pre> <p><strong>Then the next step will be to launch in your "script" this dynamically generated XSLT transformation</strong>.</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