如何解决XSLT,向生成的xml文件的根节点添加属性
|| 我使用xslt将两个xml文件添加在一起,然后此生成的xml文件应符合架构。我可以将两个xml文件添加在一起,但是结果应该在根元素中具有noNamespaceSchemaLocation = \“ file:///osba.xsd \” ass属性。 这是我的.xsl文件:<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
<xsl:transform version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">
<xsl:output method=\"xml\" version=\"1.0\" encoding=\"ISO-8859-1\" indent=\"yes\" />
<xsl:variable name=\"with\" select=\"\'reception.xml\'\" />
<xsl:template match=\"@*|node()\" >
<xsl:copy>
<xsl:apply-templates select=\"@*|node()\" />
</xsl:copy>
</xsl:template>
<xsl:template match=\"bd\">
<xsl:copy>
<xsl:apply-templates select=\"@*|node()\" />
<xsl:variable name=\"info\" select=\"document($with)/reception/bd[title=current()/title]/.\" />
<xsl:for-each select=\"$info/*\">
<xsl:if test=\"name()!=\'title\'\">
<xsl:copy-of select=\".\" />
</xsl:if>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:transform>
我想添加类似以下内容:
<xsl:template match=\"/*\" >
<xsl:attribute name=\"noNamespaceSchemaLocation\"><![CDATA[file:///I:/IMY%20Project/XML%20Files/osba.xsd]]></xsl:attribute>
<xsl:apply-templates/>
如果当前元素是root,我还没有找到任何匹配的方法,但我还考虑在第一个xsl:template中放置xsl:if test = \“ root \”类型的交易。
谢谢你的帮助
解决方法
像这样:
“>
您的值 xsl:attribute>
xsl:element>
xsl:template>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。