IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: dalby@sdu.dk
About
User Name: dalby@sdu.dk
Forum Rank: Newbie
Real Name:
Location Denmak
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Wednesday, December 4, 2019
Last Visit: Wednesday, December 4, 2019 4:23:26 PM
Number of Posts: 1
[0.01% of all post / 0.02 posts per day]
Avatar
Last 10 Posts
Topic: SQL Server generated inline xsd could not validate
Posted: Wednesday, December 4, 2019 4:20:32 PM
I have generated an XML with an inline xsd schema in in MS SQL Server. XML Spy cannot validate it

I get errror:

Unable to locate a reference to a supported schema type (DTD, W3C Schema) within this document instance.

but it is inline!?

Is SQL Server generating invalid XML?

Code:
<Drugs>
  <xsd:schema targetNamespace="Drugs.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" elementFormDefault="qualified">
    <xsd:import namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd" />
    <xsd:element name="row">
      <xsd:complexType>
        <xsd:attribute name="Case_No" type="sqltypes:int" use="required" />
        <xsd:attribute name="Drug_No" type="sqltypes:int" use="required" />
        <xsd:attribute name="TradeName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
              <xsd:maxLength value="30" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="ATCCode">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
              <xsd:maxLength value="8" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="GenericName">
          <xsd:simpleType>
            <xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
              <xsd:maxLength value="60" />
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:attribute>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <row xmlns="Drugs.xsd" Case_No="45" Drug_No="1" TradeName="XXXX" ATCCode="XXXX" GenericName="XXXX" />
  <row xmlns="Drugs.xsd" Case_No="1" Drug_No="1" TradeName="XXXX" ATCCode="XXXX" GenericName="XXXX" />
</Drugs>



I have used following SELECT in MSSQL:

Code:
SELECT  [Case_No]
        ,[Drug_No]
        ,[TradeName]
        ,[ATCCode]
        ,[GenericName]
    FROM [DrugsAahus]
    for xml raw, root('Drugs'),  XMLSCHEMA ('Drugs.xsd') 



Thanks in advance

Kind regards
Soeren

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.