[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: cknell@xxxxxxxxxx Date: Tue, 27 Jan 2004 14:21:52 -0500 |
xsl:choose and xsl:if allow you to change the execution of the stylesheet depending on the outcome of the "test". You need to supply a value to test and something to test it against. The value to test could be the value of some node in the source file, or in a file included with the document() function, or a parameter passed to the stylesheet from the execution environment. You haven't said how the transformation is being accomplished. Is it done on the web server or on the web browser? Knowing the answer to this would get us closer to a solution. For example, if the transformation is being done on the server, a value from the query string could be passed as a parameter. Interpreting that value with xsl:choose could lead to selection of different subsets of the document using an XPath expression determined in the xsl:choose. If you have embedded a reference to a stylesheet in the XML document and you are depending on the browser to respond to user interface events, then you have to take another approach. -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Bill Walker <williamewalker@xxxxxxxxx> Sent: Tue, 27 Jan 2004 10:31:24 -0800 (PST) To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Which commands to use: xsl:if, xsl:when, xsl:choose, xsl:otherwise ?? 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 dont 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 Librarys 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 dont 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Multi-source documents: d, Randolph Kahle | Thread | RE: [xsl] Which commands to use: x, JWolpert |
RE: [xsl] Which commands to use: x, Kenny Akridge | Date | Re: [xsl] Empty object, scott gabelhart |
Month |