Create XSL from XSL

偶尔善良 提交于 2019-12-04 12:49:49

If you want to use XSLT to create XSLT code then using http://www.w3.org/TR/xslt20/#element-namespace-alias helps e.g.

<xsl:stylesheet
  version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  xmlns:axsl="file://namespace.alias">

<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>

<xsl:template match="/">
  <axsl:stylesheet version="2.0">
    <xsl:apply-templates/>
  </axsl:stylesheet>
</xsl:template>

<xsl:template match="elements">
  <axsl:template match="/">
     <axsl:comment select="system-property('xsl:version')"/>
     <axsl:apply-templates/>
  </axsl:template>
</xsl:template>

<xsl:template match="block">
  <axsl:template match="{.}">
     <fo:block><axsl:apply-templates/></fo:block>
  </axsl:template>
</xsl:template>

</xsl:stylesheet>

I found the solution:

<xsl:element name="xsl:stylesheet">
</xsl:element>

does the job! (i.e., avoid using namespace="" but explicitely list the namespace prefix)

Dimitre Novatchev

The xsl:namespace-alias instruction was designed having exactly this use case in mind -- just start using it in your work.

Here is a real-world example:

http://dnovatchev.wordpress.com/2006/10/21/a-stylesheet-to-write-xslt-code/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!