Here is how this can be done:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="xsi">
<xsl:output omit-xml-declaration="yes"/>
<!-- -->
<xsl:template match="/">
<exercises xsi:noNamespaceSchemaLocation="mySchema.xsd"/>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on any source XML document (not used), the wanted result is produced:
<exercises xsi:noNamespaceSchemaLocation="mySchema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
It is not necessary to use <xsl:attribute>
in your case, however if necessary, it can be used without any problem:
<xsl:attribute name="xsi:noNamespaceSchemaLocation">
<xsl:value-of select="'mySchema.xsd'"/>
</xsl:attribute>
Do note that it is a good practice to simply define the necessary namespaces at the <xsl:stylesheet>
element so that they can readily be (re)used everywhere they are needed. THis is especially useful, if a given namespace will be needed on more than one generated element or attribute.
In this case it is also good to specify all such prefixes in the value of the exclude-result-prefixes
attribute so that the namespaces will not be automatically propagated on all literal result elements.