[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: A tricky problem

Subject: RE: A tricky problem
From: "Carlos M. S. Bento Nogueira" <cmsbn@xxxxxxxxxxxxxxxxx>
Date: Sun, 19 Jun 2005 00:59:49 +0100 (WEST)
fd item
Everybody,please forgive me for this double post,the fact is that i replied correctly but to wrong question previously :(

Aron,
the reason why this code you suggest doesn't work is that my inputs are declared as
<input type="radio" id="{generate-id()}" name="{$id}" value="{@value}">
and the generate-id() functions probably loses reference to the context node when used inside the <xsl:template
match="opt">(now fi:item) as you suggested.


I adapted your snippets to produce this:
<xsl:for-each select="fi:selection-list/fi:item[position() &lt;= current()/$line]">
<xsl:variable name="r" select="position() - 1"/>
<tr>
<xsl:apply-templates select="fi:item[position() &gt;= $r * $column + 1
and position() &lt;= $r * $column + $column ]"/>
</tr>
</xsl:for-each>
(...)


<xsl:template match="fi:item">
        <td>
        <input type="radio" id="{generate-id()}" name="{$id}" value="{@value}">
        (...)
</xsl:template>

Also the output i'm trying to achieve is e.g. for a table with 2 lines and 2 columns is

<td>
        <input>
</td>
<td>
        <input>
</td>
<tr>    <!--I can only have (($number_of_lines) - 1) tr tags -->
<td>
        <input>
</td>
<td>
        <input>
</td>
</tr>

TIA, TG(thanks again),
CarlosN.


On Sat, 18 Jun 2005, Aron Bock wrote:


Carlos, I somewhat lost track of what you're trying to do, in the long-winded explanation -- what works for me is seeing input, required output, then any explanation of what changes may/not be made. Anyway, see this thread: http://www.biglist.com/lists/xsl-list/archives/200506/msg00517.html

Regards,

--A

From: "Carlos M. S. Bento Nogueira" <cmsbn@xxxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  A tricky problem
Date: Sat, 18 Jun 2005 17:32:12 +0100 (WEST)

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&lt;$line">
			<tr>
			<xsl:if test="temp&lt;$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&gt;=2">
<tr>
</xsl:if>


(code to show inputs here)

	<xsl:if test="$line&gt;=2">
	</tr>
	</xsl:if>


_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



--


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.