troubleshooting Question

XSLT need a couple of fields added + quickie tutorial

Avatar of Jim Horn
Jim HornFlag for United States of America asked on
XML
5 Comments2 Solutions176 ViewsLast Modified:
Hi All

I'm building an SSIS package that consumes an XML file, then uses an XLST file to 'flatten' it into a single row.

Question:  How do I handle the elements not in the XLSD below?  Fuels-Unit,  All the Fuels-Costs values, and Dispatcher.

Here's the XML:
<FlightInfo>
    <FlightKey>
        <Alc>SCX</Alc>
        <Number>0117</Number>
        <STD>2014-06-30T11:00:00Z</STD>
        <OriginIcao>KMSP</OriginIcao>
    </FlightKey>
    <Compute Timestamp="2014-06-30 09:09:00">
        <Fuels Unit="LBS">
            <Pre>27151</Pre>
            <Release>10651</Release>
            <Tankerage>16500</Tankerage>
            <Burn>3830</Burn>
            <Arrival>22996</Arrival>
            <Costs>
                <Origin Currency="USD" Quantity="USG">3.11</Origin>
                <Destination Currency="USD" Quantity="USG">4.00</Destination>
                <Savings Currency="USD">2098.98</Savings>
            </Costs>
        </Fuels>
        <Dispatcher>NATHAN ROOD</Dispatcher>
    </Compute>
</FlightInfo>
Here's the XLSD, with the columns I was able to piece together..
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
   <xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
   
   <xsl:template match="/FlightInfo">
      <xsl:text>Alc,Number,STD,OriginIcao,Pre,Release,Tankerage,Burn,Fuel&#13;&#10;</xsl:text>
     
      <xsl:for-each select="FlightKey">
         <xsl:value-of select="Alc" /><xsl:text>","</xsl:text>
         <xsl:value-of select="Number" /><xsl:text>","</xsl:text>
         <xsl:value-of select="STD" /><xsl:text>","</xsl:text>
         <xsl:value-of select="OriginIcao" /><xsl:text>","</xsl:text>
      </xsl:for-each> 

      <xsl:for-each select="Compute/Fuels">
         <xsl:value-of select="Pre" /><xsl:text>","</xsl:text>
         <xsl:value-of select="Release" /><xsl:text>","</xsl:text>
         <xsl:value-of select="Tankerage" /><xsl:text>","</xsl:text>
         <xsl:value-of select="Burn" /><xsl:text>","</xsl:text>
         <xsl:value-of select="Arrival" /><xsl:text>","</xsl:text>
      </xsl:for-each> 
      
      <xsl:value-of select="/Compute/Dispatcher" /><xsl:text>","</xsl:text>
      
   </xsl:template>
</xsl:stylesheet> 
Thanks in advance.
Jim
ASKER CERTIFIED SOLUTION
zc2

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros