Re: why dosen't it read the xml info?

Subject: Re: why dosen't it read the xml info?
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Mon, 05 Jun 2000 18:24:12 +0100

First, you should tidy up your code so that it is well-formed (i.e. giving
an opening <a> tag just after the xsl:for-each and adding a closing </font>
tag).  These might just be copying errors, though, particularly as I'd have
thought you'd get a lot sterner warnings if you had these in your real

The source of your problem, though, is your use of namespaces.  Within your
source XML, you specify:

  <search xmlns="urn:schemas-microsoft-com:xml-data"

This states that the default namespace (i.e. the namespace for elements for
which no namespace is explicitly given) is
'urn:schemas-microsoft-com:xml-data'.  That means that the 'search'
element, and all its children, are within that namespace.

Within your stylesheet, though, you haven't specified those namespaces.
The stylesheet will look for a 'search' element with a null namespace, of
which there aren't any in your document.  There are three things that you
can do to make it work.  

Firstly, you can specify a named namespace within the stylesheet, and
specify that the elements you're searching for are within that namespace,

  <xsl:stylesheet xmlns:xsl="";

  <xsl:template match="/">
      <xsl:apply-templates select="data:search/data:type" />
      <xsl:value-of select="data:search/data:type" />
      <xsl:value-of select="data:search/data:auctions" /> sales


Secondly, you can specify that as the default namespace, but make sure that
all the html elements that you use are within an HTML namespace.  Then you
can use an xsl:namespace-alias element to make sure that your HTML elements
aren't namespaced within your output:

  <xsl:stylesheet xmlns:xsl="";

  <xsl:namespace-alias stylesheet-prefix="html" result-prefix="#default" />

  <xsl:template match="/">
      <xsl:apply-templates select="search/type" />
      <xsl:value-of select="search/type" />
      <xsl:value-of select="search/auctions" /> sales


Finally, you can think again about whether you need to specify namespaces
in your source document in the first place.

I hope that helps,


Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email

 XSL-List info and archive:

Current Thread