XmlTask validate action throws XmlSchemaException because of targetNamespace

Jun 24, 2011 at 10:20 PM

Trying to use the XmlTask's 'validate' action, I'm getting a XmlSchemaException reading 'The targetNamespace parameter '' should be the same value as the targetNamespace 'http://tempuri.org/schema.xsd' of the schema.'

The schema is generated from a database via Visual Studio (and thus does have a targetNamspace parameter), the xml files are hand-crafted. When using XmlLint I do not get any validation errors, e.g. using

xmllint --noout --schema schema.xsd data.xml

prints

data.xml validates

 

Is there anything I can do to make the XmlTask validate the xml file, too?

Coordinator
Jun 29, 2011 at 9:40 PM

Can you upload a repro?

Jul 4, 2011 at 3:52 PM

Can't figure up how to upload files; below, instead,  I post two code snippets: The first is the xml data file, the second is the schema. The latter is really ugly because it is a part of a VS generated DataSet.

If you put the first snippet e.g. in a file called "Abweichung.xml" and the second in "Abweichung.xsd" the command

    xmllint --noout --schema Abweichung.xsd Abweichung.xml

validates. The 'validate' action gives the previously posted error.

Sorry for the lengthy snippet.

 

Abweichung.xml:

 

<?xml version="1.0" standalone="yes"?>
<Abweichung xmlns="http://tempuri.org/Abweichung.xsd">
  <Abweichung>
    <id>1</id>
    <Nummer>010</Nummer>
    <Bezeichnung>Bezeichnung</Bezeichnung>
  </Abweichung>
</Abweichung>



Abweichung.xsd:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Abweichung" targetNamespace="http://tempuri.org/Abweichung.xsd" xmlns:mstns="http://tempuri.org/Abweichung.xsd" xmlns="http://tempuri.org/Abweichung.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:annotation>
    <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
      <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
        <Connections>
          <Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="SMUTConnectionString" ConnectionStringObject="" IsAppSettingsProperty="true" Modifier="Assembly" Name="SMUTConnectionString (Settings)" ParameterPrefix="@" PropertyReference="ApplicationSettings.DummyXsd.Properties.Settings.GlobalReference.Default.SMUTConnectionString" Provider="System.Data.SqlClient" />
        </Connections>
        <Tables>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="AbweichungTableAdapter" GeneratorDataComponentClassName="AbweichungTableAdapter" Name="Abweichung" UserDataComponentName="AbweichungTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="SMUTConnectionString (Settings)" DbObjectName="SMUT.dbo.Abweichung" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetData" UserSourceName="Fill">
                <DeleteCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="false">
                    <CommandText>DELETE FROM [dbo].[Abweichung] WHERE (([id] = @Original_id) AND ([Nummer] = @Original_Nummer) AND ([Bezeichnung] = @Original_Bezeichnung))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="id" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@Original_Nummer" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="Nummer" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@Original_Bezeichnung" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="Bezeichnung" SourceColumnNullMapping="false" SourceVersion="Original" />
                    </Parameters>
                  </DbCommand>
                </DeleteCommand>
                <InsertCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="false">
                    <CommandText>INSERT INTO [dbo].[Abweichung] ([Nummer], [Bezeichnung]) VALUES (@Nummer, @Bezeichnung);
SELECT id, Nummer, Bezeichnung FROM Abweichung WHERE (id = SCOPE_IDENTITY())</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@Nummer" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="Nummer" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@Bezeichnung" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="Bezeichnung" SourceColumnNullMapping="false" SourceVersion="Current" />
                    </Parameters>
                  </DbCommand>
                </InsertCommand>
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="false">
                    <CommandText>SELECT id, Nummer, Bezeichnung FROM dbo.Abweichung</CommandText>
                    <Parameters />
                  </DbCommand>
                </SelectCommand>
                <UpdateCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="false">
                    <CommandText>UPDATE [dbo].[Abweichung] SET [Nummer] = @Nummer, [Bezeichnung] = @Bezeichnung WHERE (([id] = @Original_id) AND ([Nummer] = @Original_Nummer) AND ([Bezeichnung] = @Original_Bezeichnung));
SELECT id, Nummer, Bezeichnung FROM Abweichung WHERE (id = @id)</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@Nummer" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="Nummer" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@Bezeichnung" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="Bezeichnung" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="id" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@Original_Nummer" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="Nummer" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@Original_Bezeichnung" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="Bezeichnung" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="false" AutogeneratedName="id" ColumnName="id" DataSourceName="" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@id" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="id" SourceColumnNullMapping="false" SourceVersion="Current" />
                    </Parameters>
                  </DbCommand>
                </UpdateCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="id" DataSetColumn="id" />
              <Mapping SourceColumn="Nummer" DataSetColumn="Nummer" />
              <Mapping SourceColumn="Bezeichnung" DataSetColumn="Bezeichnung" />
            </Mappings>
            <Sources />
          </TableAdapter>
        </Tables>
        <Sources />
      </DataSource>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Abweichung" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:EnableTableAdapterManager="true" msprop:Generator_DataSetName="Abweichung" msprop:Generator_UserDSName="Abweichung">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Abweichung" msprop:Generator_TableClassName="AbweichungDataTable" msprop:Generator_TableVarName="tableAbweichung" msprop:Generator_TablePropName="_Abweichung" msprop:Generator_RowDeletingName="AbweichungRowDeleting" msprop:Generator_UserTableName="Abweichung" msprop:Generator_RowChangingName="AbweichungRowChanging" msprop:Generator_RowEvHandlerName="AbweichungRowChangeEventHandler" msprop:Generator_RowDeletedName="AbweichungRowDeleted" msprop:Generator_RowEvArgName="AbweichungRowChangeEvent" msprop:Generator_RowChangedName="AbweichungRowChanged" msprop:Generator_RowClassName="AbweichungRow">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnVarNameInTable="columnid" msprop:Generator_ColumnPropNameInRow="id" msprop:Generator_ColumnPropNameInTable="idColumn" msprop:Generator_UserColumnName="id" type="xs:int" />
              <xs:element name="Nummer" msprop:Generator_ColumnVarNameInTable="columnNummer" msprop:Generator_ColumnPropNameInRow="Nummer" msprop:Generator_ColumnPropNameInTable="NummerColumn" msprop:Generator_UserColumnName="Nummer">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="4" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="Bezeichnung" msprop:Generator_ColumnVarNameInTable="columnBezeichnung" msprop:Generator_ColumnPropNameInRow="Bezeichnung" msprop:Generator_ColumnPropNameInTable="BezeichnungColumn" msprop:Generator_UserColumnName="Bezeichnung">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="100" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
    <xs:unique name="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:Abweichung" />
      <xs:field xpath="mstns:id" />
    </xs:unique>
  </xs:element>
</xs:schema>

 

Coordinator
Jul 28, 2011 at 10:17 PM

Thanks for the repro. This is a limitation of the task. I'm adding support for TargetNamespace in the next release.

Coordinator
Jul 28, 2011 at 10:18 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jul 28, 2011 at 10:45 PM

This is now resolved. you can recompile the code or wait for the next release.

Thanks for reporting the issue.