This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: newbie problem - writing XSL for an XML with namespaces.
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] newbie problem - writing XSL for an XML with namespaces.
- From: "Julian Reschke" <julian dot reschke at gmx dot de>
- Date: Tue, 3 Jul 2001 15:34:10 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
See <http://www.greenbytes.de/xmlfaq.html#ANSWER-xslt-vs-namespaces>.
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Simon
> Champion
> Sent: Tuesday, July 03, 2001 3:27 PM
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] newbie problem - writing XSL for an XML with namespaces.
>
>
> 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
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list