XML Source giving blues while fetching data
Hi All,
I have a webservice from which i need to populate my database tables.
As of now i have used a webservice task to fetch data from web service in an XMl file.
But this XML has Multiple Namespaces which is not supported by SSIS (Supports only single namespace).
So to overcome this issue i used XML task with opeartion type as "XSLT" And used following code in XSLT file:
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output
method="xml" indent="no" /> <xsl:template match="/|comment()|processing-instruction()"> <xsl:copy> <xsl:apply-templates /> </xsl:copy>
</xsl:template> <xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@*|node()" /> </xsl:element>
</xsl:template> <xsl:template match="@*"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="." /> </xsl:attribute>
</xsl:template> </xsl:stylesheet>
Using this i am able to generate a new XML file with Single NameSpace.
Now i have used XML SOurce which is using this new XML file and also generated XSD file.
But now the problem is that i am getting a long list in OUTPUT NAME(all the coulmn names individually and some other names like counter, sequence etc.) field when i click on Columns TAB of XML Source.
Please let me know how can i combine all these columns to populate a single table and where i am wrong.
August 13th, 2012 6:46am
you can change your XSLT in XML Task to combine elements or attributes together.
this is an example of XSLT to change structure of xml data ( you can flatten elements, or combine them and work with attributes as well):
http://www.rad.pasfu.com/index.php?/archives/21-XML-Task-Changing-Style-of-Data-XSLT.html
http://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
August 13th, 2012 7:03am
Thanks for the reply Reza.
Actually i have never before worked on XML and don't have any clue how to write XML code.
Can you please tell me if there is any general XSLT code which can
convert any XML with Multiple Namespaces to Single Namespace??
August 14th, 2012 12:07am
There is no general XSLT code, you should write your own code.
I found this to remove namespaces:
http://wiki.tei-c.org/index.php/Remove-Namespaces.xsl
But didn't try it. I prefer always to write my own XSLT, this is simple language but very powerful. you can learn it very fast and write queries as you like:
http://www.w3schools.com/xsl/
if you couldn't solve the problem finally, put your xml content here and I will help you more in detailshttp://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
August 14th, 2012 4:55pm
There is no general XSLT code, you should write your own code.
I found this to remove namespaces:
http://wiki.tei-c.org/index.php/Remove-Namespaces.xsl
But didn't try it. I prefer always to write my own XSLT, this is simple language but very powerful. you can learn it very fast and write queries as you like:
http://www.w3schools.com/xsl/
if you couldn't solve the problem finally, put your xml content here and I will help you more in detailshttp://www.rad.pasfu.com
August 14th, 2012 4:56pm
Thanks Reza.. I'll try to learn XSLT.. in case i'll face any issue i'll get back to you.
can i have your email id please?
Free Windows Admin Tool Kit Click here and download it now
August 15th, 2012 12:45pm
This is how my XML file looks like:
<?xml version="1.0" encoding="utf-16"?>
<RGDRWStatus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<StatusID xmlns="http://tempuri.org/">0</StatusID>
<StatusMessage xmlns="http://tempuri.org/">Successfully fetched the rows.</StatusMessage>
<dsRGRWData xmlns="http://tempuri.org/">
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name=" ID" type="xs:decimal" minOccurs="0" />
<xs:element name="Name" type="xs:string" minOccurs="0" />
<xs:element name="Age" type="xs:decimal" minOccurs="0" />
<xs:element name="Address" type="xs:string" minOccurs="0" />
<xs:element name="State" type="xs:string" minOccurs="0" />
<xs:element name="City" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
< ID>1100</ ID>
<Name>Manish</ Name >
< Age >10</ Age >
< Address >East Street, 24</ Address >
< State >DEFG</ State >
< City>Abcd</City>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
< ID>1100</ ID>
<Name>Manish</ Name >
< Age >10</ Age >
< Address >East Street, 24</ Address >
< State >DEFG</ State >
< City>Abcd</City>
</Table>
<Table diffgr:id="Table3" msdata:rowOrder="2">
< ID>1100</ ID>
< ID>1100</ ID>
<Name>Manish</ Name >
< Age >10</ Age >
< Address >East Street, 24</ Address >
< State >DEFG</ State >
< City>Abcd</City>
</Table>
<Table diffgr:id="Table4" msdata:rowOrder="3">
< ID>1100</ ID>
<Name>Manish</ Name >
< Age >10</ Age >
< Address >East Street, 24</ Address >
< State >DEFG</ State >
< City>Abcd</City>
</Table>
</NewDataSet>
</diffgr:diffgram>
</dsRGRWData>
</RGDRWStatus>
I tried to develop an XSLT filebut all i was getting is a blank XML file. Can you please help me in developing an XSLT file for this XML, so that the new XML has single Namespace. :(
August 16th, 2012 12:26am