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

Re: xsl:variable

Subject: Re: xsl:variable
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 10 Mar 2003 11:05:33 -0700 (MST)
xsl variable input name
Laurence Mossuz wrote:
> a part of my xml file looks like that :
> - <xsl:for-each select="toto">
> - <tr>
>   <xsl:apply-templates select="titi" />
>   <xsl:apply-templates select="tata" />
>   </tr>
>   </xsl:for-each>

That's not your XML.

Show us the XML you have, and the output you want to produce.

I *think* you are saying you have something like
<test>
  <toto>
    <titi>ti1</titi>
    <tata>ta1</tata>
  </toto>
  <toto>
    <titi>ti2</titi>
  </toto>
  <toto>
    <tata>ta3</titi>
  </toto>
  <toto/>
</test>

where each toto represents a table row, and where titi or tata may be missing.
When titi or tata are present, you want their value in the cell; otherwise you
want an HTML input element. Is this correct? I mean, is this the output you
would want?

<tr>
  <td>ta1</td>
  <td>ti1</td>
</tr>
<tr>
  <td>ta2</td>
  <td><input name="titi2" type="text" /></td>
</tr>
<tr>
  <td><input name="tata3" type="text" /></td>
  <td>ti3</td>
</tr>
<tr>
  <td><input name="tata4" type="text" /></td>
  <td><input name="titi4" type="text" /></td>
</tr>

If so, then when processing each toto, you can use its
position relative to all the totos selected for processing
as your counter.

<xsl:for-each select="toto">
  <tr>
    <td>
      <xsl:choose>
        <xsl:when test="string(tata)">
          <xsl:value-of select="tata"/>
        </xsl:when>
        <xsl:otherwise>
          <input name="tata{position()}" type="text"/>
        </xsl:otherwise>
      </xsl:choose>
    </td>
    <td>
      <xsl:choose>
        <xsl:when test="string(titi)">
          <xsl:value-of select="titi"/>
        </xsl:when>
        <xsl:otherwise>
          <input name="titi{position()}" type="text"/>
        </xsl:otherwise>
      </xsl:choose>
    </td>
  </tr>
</xsl:for-each>

If this is not exactly what you want, perhaps it at least gives you some
ideas.

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.