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

Subject: [xsl] Which commands to use: xsl:if, xsl:when, xsl:choose, xsl:otherwise ??
From: Bill Walker <williamewalker@xxxxxxxxx>
Date: Tue, 27 Jan 2004 10:31:24 -0800 (PST)
Hi

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:

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?

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?

http://www.stockton.lib.ca.us/new_webroot/index.htm

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:

http://www.stockton.lib.ca.us/xml_xsl_html_samples/bureau-labor-stats.xml

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

http://www.stockton.lib.ca.us/new_webroot/statistics/stat-openpg.htm

This page was generated from:

http://www.stockton.lib.ca.us/xml_xsl_html_samples/stat-openpg.xsl

http://www.stockton.lib.ca.us/xml_xsl_html_samples/stat-openpg.xml

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

http://www.stockton.lib.ca.us/new_webroot/statistics/stat-gensit.htm

This is generated from a different XSL file and XML
file:

http://www.stockton.lib.ca.us/xml_xsl_html_samples/stat-secondpage.xsl

http://www.stockton.lib.ca.us/xml_xsl_html_samples/stat-gensit.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
this:

<?xml version="1.0" ?> 
  <page>
      <links>
          <categories>
              <category>Metaphysics</category> 
          </categories>

          <database-links>
              <database-link>InfoTrac</database-link> 
          </database-links>

          <website-links>
               <website-link
filename="bureau-labor-stats.xml" /> 
          </website-links>
       </links>
    </page>


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" ?> 
   <page>
       <links>
           <categories>
                <category /> 
           </categories>

           <database-links>
                <database-link /> 
           </database-links>

           <website-links>
               <website-link
filename="bureau-labor-stats.xml" /> 
           </website-links>
       </links>
  </page>

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
consideration?

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!
http://webhosting.yahoo.com/ps/sb/

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


Current Thread