我使用XSLT作为各种组件的“代码生成器”,包括其他XSLT。例如,我有一个查询为表生成MSSQL sys.columns行的XML输出,并且希望生成一个XSLT,其中包含一个包含每行的列的表。Xslt生成Xslt:设置根名称空间
所以我想产生以下XSLT:
<xsl:stylesheet version="1.0" xmlns:format="urn:qbo3-formatting" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
...
</xsl:stylesheet>
我产生上面这样的 '发电机' XSLT的XSLT:
<xsl:element name="xsl:stylesheet">
<xsl:attribute name="version">1.0</xsl:attribute>
<xsl:attribute name="format" namespace="http://www.w3.org/XML/1998/namespace" >urn:qbo3-formatting</xsl:attribute>
...
</xsl:element>
的问题是,这个 '发电机' XSLT产生:
<xsl:stylesheet version="1.0" xml:format="urn:qbo3-formatting" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
...
</xsl:stylesheet>
注意xml:format
而不是所需的xmlns:format
。
根据W3C的说法,'xmlns'被保留并绑定到'http://www.w3.org/2000/xmlns/'。如果我试图创建上面使用这个命名空间的格式属性,我得到一个错误:
Elements and attributes cannot belong to the reserved namespace 'http://www.w3.org/2000/xmlns/'.
任何建议上一个变通?
由于提前,
埃里克
正是我所需要的;非常感谢! –
@EricPatrick:不客气。 –