[xsl] How do I check if an element exists with the same name

Subject: [xsl] How do I check if an element exists with the same name
From: "Tim Blommerde" <T.Blommerde@xxxxxx>
Date: Mon, 26 Mar 2001 10:06:31 +0200
Dear XSL(T) users,

After checking most of the XSL-list archives and reading nearly the whole
XSL companion by Neil Bradley I fear the thing I want is not possible with
XSL, but just to be sure I'd like to hear your opinion on it.  Consider the
following XML part:

  <missing-inputfields>
    <missing-field name='loginName'/>
  </missing-inputfields>

  <input-form caption="Submit">
    <input-field name='loginName' caption='Name'/>
    <input-field name='loginPWD' caption='Password' encrypted='true'/>
  </input-form>

I'd like to convert this XML to HTML using an XLST.  And here comes the
tricky part, I'd like to let the 'input-field' template check if there's a
'missing-field' with the same name.  Is this possible and if so, how?

I tried things like:

    <xsl:template match="input-field">
    <tr>
      <td width=150>
        <xsl:value-of select="@caption"/>
        <xsl:apply-templates select="//missing-field[@name={name}]">
          <xsl:param name="nm">
	    <xsl:value-of select="@name"/>
	  </xsl:param>
	</xsl:apply-templates>
      </td>
      <td>
        <input type="text" size="20">
          <xsl:attribute name="name">
            <xsl:value-of select="@name"/>
          </xsl:attribute>
        </input>
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="input-field">
    <tr>
      <td width=150>
        <xsl:value-of select="@caption"/>
        <xsl:if test="//missing-field[@name]={name}">
          <img src="./mark.gif>
	  </xsl:if>
      </td>
      <td>
        <input type="text" size="20">
          <xsl:attribute name="name">
            <xsl:value-of select="@name"/>
          </xsl:attribute>
        </input>
      </td>
    </tr>
  </xsl:template>

But as you all might have guessed/known, this did not work.  So that's why
I'm asking you if you can help me out.  Is it possible, or not?  Or do you
have no clue at what I'm trying to do?  I'd appreciate any
help/comments/ideas because I'm rather stuck.

Yours sincerely,
Tim


Ps. Poster information:
      Vendor: Microsoft
      Processor version: Original IE5 (or old version of other processor)



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


Current Thread