Textarea in XSL

getsriku
getsriku used Ask the Experts™
on
Hi all

I am haveing a xml (test.xml)

<?xml version="1.0" encoding="UTF-8"?>
<constantgroup>
<constant id="textarea_rows">6</constant>
<constant id="textarea_cols">60</constant>
</constantgroup>

How to set attributes for textarea (rows and cols) from the above xml

XSL goes like this...
<textarea name="ElementnameTextarea" rows="?????"  cols="?????"></textarea>


Pls help me

Thanks in advance
Nivas
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
[jarkko@itcm xslt]$ cat fo.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" indent="yes"/>
 
  <xsl:template match="constantgroup">
   <textarea name="ElementnameTextarea"
     rows="{constant[@id='textarea_rows']}"
     cols="{constant[@id='textarea_cols']}"></textarea>
 </xsl:template>
 
</xsl:stylesheet>
 
Commented:
hi,
try this..this should work!


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
            <html>
                  <head>
                        <title></title>
                  </head>
                  <body>
                        <textarea name="test">
                              <xsl:variable name="rows" select="//constant[@id = 'textarea_rows']"></xsl:variable>
                              <xsl:variable name="cols" select="//constant[@id = 'textarea_cols']"></xsl:variable>
                              <xsl:attribute name="rows">
                                    <xsl:value-of select="$rows"></xsl:value-of>
                              </xsl:attribute>
                              <xsl:attribute name="cols">
                                    <xsl:value-of select="$cols"></xsl:value-of>
                              </xsl:attribute>
                                    <xsl:value-of select="concat('Textarea Rows are : ',$rows,' and Cols are : ', $cols)"></xsl:value-of>
                        </textarea>
                  </body>
            </html>
      </xsl:template>
</xsl:stylesheet>

Zulu..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial