View Single Post
  #2 (permalink)  
Old February 27th, 2006, 07:07 PM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts

This is not the way to write XSLT:

       <xsl:text disable-output-escaping="yes">

XSLT is a language for transforming input trees into result trees. The result tree is then (optionally) sent to a serializer to be turned into serial XML. Very occasionally you need to prod the serializer to do something unusual, and that is the only time you should use disable-output-escaping. What you are trying to do here is to bend XSLT into a language for writing textual XML, in the form of tags, and you are getting yourself into a mess as a result.

Writing a node to a tree is an atomic action, achieved using a literal result element if it's name is known statically, or xsl:element if not. You don't write one half of the node at one time, and the other half later.

To write a table with data items arranged four per row, your logic should look like this:

 for each group of four items
    for each of the four items
        output the item

for example

 <xsl:for-each select="Course[position() mod 4 = 1]">
   <xsl:for-each select=".|following-sibling::Course[position() &lt; 4]">

Sorry not to help you with your immediate problem, but this code is no place to start from.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote