OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML namespaces and XSLT



XSL, XSLT and XPath questions would be better posted to the following list:

   http://www.mulberrytech.com/xsl/xsl-list

There are a number of subscribers who would enthusiastically respond to 
such questions.

There is also an *excellent* FAQ at:

   http://www.dpawson.co.uk

At 01/04/30 12:15 +0200, Kris Vloeberghs wrote:
>I've got an XML file here wich makes use of two different namespaces.  This
>file has to be parsed by XSLT, but there seems to be a problem.
>
>example 1:
>...<xsl:template match="/">
>   <html><head><title>OAI</title></head>
>     <body><table width="80%" align="left" cellspacing="0" cellpadding="1"
>border="1">
>       <xsl:for-each select="GetRecord/record/metadata/dc">
>
>This works perfectly when I remove all namespace declarations from my source
>XML doc.

Then your source file elements are in *no* namespace, not in the default 
namespace.

>example 2: ==> the differences are in 'template match' and 'for-each'
>...
><xsl:template match="GetRecord/record/metadata">
>   <html><head><title>Open Archive Initiative</title></head>
>     <body><table width="80%" align="left" cellspacing="0" cellpadding="1"
>border="1">
>       <xsl:for-each select="dc">
>
>This version works with the original XML-doc, but all the HTML tags included
>in my XSLT-file seem to be ignored.
>
>So, no tables are generated.  All the
>data coming from the XML-doc are presented as one line.

Right ... because none of the template rules are being matched.

You have to remember that the use of no namespace prefix in an XPath 
expression will only select nodes in no namespace, not nodes in the default 
namespace.

If your source document has a namespace for the elements (even if the 
elements use the default namespace), then your XPath expressions *must* use 
namespace prefixes.

Try:

   <xsl:template match="n:GetRecord/n:record/n:metadata">

with the appropriate namespace declaration.

I hope this helps.

....................... Ken


--
G. Ken Holman                      mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.               http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0     +1(613)489-0999   (Fax:-0995)
Web site:     XSL/XML/DSSSL/SGML/OmniMark services, training, products.
Book:  Practical Transformation Using XSLT and XPath ISBN 1-894049-06-3
Article: What is XSLT? http://www.xml.com/pub/2000/08/holman/index.html
Next public instructor-led training:      2001-05-01,05-14,05-15,05-16,
-                       05-17,05-21,05-22,06-18,06-21,07-20,07-21,09-19

Training Blitz: 3-days XSLT/XPath, 2-days XSLFO in Ottawa 2001-06-18/22