[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] A tricky problem
Hello!
I'm trying to create a piece of xsl code that dinamicaly displays items on a table.This seems a basic problem at first glance, but if you're curious(and a bit pacient) please continue reading :) This is my item list:(temp.xml) <fd:selection-list> <fd:item value="Dcor"/> <fd:item value="DAo"/> <fd:item value="InsAo"/> <fd:item value="EstAo"/> </fd:selection-list> Note that i cannot change the item properties, e.g. , to add another attribute like position="row" to fd:item nor can i add description tags between item lists e.g. : <fd:item value="Dcor"/> <row></row> <fd:item value="DAo"/> The description of this item lists is passed to the xsl by snippet:(temp_action.xml) <table border="0"> <tr> (...) <td> <ft:widget id="diagnostico_opcoes"> <fi:styling list-type="radio" list-orientation="horizontal" line="2" column="2"/> </ft:widget> </td> (...) </tr> where we describe the list orientation layout and number of columns and rows we want on a table. The piece of xsl code which iterates through the items on this list is given by this snippet: <xsl:for-each select="descendant-or-self::fi:item"> (..) </xsl:for-each> although the following piece of code also produces the same results: <xsl:for-each select="fi:selection-list/fi:item"> (...) </xsl:for-each> Inside the iteration code snippet, i should build a set of instructions that could produce an HTML output like <td> <input name="Dcor" .../> <td/> <td> <input name="Dao" .../> <td/> <tr> <td> <input name="InsAo" .../> <td/> <td> <input name="EstAo" .../> <td/> <tr/> My last attemp to produce this, was the following piece of code: <xsl:variable name="elements" select="count(descendant-or-self::fi:item)"/> <xsl:for-each select="descendant-or-self::fi:item"> <!-- Counts the iteration number temp= 1,2,3,4 ... --> <xsl:variable name="temp" select="($elements)-(count(following-sibling::*))"/> <xsl:if test="$temp<$line"> <tr> <xsl:if test="temp<$column"> <td> <input type="radio" ..../> </td> </xsl:if> </tr> </xsl:if> (...) This would work great if instead of if test="..." i had a for-each select="(1 to $line)" for-each select="(1 to $column)" and although this is possible since i'm using Saxon8 it doesn't do the trick for the following reasons: - i should only change lines if i have $line>=2 - the following snippet is invalid as a mean to insert lines between columns: <xsl:if test="$line>=2"> <tr> </xsl:if> (code to show inputs here) <xsl:if test="$line>=2"> </tr> </xsl:if> - i found no way of iterating one by one element without selecting all the elements nodes previously with a (for-each="fi:selection-list/fi:item") Any ideas to overcome this problem would be great.Please be so kind to include some code snippets to illustrate. TIA, CarlosN.
|
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
|