Generating Form Inputs

Discussion in 'XML' started by HugeBob, Aug 4, 2006.

  1. HugeBob

    HugeBob Guest

    Hi All,

    I'm trying to create a form in my XSLT file and fill in the input tag
    attributes with results from an XML transformation. Here's what I'm
    doing that's not working:


    <INPUT type="checkbox"
    name="<xsl:value-of select='@file'/>"
    value="<xsl:value-of select='@file'/>"
    >


    MSXSL reports: The character '<' cannot be used in an attribute value.

    How can I perform this task correctly? Thanks.
    HugeBob, Aug 4, 2006
    #1
    1. Advertising

  2. HugeBob wrote:
    > The character '<' cannot be used in an attribute value.


    Either use the xsl:attribute directive to construct this attribute
    (which can take arbitrarily complex code in its body to build up the
    value), or look at the documentation for Attribute Value Templates.



    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Aug 5, 2006
    #2
    1. Advertising

  3. .... or retrieve the value into a variable and set the attribute's value
    from that.

    XSLT is a programming language; there are usually multiple ways to solve
    any problem, and it's a partly matter of deciding which one best
    expresses what you're trying to do.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Aug 5, 2006
    #3
  4. HugeBob

    HugeBob Guest

    Thanks Joe. AVT's worked out. Previously, I had tried using the
    <xsl:attribute ...> tag to populate my <INPUT...>'s:

    ..
    ..
    ..
    <TD ...>
    <input type="checkbox" > <----------------- error
    <xsl:attribute name="name">
    <xsl:value-of select="name"/>
    </xsl:attribute>
    <xsl:attribute name="value">
    <xsl:value-of select="@storyid"/>
    </xsl:attribute>

    But, my mistake was that I didn't terminate the input tag correctly: />

    The processor reported: End tag 'TD' does not match the start tag
    'input'. Needless to say, that confused me.


    Joe Kesselman wrote:
    > ... or retrieve the value into a variable and set the attribute's value
    > from that.
    >
    > XSLT is a programming language; there are usually multiple ways to solve
    > any problem, and it's a partly matter of deciding which one best
    > expresses what you're trying to do.
    >
    > --
    > () ASCII Ribbon Campaign | Joe Kesselman
    > /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    HugeBob, Aug 7, 2006
    #4
  5. HugeBob schrieb:
    > Thanks Joe. AVT's worked out.


    Good

    > Previously, I had tried using the
    > <xsl:attribute ...> tag to populate my <INPUT...>'s:
    >
    > ..
    > ..
    > ..
    > <TD ...>
    > <input type="checkbox" > <----------------- error
    > <xsl:attribute name="name">
    > <xsl:value-of select="name"/>
    > </xsl:attribute>
    > <xsl:attribute name="value">
    > <xsl:value-of select="@storyid"/>
    > </xsl:attribute>
    >
    > But, my mistake was that I didn't terminate the input tag correctly: />


    No, you have to terminate the input element _after_ the xsl:attribute
    elements:
    <input ...>
    <xsl:attribute ...>
    ...
    </xsl:attribute>
    <xsl:attribute ...>
    ...
    </xsl:attribute>
    </input>
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
    Johannes Koch, Aug 7, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Willem Oosthuizen

    Coding style to prioritize certain inputs

    Willem Oosthuizen, Sep 2, 2003, in forum: VHDL
    Replies:
    5
    Views:
    495
    Mike Treseler
    Sep 4, 2003
  2. Guest

    assigning values to form inputs

    Guest, Aug 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    528
  3. Ellie
    Replies:
    2
    Views:
    447
    Ellie
    Oct 30, 2008
  4. Realbot

    Differences in UTF-8 html form inputs

    Realbot, Jan 8, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    210
    Realbot
    Jan 10, 2005
  5. Replies:
    9
    Views:
    244
    Randy Webb
    Oct 15, 2005
Loading...

Share This Page