[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: testing for existence of content before processing
Terry,
I don't think your effort is so bad. It seems your rules are something like: Always want a pretest with the first item Always want a posttest with the last item Always want a review with a "Lab" item If no "Lab" item is present, place a review with the penultimate item So: <xsl:when test="position()=1"> <!--place pretest--> </xsl:when> <xsl:when test="position()=last()"> <!--place posttest--> </xsl:when> <xsl:when test="title = 'Lab' or ((position()=last()-1) and not(../*/title='Lab')"> <!--place review--> </xsl:when> <xsl:otherwise> <!--place generic row info--> </xsl:otherwise> I can imagine refactoring this, and I have a concern about edge cases. (What if the Lab appears last?) I also suspect that the generic row info appears in the other branches as well, which suggests it could be pulled out. So it might look something like: <!--place generic row info--> <xsl:if test="not(preceding-sibling::tocItem)"> <!--place pretest--> </xsl:if> <xsl:if test="title = 'Lab' or (count(following-sibling::tocItem)=1 and not(../tocItem/title='Lab'))"> <!--place review--> </xsl:if> <xsl:if test="not(following-sibling::tocItem)"> <!--place posttest--> </xsl:if> This time I've used paths instead of position tests to establish the location. And if more than one condition obtains, you get whatever it entails, in an order you want. Cheers, Wendell At 01:12 PM 10/18/2010, you wrote: I am working with a table of contents that I am converting into a table, placing the contents of the toc into one column of the table and inserting certain content in the last column of each row, depending upon the position and content of certain entries. All is great until I get to situations in which the content depends upon the existence or non-existence of a certain item in the toc. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|