[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Doesn't see elements when using namespaces

Subject: Doesn't see elements when using namespaces
From: "Colin Simpson" <Colin.Simpson@xxxxxxxxxxxxxxx>
Date: Thu, 17 Aug 2006 13:10:30 +0100
gms xs
I am trying to use a very simple XSLT to convert an XML file into CSV
(Comma Separated Values).  However, I'm having difficulties which seems
to be due to the namespaces.  Using XML Spy 5.4, it never finds any
<CodingNoticesP6P6B> elements to process.  If I remove all the
namespaces and "ns0:" prefixes in the XML and XSL files, then it works
fine.

Here is a simplified XML file:

<?xml version="1.0" encoding="utf-8"?>
<ns0:DPSdata
xmlns:ns0="http://www.govtalk.gov.uk/taxation/DPSwrapper/1">
  <ns0:DataType>P6</ns0:DataType>
  <CodingNoticesP6P6B
        xmlns="http://www.govtalk.gov.uk/taxation/CodingNoticesP6P6B/2"
        xmlns:gt="http://www.govtalk.gov.uk/CM/core"
        xmlns:gms="http://www.govtalk.gov.uk/CM/gms-xs"
        IssueDate="2005-09-01">
    <Name>Alan Brown</Name>
    <TaxCode>123L</TaxCode>
  </CodingNoticesP6P6B>
  <CodingNoticesP6P6B
        xmlns="http://www.govtalk.gov.uk/taxation/CodingNoticesP6P6B/2"
        xmlns:gt="http://www.govtalk.gov.uk/CM/core"
        xmlns:gms="http://www.govtalk.gov.uk/CM/gms-xs"
        IssueDate="2005-09-01">
    <Name>Julie Green</Name>
    <TaxCode>345L</TaxCode>
  </CodingNoticesP6P6B>
</ns0:DPSdata>


Here is my XSL file:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
  xmlns:ns0="http://www.govtalk.gov.uk/taxation/DPSwrapper/1">
<xsl:output method="text" media-type="text/xml"
omit-xml-declaration="yes" encoding="UTF-8"/>

  <!-- This contains the character used as the end of line delimiter.
-->
  <xsl:variable name="CR" select=" '&#13;' "/>

  <!-- Start at the top level -->
  <xsl:template match="/">
    <xsl:apply-templates select="//ns0:DPSdata"/>
  </xsl:template>

  <!-- The header details -->
  <xsl:template match="ns0:DPSdata">
    <xsl:text>1,</xsl:text>
    <xsl:value-of select="ns0:DataType"/>
    <xsl:value-of select="$CR"/>
    <xsl:apply-templates select="//CodingNoticesP6P6B"/>
  </xsl:template>

  <!--- Process a P6/P6B -->
  <xsl:template match="CodingNoticesP6P6B">
    <xsl:call-template name="ExtractDetails"/>
  </xsl:template>

  <!-- Extract all the details for the P6/P9 -->
  <xsl:template name="ExtractDetails">
    <xsl:text>2,</xsl:text>
    <xsl:value-of select="@IssueDate"/>
    <xsl:text>,</xsl:text>
    <xsl:value-of select="Name"/>
    <xsl:text>,</xsl:text>
    <xsl:value-of select="TaxCode"/>
    <xsl:value-of select="$CR"/>
  </xsl:template>

</xsl:stylesheet>

Can anyone see what I'm doing wrong?

Thanks in anticipation.

Colin Simpson
************************************************************************

 Blue Arrow is official sponsor and recruitment partner of Team GB, the
 British Olympic Association and OPEN, the Olympic and Paralympic
 Employment Network.

 Your company can become a member of OPEN - the Olympic and Paralympic
 Employment Network today, for free - visit www.bluearrow.co.uk/OPEN

 Find out more about all Blue Arrow recruitment solutions - visit
 www.bluearrow.co.uk

************************************************************************


************************************************************************

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed.  If you have received this email in error please notify
the system manager.

************************************************************************

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.