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

using XSLT in SSIS XML Task

$
0
0

I develop SSIS (SQL Server Integration Services) solutions in Visual Studio, so I think this is the right place to ask this question.  (I posted something to the SSIS forum on Friday, but no one has replied yet; see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=648868&SiteID=1)

SSIS has an XML Task that I use to specify an XSLT "operation", which is basically an XML document and an XSLT stylesheet.  The stylesheet's job is simply to copy the XML document and add a single attribute (ihs_cats_seq) to one element type (kw); the value of the attribute should be its position within the content of its parent element (keywords).

I have some XSLT experience, and my simple stylesheet works under the Saxon XSLT processor, e.g. transforming this:

<keywords><kw>AERODYNAMICS</kw><kw>AMENDMENT</kw><kw>LOCATION</kw><kw>ORGANISATION</kw><kw>RECORD</kw><kw>SCHEDULE</kw><kwSERIES</kw></keywords>

into this:

<keywords><kw ihs_cats_seq="1">AERODYNAMICS</kw><kw ihs_cats_seq="2">AMENDMENT</kw><kw ihs_cats_seq="3">LOCATION</kw><kw ihs_cats_seq="4">ORGANISATION</kw><kw ihs_cats_seq="5">RECORD</kw><kw ihs_cats_seq="6">SCHEDULE</kw><kw ihs_cats_seq="7">SERIES</kw></keywords>

But under SSIS, every kw element gets an empty attribute value: ihs_cats_seq=""

Is there a problem with the position() XPath function, or with my use of it here:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="identity" match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="kw">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <xsl:attribute name="ihs_cats_seq" select="position()"/>
    <xsl:apply-templates select="node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>