Re: [xsl] Which commands to use: xsl:if, xsl:when, xsl:choose, xsl:otherwise ??

Subject: Re: [xsl] Which commands to use: xsl:if, xsl:when, xsl:choose, xsl:otherwise ??
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Jan 2004 14:37:05 -0500
At 2004-01-27 10:31 -0800, Bill Walker wrote:
I have learned just enough XML and XSLT to think I
understand what I am doing.

Congratulations!


However, when I am faced with something that takes
more logic and real understanding of such things as:

xsl:if

xsl:choose

xsl:when

xsl:otherwise

?I find I really don?t understand how to use them or
what is going on with the XSLT and the processing?

They are useful *within* a template ... sounds like you just need different sets of templates.


I COULD just go on and
create an XML and an XSL file for each page?

But I began thinking, "There must be a way using
xsl:if or xsl:when or xsl:choose or xsl:otherwise to
make it so I could have ONE and one only XSL file for
the whole site.

Not sure why this (a single XSLT file) is important to you ... is it a maintenance problem? Throwing the logic for documents conforming to multiple DTDs into a single stylesheet has its own maintenance challenges.


On brief review your vocabularies look mutually exclusive ... a single XSL stylesheet can support documents from multiple DTDs just by having the respective templates all in one stylesheet. When you have a vocabulary conflict you have to get into using modes, which starts with some of the challenges.

But if you write a push-oriented stylesheet then you can accommodate different document models with a single XSLT file.

But I'm not really sure why you want one stylesheet for everything. If you do have common templates, stylesheet modularization can done with <xsl:include/>.

The idea is that no matter whether I was generating an
opening Subject screen or a page further in, all the
info. I need should be in this XML file.

Why not modularize the common data, maintain it in a single location, and use the document() function to pull into your transform? That will improve your maintenance of your data without having copies of information in each XML file.


I have tried many ways, but it is clear that I still
don?t truly understand which commands are appropriate
and how to incorporate them into the XSL?

Separate <xsl:template> instructions sit there waiting to be fired by the <xsl:apply-templates/> that pushes nodes to the stylesheet. Since you have element types from different DTDs, you can just let the ones that do not apply sit there and never fire, and the ones that do apply actually get used.


I hope this helps.

................... Ken

  Reference Dept.
  Stockton-San Joaquin County Public Library

p.s. we are delivering XSL training in the San Francisco area the week of March 22 ... check out our home page for venue, pricing and registration details ... perhaps we can help you and your colleagues.



-- Public courses: sign up for one or both soon to reserve your seat! Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong, China: 2004-05-17 Bremen, Germany: 2004-05-24 World-wide on-site corporate, government & user group XML training

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


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



Current Thread