[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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: "Kenny Akridge" <kakridge@xxxxxxxxxxxxx>
Date: Tue, 27 Jan 2004 14:20:35 -0500


This template will work with both of your html needs:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
<xsl:template match="page/links">


<xsl:template match="categories">
<xsl:if test="normalize-space(.)">
	Categories: <br/>

<xsl:template match="category">
	<xsl:value-of select="."/><br/>

<xsl:template match="database-links">
<xsl:if test="normalize-space(.)">	
	<p/>Database Links: <br/>

<xsl:template match="database-link">
	<xsl:value-of select="."/><br/>


<xsl:template match="website-links">
<xsl:if test="normalize-space(*/@filename)">	
	<p/>Website Links: <br/>

<xsl:template match="website-link">
	<xsl:value-of select="@filename"/><br/>



It is in rough form, but you really don't need any logic.  You should
get the gist of what is going on here though.

Let me know if you have any questions.

Kenny Akridge

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Bill Walker
Sent: Tuesday, January 27, 2004 1:31 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Which commands to use: xsl:if, xsl:when, xsl:choose,
xsl:otherwise ??


I have learned just enough XML and XSLT to think I
understand what I am doing. 

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





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

Here is my problem.

I am a librarian and am working on redesigning our
Library's website. Our plan is to group a lot of
information into 30 Subject Categories on the right
side of our opening screen.


So far so good.

Underlying this idea, our committee decided to make
every single link on each subject and sub-category
page a separate XML file.  For example, they all start
as Dublin Core and look like this:


Little by little we are beginning to do this. So each
Subject Opening page will look like this example:


This page was generated from:



For any page one level in we have a more simple page
that looks like this:


This is generated from a different XSL file and XML



This all works pretty well and 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.

So I simplified an XML file to include what needs to
be (or not be) on all pages which would look like

<?xml version="1.0" ?> 


filename="bureau-labor-stats.xml" /> 

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.

What I cannot figure out is how to make XSL look at
this XML file and process it sequentially.

If it is an opening page, it will crank out the
Categories, Databases and the Weblinks lists .

If it is one page further in, it would have only
web-links.  It would look the example below and,
finding no Categories And no Databases, it would just
list the Websites...

<?xml version="1.0" ?> 
                <category /> 

                <database-link /> 

filename="bureau-labor-stats.xml" /> 

Can someone please help me understand how to do this.

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.

I really appreciate the expertise available on this
list and heartily thank anyone who has been kind
enough to read this far and give my little task some

Thanking you all in advance.

--Bill Walker  
  Reference Dept.
  Stockton-San Joaquin County Public Library


Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

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

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

Current Thread