I am adding two xml files together using xslt, and then this resultant xml file should comply with a schema. I am able to add the two xml files together but then the result should have noNamespaceSchemaLocation="file:///osba.xsd" ass an attribute in the root element.
Here is my .xsl file:
<?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>
I want to add something like:
<xsl:template match="/*" >
<xsl:attribute name="noNamespaceSchemaLocation"><![CDATA[file:///I:/IMY%20Project/XML%20Files/osba.xsd]]></xsl:attribute>
<xsl:apply-templates/>
I have not found any way to match if the current element is root, I was also thinking of maybe putting an xsl:if test="root" type of deal in the first xsl:template.
Thanks for any help