Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT, Add an attribute to the root node of the resultant xml file
    primarykey
    data
    text
    <p>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.</p> <p>Here is my .xsl file:</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes" /&gt; &lt;xsl:variable name="with" select="'reception.xml'" /&gt; &lt;xsl:template match="@*|node()" &gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()" /&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="bd"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()" /&gt; &lt;xsl:variable name="info" select="document($with)/reception/bd[title=current()/title]/." /&gt; &lt;xsl:for-each select="$info/*"&gt; &lt;xsl:if test="name()!='title'"&gt; &lt;xsl:copy-of select="." /&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;/xsl:transform&gt; </code></pre> <p>I want to add something like:</p> <pre><code>&lt;xsl:template match="/*" &gt; &lt;xsl:attribute name="noNamespaceSchemaLocation"&gt;&lt;![CDATA[file:///I:/IMY%20Project/XML%20Files/osba.xsd]]&gt;&lt;/xsl:attribute&gt; &lt;xsl:apply-templates/&gt; </code></pre> <p></p> <p>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.</p> <p>Thanks for any help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload