SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Different ways to write XSL?

    I'm really new to XSL and it seems there are two different ways it can be done: 1) rule-based or templates and 2) procedural.

    I'm wondering when you would use one over the other. Most of the tutorials on the web seem to teach the template way, which seems fine and easy when you're just outputting simple data or need to output values over and over again.

    I have a web page that has quite a few nested tables and there's only one part of the page where I want to call up info from an XML file. I've had a really hard time trying to get it to work with templates - so is this a time when I should be doing it the procedural way? Is there a right and a wrong way?

  2. #2
    SitePoint Zealot JEmLAC's Avatar
    Join Date
    Apr 2002
    Location
    Kansas City
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a book by Deborah Kurata called "Doing Web Development: Client-Side Techniques" which I like a lot and she says this (where she says declarative, you say template-based):
    "Most anything you can do with the procedural approach you can also do with the declarative approach. Some developers say that "real programmers" don't use the procedural approach and that all XSLT stylesheets should be developed using the declarative approach."
    So it sounds like a mainly stylistic preference. Coming from a programming background, I'm comfortable with reading procedural-style code, although for large sheets I can see how this might get a bit messy. I'm still learning it myself and find myself occasionally "running home to mama" when I need to process a node only if it meets a certain criteria, but I am getting used to the XPath syntax, so hopefully I can move to using the declarative approach most/all of the time. As I see it, the "how" difference between the two approaches is much larger than the "what" difference.
    Morning person by habit, not by nature.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •