Re: MSXML 3.0 XSLT. Does it work?

Subject: Re: MSXML 3.0 XSLT. Does it work?
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Wed, 12 Jul 2000 10:17:59 +0100
Sotiris

>here is an example of my XML code and style sheet and the results in
>produces using MSXML 3.0.

Your problem lies in your use of namespaces.  In your XML document, you
have defined the default namespace (the one without a prefix) to be
"urn:schemas-microsoft-com:xml-data" in:

<SearchSet xmlns="urn:schemas-microsoft-com:xml-data"
           xmlns:dt="urn:schemas-microsoft-com:datatypes" 
           xmlns:plss="urn:ctl.com:plss">

In your stylesheet, on the other hand, the only namespace declaration you
have made is about the XSLT namespace
("http://www.w3.org/1999/XSL/Transform";).  That means that when you match
on an element name within a template, e.g.:

<xsl:template match="SearchSet">
  ...
</xsl:template>

The XSLT processor is looking for a 'SearchSet' element that is not in a
namespace (or is in the namespace "" - somebody want to tell me what the
correct technical term is?).  This *doesn't* match the 'SearchResults' or
any other elements in your XML document because they are in the
"urn:schemas-microsoft-com:xml-data" namespace.  Without that match, only
the built-in templates are processed, which means that the output consists
of the textual content of the elements in your XML document (the
'PL00000990' and so on).

You have two good options (and a bad one that involves searching on the
local part of the element name):

1. take out the default namespace declaration in the XML document, or give
the xml-data namespace a prefix - this is the best option if
'SearchResults' and the other elements are *not* actually defined within
the Microsoft XML-Data schema

2. declare the default namespace in the stylesheet to be
"urn:schemas-microsoft-com:xml-data" using:

  <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                  xmlns="urn:schemas-microsoft-com:xml-data">
  ...
  </xsl:stylesheet>

This is the best option if 'SearchResults' and the other elements *are*
actually defined within the Microsoft XML-Data schema.

I hope that helps,

Jeni

Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email
jeni.tennison@xxxxxxxxxxxxxxxx



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread