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

newbie problem - writing XSL for an XML with namespace

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

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.

Thus
   <Invoice>....</Invoice>
works fine

but
   <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="/">
  <html>
   <head>
    <title>Hire Invoice</title>
   </head>
   <body class="Main">
     <xsl:apply-templates select="//Invoice" mode="inv_no"/>
     <br/>
     Invoice Date:
     <xsl:value-of select="//Invoice/InvoiceDate"/>
     <br/>
     <b>INVOICE TO:</b><br/>
     <xsl:apply-templates select="//Invoice/InvoiceTo/Address/descendant::*"/>
   </body>
  </html>
 </xsl:template>

 <xsl:template match="Invoice" mode="inv_no">
  <xsl:param name="Style" select="'inv_no'"/>
   <table>
     <tr>
      <td Align="Center">
       <b>INVOICE NO:</b>
      </td>
      <td>
       <b>
        <xsl:value-of select="SuppliersInvoiceNumber"/>
       </b>
      </td>
     </tr>
   </table>
 </xsl:template>
 <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(.,' ')"/>
     <br/>
    </xsl:if>
   </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>



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

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.