[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: help XML


binhthang

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@h...]
>Sent: Monday, February 23, 2004 11:45 AM
>To: xml-dev@l...
>Subject:  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@h...>

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.