Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

How to upload an XML file into our SQL database in SSIS?

$
0
0

I am a newbie with SSIS 2008 R2.  I have an XML and XSD file with the following structure that I am trying to upload in SSIS.  It's really basic what I'm trying to do, but I encountered a few problems.  First, in my XSD file I had the line:

<xs:complexType mixed="true">

It doesn't appear that SSIS accepts the complex type, so I changed this to false.  Also, I get several errors from this XSD file for various reasons.  The first few lines of this file are:

<?xml version='1.0' encoding='UTF-8'?>
<xs:schema targetNamespace="http://www.w3.org/2001/XMLSchema" blockDefault="#all" elementFormDefault="qualified" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="EN"
           xmlns:vs="http://schemas.microsoft.com/Visual-Studio-Intellisense">
  <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>

  <xs:complexType name="openAttrs">
    <xs:complexContent>
      <xs:restriction base="xs:anyType">
        <xs:anyAttribute namespace="##other" processContents="lax"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="annotated">
    <xs:complexContent>
      <xs:extension base="xs:openAttrs">
        <xs:sequence>
          <xs:element ref="xs:annotation" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="id" type="xs:ID"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:group name="schemaTop">
    <xs:choice>
      <xs:group ref="xs:redefinable"/>
      <xs:element ref="xs:element"/>
      <xs:element ref="xs:attribute"/>
      <xs:element ref="xs:notation"/>
    </xs:choice>
  </xs:group>

And the first few lines of my XML file are:

<?xml version="1.0" encoding="UTF-8"?> 
-<xs:schema version="1.0" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.tn.gov/mental/Schemas/CrisisAssessment" xmlns:mh="http://www.tn.gov/mental/Schemas/CrisisAssessment" xmlns:xs="http://www.w3.org/2001/XMLSchema"> -<xs:annotation> <xs:documentation>Schema name: CrisisAssessment</xs:documentation> </xs:annotation> -<xs:annotation> <xs:documentation>Crisis Assessment - File upload specification</xs:documentation> </xs:annotation> -<xs:element type="mh:ProviderType" name="Provider"> -<xs:annotation> <xs:documentation>Provider record is essentially a root element; so only need once per file</xs:documentation> </xs:annotation> </xs:element> -<xs:complexType name="F2FAssessmentType"> -<xs:annotation> <xs:documentation>F2F Assessment Data</xs:documentation> </xs:annotation> -<xs:sequence> -<xs:element type="xs:date" name="AssessmentDate"> -<xs:annotation> <xs:documentation>Assessment Date</xs:documentation> </xs:annotation> </xs:element> -<xs:element type="xs:time" name="ArrivalTime"> -<xs:annotation> <xs:documentation>Arrival Time</xs:documentation> </xs:annotation> </xs:element> -<xs:element name="ResidentialStatus"> -<xs:annotation> <xs:documentation>Residential Status</xs:documentation> </xs:annotation> -<xs:simpleType> -<xs:restriction base="xs:unsignedByte"> -<xs:enumeration value="1"> -<xs:annotation> <xs:documentation>Homeless</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="2"> -<xs:annotation> <xs:documentation>Foster Home/Foster Care</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="3"> -<xs:annotation> <xs:documentation>Residential Care</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="4"> -<xs:annotation> <xs:documentation>Crisis Residence</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="5"> -<xs:annotation> <xs:documentation>Institutional Setting</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="6"> -<xs:annotation> <xs:documentation>Jail/Correctional Facility</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="7"> -<xs:annotation> <xs:documentation>Private Residence-Independent Living</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="8"> -<xs:annotation> <xs:documentation>Private Residence-Dependent Living</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="9"> -<xs:annotation> <xs:documentation>Private Residence-living arrangement not available</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="10"> -<xs:annotation> <xs:documentation>Other Residential Status</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="11"> -<xs:annotation> <xs:documentation>With Family/Extended Family or non-relative</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration value="12"> -<xs:annotation> <xs:documentation>Unknown</xs:documentation> </xs:annotation> </xs:enumeration> -<xs:enumeration val


I know how to debug SQL code, but I don't have a clue about how to debug XML.  In SSIS, I created a package with an XML source and an OLE DB Destination.  I get this error now when I try to run this package:

Error at Data Flow Task [SSIS.Pipeline]: "output "annotation__appinfo__sequence_1" (3993)" contains no output columns. An asynchronous output must contain output columns.
Error at Data Flow Task [SSIS.Pipeline]: "output "annotation__documentation__sequence_1" (3999)" contains no output columns. An asynchronous output must contain output columns.
Error at Data Flow Task [SSIS.Pipeline]: One or more component failed validation.
Error at Data Flow Task: There were errors during task validation.
 (Microsoft.DataTransformationServices.VsIntegration)

Also, I tried selecting just one column to link these two data flow objects.

I chose all_element.  So how can I fix this for this to successfully import?  Are there any useful XML tutorials you can recommend for what I am trying to do?

I also got this warning in SSIS:

Warning at {176EF50E-7E06-475E-8450-93A4A37CECA6} [XML Source [1]]: No maximum length was specified for the output column "maxOccurs" (3186) with external data type System.String. The SSIS Data Flow Task data type "DT_WSTR" with a length of 255 will be used.

Warning at {176EF50E-7E06-475E-8450-93A4A37CECA6} [XML Source [1]]: No maximum length was specified for the output column "default" (3189) with external data type System.String. The SSIS Data Flow Task data type "DT_WSTR" with a length of 255 will be used.



Ryan D





Viewing all articles
Browse latest Browse all 935

Trending Articles