Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

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?

Jim Horn
Jim Horn
1 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>
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAuthor Commented:
Bingo bango ... thanks

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now