XSLT <xsl:namespace-alias> 元素
定義和用法
<xsl:namespace-alias> 元素用於把樣式表中的命名空間替換為輸出中不同的命名空間。
注意: <xsl:namespace-alias>是頂層元素(top-level element),且必須是<xsl:stylesheet>或<xsl:transform>的子節點。
語法
<xsl:namespace-alias
stylesheet-prefix="prefix|#default"
result-prefix="prefix|#default"/>
stylesheet-prefix="prefix|#default"
result-prefix="prefix|#default"/>
屬性
属性 | 值 | 描述 |
---|---|---|
stylesheet-prefix | prefix #default |
必需。规定您希望更改的命名空间。 |
result-prefix | prefix #default |
必需。为输出规定期望的命名空间。 |
實例1
前綴wxsl 在輸出中被轉換為前綴xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wxsl="http://www.w3cschool.cc/w3style.xsl">
<xsl:namespace-alias stylesheet-prefix="wxsl" result-prefix="xsl"/>
<xsl:template match="/">
<wxsl:stylesheet>
<xsl:apply-templates/>
</wxsl:stylesheet>
</xsl:template>
</xsl:stylesheet>
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wxsl="http://www.w3cschool.cc/w3style.xsl">
<xsl:namespace-alias stylesheet-prefix="wxsl" result-prefix="xsl"/>
<xsl:template match="/">
<wxsl:stylesheet>
<xsl:apply-templates/>
</wxsl:stylesheet>
</xsl:template>
</xsl:stylesheet>
完整的XSLT元素參考手冊