Generating Form Inputs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • HugeBob

    #1

    Generating Form Inputs

    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:valu e-of select='@file'/>"
    value="<xsl:val ue-of select='@file'/>"
    >
    MSXSL reports: The character '<' cannot be used in an attribute value.

    How can I perform this task correctly? Thanks.

  • Joe Kesselman

    #2
    Re: Generating Form Inputs

    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

    Comment

    • Joe Kesselman

      #3
      Re: Generating Form Inputs

      .... 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

      Comment

      • HugeBob

        #4
        Re: Generating Form Inputs

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

        ..
        ..
        ..
        <TD ...>
        <input type="checkbox" <----------------- error
        <xsl:attribut e name="name">
        <xsl:value-of select="name"/>
        </xsl:attribute>
        <xsl:attribut e name="value">
        <xsl:value-of select="@storyi d"/>
        </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

        Comment

        • Johannes Koch

          #5
          Re: Generating Form Inputs

          HugeBob schrieb:
          Thanks Joe. AVT's worked out.
          Good
          Previously, I had tried using the
          <xsl:attribut e ...tag to populate my <INPUT...>'s:
          >
          ..
          ..
          ..
          <TD ...>
          <input type="checkbox" <----------------- error
          <xsl:attribut e name="name">
          <xsl:value-of select="name"/>
          </xsl:attribute>
          <xsl:attribut e name="value">
          <xsl:value-of select="@storyi d"/>
          </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:attribut e ...>
          ...
          </xsl:attribute>
          <xsl:attribut e ...>
          ...
          </xsl:attribute>
          </input>
          --
          Johannes Koch
          In te domine speravi; non confundar in aeternum.
          (Te Deum, 4th cent.)

          Comment

          Working...