Re: [xsl] Newbie: easy one.

Subject: Re: [xsl] Newbie: easy one.
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 8 Jul 2003 15:09:42 +0100

> [xsl] Newbie: easy one.

giving threads titles like that doesn't really help people searching
the list archives.

You have several problems, all of which are covered in the FAQ for this
list at http://www.dpawson.co.uk

> <webapps xmlns:webapps="http://www.rudistarcevic.com";>
that is an element called webapps in namespace
http://www.rudistarcevic.com

> <xsl:for-each select="webapps

that would select an element called webapps in no namespace, so doesn't
select your element.

You want
<xsl:for-each select="w:webapps/w:website"

and add  xmlns:w="http://www.rudistarcevic.com"; to your xsl:stylesheet
element. 


> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>


You are not producing an FO document, you are producing HTML, so
you don't want xmlns:fo="http://www.w3.org/1999/XSL/Format";
it isn't doing anything except making your HTML invalid.

In the following I'll assume that you have changed all your xpaths to be
in the http://www.rudistarcevic.com namespace (otherwise nothing matches
at all)

> <xsl:for-each select="webapps/website">

so here ypur current nodes are website nodes and here

> <xsl:apply-templates/>

you are applying templates to the child nodes of that
the only child nodes are address nodes and white space text
but you don't have a template for those.

Your template
> <xsl:template match="webapps/website">

will never be applied (even if you changed it to

<xsl:template match="w:webapps/w:website">

so that it matched your elements as you never apply templates to
website elements.

I suspect you want



<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:w="http://www.rudistarcevic.com"; >

<xsl:template match="/">
<html>
<head><title>Web applications list</title></head>
<body>
<xsl:for-each select="w:webapps/w:website">
 <table border="1" summary="Web Application Table">
 <tr>
  <td>Site Name:</td>
  <td><xsl:value-of select="@name"/></td>
 </tr>

 <xsl:apply-templates/>

 </table>
 
</xsl:for-each>

</body>
</html>
</xsl:template>

<xsl:template match="w:address">
 <tr>
  <td>URL:</td>
  <td><xsl:value-of select="address"/></td>
 </tr>
</xsl:template>

</xsl:stylesheet>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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


Current Thread