[jdom-interest] Problem with ElementFilter

Charles.Robinson at abbott.com Charles.Robinson at abbott.com
Mon Jun 24 11:16:47 PDT 2002


I am trying to convert from jdom.b7 to jdom.b8 and I ran into a surprise with
filters.

Specifically I get the error report from ContentList
org.jdom.IllegalAddException: Filter won't allow the org.jdom.Element
'[Element: <view/>]' to be added to the list
        at org.jdom.ContentList$FilterList.add(ContentList.java:760)
        at java.util.AbstractList.add(AbstractList.java:84)
        at GenBO.main(GenBO.java:25)
Filter won't allow the org.jdom.Element '[Element: <view/>]' to be added to
the list

when executing the following snippet of code
          SAXBuilder b = new SAXBuilder();
          File xmlFile = new File(args[0]);
          Document doc = b.build(xmlFile);
          Element root = doc.getRootElement();
          List t = root.getChildren("table");
          List v = root.getChildren("view");
          Iterator iterator = v.iterator();
               while (iterator.hasNext()) {
//                  t.add(iterator.next());
               Element e = (Element)iterator.next();
               e = e.detach();
               t.add(e.clone());
               }

with the xml file
<?xml version="1.0" encoding="UTF-8"?>

<asms>
  <table name="BSCT">
  </table>
  <view name="BSCTv">
  </view>
</asms>

If I eliminate either the element "view" from the xml or the concatenation  of
same onto List t everything is fine. At first I thought I had a concurency
problem, thus my detach/clone sequence but that did not seem to be the
problem.




More information about the jdom-interest mailing list