W3C home > Mailing lists > Public > xsl-editors@w3.org > April to June 2002

Copy node and sub-node in HTML hidden field

From: Benoit Segaert <benoit.segaert@uniway.be>
Date: Wed, 17 Apr 2002 17:36:28 +0200
Message-ID: <3CBD967C.E37837BB@uniway.be>
To: xsl-editors@w3.org
I need to copy a XHTML node and subnode in an attribute.
EX:
    <tag>
        <p>example</p>
    </tag>


If I want to copy
    <p>example</p>
in an attribute, I receive an error from my XSLT parser:
    Cannot write an attribute when there is no open start tag.

I have try the following codes:
    <xsl:template match="tag">
        <xsl:variable name = "content" ><xsl:copy-of
select="node()|@*"/></xsl:variable>
        <input type="hidden" value="{$content}"/>
    </xsl:template>

or
    <xsl:template match="tag">
         <xsl:element name="input">
              <xsl:attribute name="type">hidden</xsl:attribute>
              <xsl:attribute name="name"><xsl:value-of
select="$id"/>_hidden</xsl:attribute>
              <xsl:attribute name="value"><xsl:copy-of
select="node()|@*"/></xsl:attribute>
         </xsl:element>
    </xsl:template>

But if I put the content in a textarea, I have any problem:

 <TEXTAREA  rows="{$lineNumber}" name="{$id}" style="width: 100%">
      <xsl:copy-of select="node()|@*"/>
 </TEXTAREA>

Can you help me?
Benoit
Received on Wednesday, 17 April 2002 11:36:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:59:53 GMT