[jdom-interest] Bug in AttributeList.java

Joan Roch joanr at k-os.com
Wed Feb 20 07:15:30 PST 2002


--------------------------------------------------------------------------------
This bug report applies to:
JDOM-b8-dev - Checked out from CVS on Feb. 20, 2002
--------------------------------------------------------------------------------

I am not 100% sure the bug comes from AttributeList.java, but it's my best guess.

There seem to be a discrepancy between the reported number of Attributes in the list and the actual number of Attributes. None of my methods modify the AttributeList in any way. I don't see right any other explanation for such an Exception being thrown, but I don't have the knowledge to point out this bug, nor the time to acquire that knowledge :(

--------------------------------------------------------------------------------
The error is the following:

java.util.NoSuchElementException
	at java.util.AbstractList$Itr.next(Unknown Source)
	at com.ermis.html.XhtmlTemplate.exploreElement(XhtmlTemplate.java:190)
	at com.ermis.html.XhtmlTemplate.exploreElement(XhtmlTemplate.java:212)
	at com.ermis.html.XhtmlTemplate.exploreElement(XhtmlTemplate.java:212)
	at com.ermis.html.XhtmlTemplate.exploreElement(XhtmlTemplate.java:212)
	at com.ermis.html.XhtmlTemplate.<init>(XhtmlTemplate.java:124)
	at com.ermis.html.XhtmlPage.<init>(XhtmlPage.java:68)
	at TemplateTest.main(TemplateTest.java:22)
--------------------------------------------------------------------------------

Here is my code in XhtmlTemplate:

184:  private void exploreElement(Element element) {
185:    // we first explore the attributes of the current Element
186:    List attributes = element.getAttributes();
187:    Iterator attributeIterator = attributes.iterator();
188:    while (attributeIterator.hasNext()) {
189       /* LOG */ logger.debug("*** Exploring: <" + element.getName() + "> " + attributes.size() + " attributes.");
190:      Attribute attribute = (Attribute) attributeIterator.next();
191:      // we check if the attribute is the special identifier
192:      if (attribute.getName().equals(IDENTIFIER)) {
193:        // special identifier - we store the current element for future reference
194:        addIdentifiedElement(attribute.getValue(), element);
195:      } else {
196:        // normal attribute - we check if the attribute value contains a variable
197:        REMatch[] variables = varRegExp.getAllMatches(attribute.getValue());
198:        for (int i = 0; i < variables.length; i++) {
199:          addVariableReference(variables[i].toString(1), attribute);
200:        }
201:      }
202:    }
[..]
221:  }

--------------------------------------------------------------------------------

The LOG file output:
0 [main] INFO TemplateTest  - BasicConfigurator used.
160 [main] INFO com.ermis.html.XhtmlTemplate  - Template found at 'file:/C:/Ermis/ermismail/templates/LinkTrackingHelper-list.xhtml'
771 [main] DEBUG com.ermis.html.XhtmlTemplate  - Template 'file:/C:/Ermis/ermismail/templates/LinkTrackingHelper-list.xhtml' successfully parsed.
781 [main] DEBUG com.ermis.html.XhtmlTemplate  - *** Exploring: <html> 0 attributes.
781 [main] DEBUG com.ermis.html.XhtmlTemplate  - *** Exploring: <head> 0 attributes.
781 [main] DEBUG com.ermis.html.XhtmlTemplate  - *** Exploring: <title> 0 attributes.
791 [main] DEBUG com.ermis.html.XhtmlTemplate  - Reference to ${ermis.mailingId} found in 'org.jdom.Text'.
791 [main] DEBUG com.ermis.html.XhtmlTemplate  - *** Exploring: <body> 0 attributes.
791 [main] DEBUG com.ermis.html.XhtmlTemplate  - *** Exploring: <p> 0 attributes.
791 [main] DEBUG com.ermis.html.XhtmlTemplate  - *** Exploring: <b> 0 attributes.
791 [main] DEBUG com.ermis.html.XhtmlTemplate  - Reference to ${ermis.mailingId} found in 'org.jdom.Text'.
791 [main] DEBUG com.ermis.html.XhtmlTemplate  - *** Exploring: <form> 2 attributes.
791 [main] DEBUG com.ermis.html.XhtmlTemplate  - Reference to ${ermis.servlet} found in 'org.jdom.Attribute'.
791 [main] DEBUG com.ermis.html.XhtmlTemplate  - *** Exploring: <ermis> 1 attributes.
801 [main] DEBUG com.ermis.html.XhtmlTemplate  - <ermis ermis-id="trackable-link"> added.
java.util.NoSuchElementException
	at java.util.AbstractList$Itr.next(Unknown Source)
	at com.ermis.html.XhtmlTemplate.exploreElement(XhtmlTemplate.java:190)
	at com.ermis.html.XhtmlTemplate.exploreElement(XhtmlTemplate.java:212)
	at com.ermis.html.XhtmlTemplate.exploreElement(XhtmlTemplate.java:212)
	at com.ermis.html.XhtmlTemplate.exploreElement(XhtmlTemplate.java:212)
	at com.ermis.html.XhtmlTemplate.<init>(XhtmlTemplate.java:124)
	at com.ermis.html.XhtmlPage.<init>(XhtmlPage.java:68)
	at TemplateTest.main(TemplateTest.java:22)

--------------------------------------------------------------------------------

And the parsed XML file:

<html>
  <head>
    <title>Mailing ID: ${mailingId}</title>
  </head>
  <body>
    <p><b>Mailing ID: ${mailingId}</b></p>
    <form method="post" action="${servlet}?action=save">
      <ermis ermis-id="trackable-link">
        <table border="1" width="100%" ermis-id="zling">
          <tr>
            <td colspan="2"><small>${url}</small></td></tr>
          <tr>
            <td valign="middle"><input name="track-${i}" type="checkbox" checked="true"/> Track?</td>
            <td ermis-id="gronk" valign="middle" width="100%">$text</td>
          </tr>
          <tr>
            <td valign="middle"><input name="type-${i}" value="product" type="radio" checked="true"/> Product<br/>
                                <input name="type-${i}" value="other" type="radio"/> Other</td>
            <td valign="middle" width="100%">Description [${i}]: <textarea name="desc-${i}" cols="80" rows="1">${desc}</textarea> [${i}]</td>
          </tr>
        </table><br/>
      </ermis>
      <input type="submit" value="Submit"/>
    </form>
  </body>
</html>

--------------------------------------------------------------------------------






More information about the jdom-interest mailing list