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 \”类型的交易。 谢谢你的帮助     

解决方法

        像这样:              “>                          您的值