[
Lists Home |
Date Index |
Thread Index
]
Couple of questions...
why is your address infinitely recursive? [can your address really be
composed of an address?{when does it end? - it doesn't - it addresses all
the way to the bottom} ;)]
In your XML, area and city are encoded as attributes... yet your DTD says
they are elements. I'll assume your XML is correct... but this is why they
don't display for you...
In which case you could try something like this.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body style="font-family:Arial,helvetica,sans-serif;font-size:12pt">
<h2>My Restaurants Guide</h2>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="restaurant">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="name">
<xsl:value-of select="." />
</xsl:template>
<xsl:template match="address">
<br />
<xsl:value-of select="@str_name" />
<xsl:text> </xsl:text>
<xsl:value-of select="@str_number" />
<xsl:text>, </xsl:text>
<xsl:value-of select="@area" />
<xsl:text>, </xsl:text>
<xsl:value-of select="@city" />
</xsl:template>
<xsl:template match="kitchen">
<br />
<xsl:value-of select="." />
</xsl:template>
<xsl:template match="payment">
<br />
<xsl:value-of select="." />
</xsl:template>
</xsl:stylesheet>
Note that I modified your stylesheet to employed "push" processing rather
than "pull" processing .. which is tied less strongly to the detailed
structure of your document. I am utilizing rule-base design patterns ..
where the body of the template rule declares which nodes it is interested in
[address, kitchen, payment, etc.]...rather than the template rule for the
parent node defining in detail how its children should be processed. You
can read about rule based design patterns in detail in Michael Kay's XSLT
Programmers Reference text.
Cheers...Hugh
CyberSpace Industries 2000 Inc.
XML Training and Consulting
http://www.urbanmarket.com/csi2000
See our SmartCapital Initiatives at:
http://ato.smartcapital.ca/xml XML in Ottawa
http://ato.smartcapital.ca/perth Historic Perth Ontario
Visit Historic Perth Ontario at http://www.all-about-perth.com
See my first art exhibit on Mars at http://hugh-chatfield.com
>-----Original Message-----
>From: Binh Thang [mailto:binhthang@hotmail.com]
>Sent: Monday, February 23, 2004 11:45 AM
>To: xml-dev@lists.xml.org
>Subject: [xml-dev] help XML
>Hi everybody,
I am trying to create a simple xml. This is the way I want to display my
info in html:
Proeverij 272
>Prinsengracht 272, Jordaan, Amsterdam
>Dutch/International
>pin
>I have a DTD, a XML and a XSLT but somehow it doesn't display all the info
(the address info) I >want.
>Many thanx in advance,
>hbthang
- References:
- help XML
- From: "Binh Thang" <binhthang@hotmail.com>
|