First of all, my response so far did not in any way try to solve your xsi:nil problem, I was only addressing your validation problem.
If you need help with that xsi:nil problem then you need to provide details of your XML and XSLT.
As for validation, I don't use XML Spy but I have AltovaXML tools, the command line version of Altova's XSLT and XQuery engine.
With that engine I have no problems to validate the result of an XSLT transformation.
I will show you an example: Assume we have two XML input files, file1.xml looks as follows:
Code:
<root>
<baz>1</baz>
<baz>2</baz>
</root>
file2.xml as follows:
Code:
<root>
<baz>1</baz>
<baz>a</baz>
</root>
Then I have a schema schema1.xsd as follows:
Code:
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/2008/foo"
elementFormDefault="qualified">
<xs:element name="foo">
<xs:complexType>
<xs:sequence>
<xs:element name="bar" type="xs:int" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and a stylesheet sheet1.xsl as follows:
Code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://example.com/2008/foo"
version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:import-schema namespace="http://example.com/2008/foo" schema-location="schema1.xsd"/>
<xsl:template match="/root">
<foo xsl:validation="strict">
<xsl:apply-templates select="baz"/>
</foo>
</xsl:template>
<xsl:template match="baz">
<bar>
<xsl:apply-templates/>
</bar>
</xsl:template>
</xsl:stylesheet>
So what the stylesheet does is to transform one of the XML input documents to a result document and to validate that result against the schema. The schema requires the '{http://example.com/2008/foo}bar' element to be of type xs:int which will fail for the second input for the second element as that is not an integer but the string 'a'.
And in that case AltovaXML tools nicely reports
"Validation Error
Value 'a' is not allowed for element <bar>. at foo"
If you have problems specific to Altova software then you might also want to try an appropriate forum on Altova's website
http://www.altova.com/forum/forum_landingpage.aspx
--
Martin Honnen
Microsoft MVP - XML