从 XSL 创建 XSL [英] Create XSL from XSL
问题描述
我正在尝试从 XSLT 样式表动态生成 XSLT 文档.原则上这当然有效,但我没有让命名空间工作.我想让生成的 XSLT 元素以xsl"前缀为前缀:
I am trying to dynamically generate an XSLT document from an XSLT stylesheet. In principle this works, of course, but I do not get the namespaces working. I want to have the generated XSLT elements to be prefixed with "xsl" prefix:
<xsl:stylesheet ...>
而不是
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform">
我使用了 xsl:element 的 namespace="" 和 xsl:namespace 但我没有让它工作(xslt2/saxon 可用)
I played around with namespace="" of xsl:element and with xsl:namespace but I do not get it working (xslt2/saxon available)
有什么提示吗?
推荐答案
如果您想使用 XSLT 创建 XSLT 代码,请使用 http://www.w3.org/TR/xslt20/#element-namespace-alias 帮助例如
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>
这篇关于从 XSL 创建 XSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!