This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: why dosen't it read the xml info?
- To: YonitL at shopy dot co dot il
- Subject: Re: why dosen't it read the xml info?
- From: Jeni Tennison <Jeni dot Tennison at epistemics dot co dot uk>
- Date: Mon, 05 Jun 2000 18:24:12 +0100
- Cc: XSL-List at mulberrytech dot com
- Reply-To: xsl-list at mulberrytech dot com
Yonit,
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
stylesheet!
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"
xmlns:dt="urn:schemas-microsoft-com:datatypes">
...
</search>
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,
e.g.:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:data="urn:schemas-microsoft-com:xml-data">
<xsl:template match="/">
<html>
<body>
<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
...
</body>
</html>
</xsl:template>
</xsl:stylesheet>
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="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="urn:schemas-microsoft-com:xml-data">
<xsl:namespace-alias stylesheet-prefix="html" result-prefix="#default" />
<xsl:template match="/">
<html:html>
<html:body>
<xsl:apply-templates select="search/type" />
<xsl:value-of select="search/type" />
<xsl:value-of select="search/auctions" /> sales
...
</html:body>
</html:html>
</xsl:template>
</xsl:stylesheet>
Finally, you can think again about whether you need to specify namespaces
in your source document in the first place.
I hope that helps,
Jeni
Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 • Fax 0115 9061304 • Email
jeni.tennison@epistemics.co.uk
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list