[xsl] newbie problem - writing XSL for an XML with namespaces.

Subject: [xsl] newbie problem - writing XSL for an XML with namespaces.
From: "Simon Champion" <spudley99@xxxxxxxxx>
Date: Tue, 03 Jul 2001 21:27:19 +0800

I'm still fairly new to this XML & XSL stuff, so please be patient with me. (I'm sure this is a really obvious question, but I'm absolutely stuck on it)

I have been given an XML document type to work with. It contains invoicing data, and our primary use for it will be passing it directly between two companies' software packages, but I also need to write XSLT stylesheets so that the same invoices can be viewed in a browser as well.

I've written an XSLT, which works well, but unfortunately it stops working as soon as I give it an XML that uses namespaces.

works fine

   <Invoice xmlns="urn:www.basda.org/schema/eBIS-XML_invoice_3.01.xml>....</Invoice>
gives me an empty page.

I've been unable to find the reason why this is happening. Other than the namespace, the two documents were identical, and The XSLT doesn't reference any namespaces (other than it's own), so why does it choke when there's a namespace in the file.

Please can someone explain why it's not working for me, and how I can sort it out.

Many (many, many,...) thanks!  :-)

    Simon Champion.
    MCS Ltd, Marlow, UK  --  "Software for the Rental Industry"

Here is a cut-down version of my XSLT, including the relevant bits (this version doesn't include much data, but does demonstrate the effect):

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
 <xsl:output method="html" version="4.0" omit-xml-declaration="yes" indent="yes"/>
 <xsl:template match="/">
    <title>Hire Invoice</title>
   <body class="Main">
     <xsl:apply-templates select="//Invoice" mode="inv_no"/>
     Invoice Date:
     <xsl:value-of select="//Invoice/InvoiceDate"/>
     <b>INVOICE TO:</b><br/>
     <xsl:apply-templates select="//Invoice/InvoiceTo/Address/descendant::*"/>

 <xsl:template match="Invoice" mode="inv_no">
  <xsl:param name="Style" select="'inv_no'"/>
      <td Align="Center">
       <b>INVOICE NO:</b>
        <xsl:value-of select="SuppliersInvoiceNumber"/>
 <xsl:template match="AddressLine">
  <xsl:param name="Style" select="'supp_addr'"/>
   <xsl:for-each select=".">
    <xsl:if test="string-length(.) > 0">
     <xsl:value-of select="concat(.,' ')"/>

PS - This XSLT I'm writing has to be able to display the invoices coming from several different sources, which may or may not include the namespace details, so I need a solution that will work in both cases. (To further complicate the issue, the invoice may (or may not) be wrapped inside another XML type - SOAP, Biztalk, etc - in which case it would definitely require namespaces - multiple namespaces even - but I haven't got that far yet)


Make PC-to-Phone calls with Net2Phone.
Sign-up today at: http://www.net2phone.com/cgi-bin/link.cgi?121

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread