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

Posted on 2014-08-01
Last Modified: 2016-02-11
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="" xmlns:xs="" xmlns:fn="">
   <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?

Question by:Jim Horn
    LVL 9

    Accepted Solution

    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>
    LVL 65

    Author Closing Comment

    by:Jim Horn
    Bingo bango ... thanks

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now