XLST can't handle an XML file with an element name with a space in it

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.

Here's the XML file, with element 'Compute Timestamp' on line 8
   <Compute Timestamp="2014-07-09 20:34:00">

Open in new window

Here's my in-progress XLST file, grabbing 'Compute Timestamp' on line 12
<?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: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:value-of select="Compute Timestamp" /><xsl:text>","</xsl:text>

Open in new window

The problem I'm having is that when I execute the SSIS package it returns the following error message on the XML Task:
[XML Task] Error: An error occurred with the following error message: "Expected end of the expression, found 'Timestamp'.".
Question:  Does anyone know how the code to handle this?

LVL 66
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAsked:
Who is Participating?
timestanmp is an attribute for the compute element
to get the attribute value you should do
Element/attribute. attribute is preceeded by @
so the following should do it for you
<xsl:value-of select="Compute/@Timestamp" /><xsl:text>","</xsl:text>
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAuthor Commented:
Bingo bango ... thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.