Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The second of the two articles below shows how to use an XLST file in SSIS to transform the XML source file into something you can use for your described purpose. I provide two XSLT file contents at the bottom.</p> <p><code>http://sqlserverpedia.com/blog/sql-server-bloggers/loading-xml-using-ssis/</code></p> <p><a href="http://blog.hoegaerden.be/2011/04/20/loading-complex-xml-using-ssis/" rel="nofollow">http://blog.hoegaerden.be/2011/04/20/loading-complex-xml-using-ssis/</a></p> <p>Repairs to listed data sample:</p> <p>1) Remove the space in what appears to be a comment at the beginning: '...xmldata/1/ xmldata.xsd...' to 'xmldata/1/xmldata.xsd'</p> <p>2) Add <code>&lt;/data&gt;&lt;/dataset&gt;</code> to the very end of the data.</p> <p>You can test it here (Hmmmm, it doesn't seem to work there!):</p> <p><code>http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&amp;xsltfile=cdcatalog</code></p> <p>Or add this as the second line of XML to test in IE by opening the XML file:</p> <pre><code>&lt;?xml-stylesheet type="text/xsl" href="Cognos.xsl"?&gt; </code></pre> <p>Look over the xslt listings carefully and note the differences in the 'output' element. Note that I needed to define in my XSLT file the namespace that was used in the XML file's 'dataset' element, and give it a name which I can use to prefix references to the nodes defined within 'dataset'. Assume case sensitivity matters everywhere because it probably does. Do some reading on XSLT elements at:</p> <p><a href="http://www.w3schools.com/xsl/" rel="nofollow">http://www.w3schools.com/xsl/</a></p> <p>Cognos.xsl to list contents as 'pipe' (vertical bar) delimited file. There will be an empty column at the end - due to the trailing delimiter - which you will need to ignore in your code that uses the file.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cog="http://developer.cognos.com/schemas/xmldata/1/"&gt; &lt;xsl:output method="text" encoding="UTF-8" indent="no" omit-xml-declaration="yes" /&gt; &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates select="cog:dataset/cog:metadata/cog:item"&gt; &lt;/xsl:apply-templates&gt; &lt;xsl:text&gt;&amp;#13;&amp;#10;&lt;/xsl:text&gt; &lt;xsl:apply-templates select="cog:dataset/cog:data/cog:row"&gt; &lt;/xsl:apply-templates&gt; &lt;/xsl:template&gt; &lt;xsl:template match="cog:dataset/cog:metadata/cog:item"&gt; &lt;xsl:value-of select="@name"/&gt; &lt;xsl:text&gt;|&lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;xsl:template match="cog:dataset/cog:data/cog:row"&gt; &lt;xsl:text&gt;&amp;#13;&amp;#10;&lt;/xsl:text&gt; &lt;xsl:apply-templates select="./cog:value"&gt; &lt;/xsl:apply-templates&gt; &lt;/xsl:template&gt; &lt;xsl:template match="cog:dataset/cog:data/cog:row/cog:value"&gt; &lt;xsl:value-of select="."/&gt; &lt;xsl:text&gt;|&lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Cognos.xsl to list contents as HTML table:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cog="http://developer.cognos.com/schemas/xmldata/1/"&gt; &lt;xsl:output method="html" encoding="UTF-8" indent="yes" /&gt; &lt;xsl:template match="/"&gt; &lt;html&gt;&lt;body&gt; &lt;table border="1"&gt;&lt;tr&gt; &lt;xsl:apply-templates select="cog:dataset/cog:metadata/cog:item"&gt; &lt;/xsl:apply-templates&gt; &lt;/tr&gt; &lt;xsl:text&gt;&amp;#13;&amp;#10;&lt;/xsl:text&gt; &lt;xsl:apply-templates select="cog:dataset/cog:data/cog:row"&gt; &lt;/xsl:apply-templates&gt; &lt;/table&gt; &lt;/body&gt;&lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:template match="cog:dataset/cog:metadata/cog:item"&gt; &lt;td&gt; &lt;xsl:value-of select="@name"/&gt; &lt;/td&gt; &lt;/xsl:template&gt; &lt;xsl:template match="cog:dataset/cog:data/cog:row"&gt; &lt;tr&gt; &lt;xsl:apply-templates select="./cog:value"&gt; &lt;/xsl:apply-templates&gt; &lt;/tr&gt; &lt;/xsl:template&gt; &lt;xsl:template match="cog:dataset/cog:data/cog:row/cog:value"&gt; &lt;td&gt; &lt;xsl:choose&gt; &lt;xsl:when test=". !='' and . !=' '"&gt; &lt;xsl:value-of select="." /&gt; &lt;/xsl:when&gt; &lt;xsl:when test=". =' '"&gt; &lt;xsl:text&gt;space&lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:text&gt;null&lt;/xsl:text&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/td&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>And, yes, you are all welcome for this concise collection of requirements, fixes, links, and techniques which I have spent nearly 14 hours researching. Maybe I will turn this in to an article.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload