This is the mail archive of the mailing list .

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

newbie problem - writing XSL for an XML with namespaces.


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=">....</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=""; 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:

 XSL-List info and archive:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]