[jdom-interest] ERROR: org.jdom.Element.getParent()Lorg/jdom/Element;

angeloimm angeloimm at libero.it
Fri Jan 28 07:55:55 PST 2005


Hi all; i'm using JDom 1.0,  Jaxen version 1.0-FCS ( jaxen-full.jar ) on JBuilder2005.
I have this xml file called structure:

<?xml version="1.0" encoding="ISO-8859-1"?>
<site_structures>
  <site name="Regione Campania" id="site1">
    <page name="HomeTest" id="FWD-001" descr="Pagina principale della Regione Campania" jsPageName="default">
      <sezione name="La Regione Informa" path="PTH-001" infobeanName="Notizia" forward_detail="FWD-001-004" forward_archive="FWD-001-003"/>
      <sezione name="Eventi" path="PTH-002" infobeanName="NotiziaHomePage" forward_detail="FWD-001-002" forward_archive="FWD-001-001"/>
      <sezione name="Siti Tematici in evidenza" editable="false" path="PTH-003" infobeanName="ExternalLink" forward_archive="FWD-001-005"/>
      <sezione name="Primo Piano" path="PTH-004" infobeanName="NotiziaHomePage" forward_detail="FWD-001-007"/>
      <sezione name="Link Istituzionali" path="PTH-005" infobeanName="ExternalLink"/>
      <page editable="false" name="Dettaglio La Regione Informa" id="FWD-001-004" jsPageName="HOME_DettaglioRegioneInforma">
        <sezione name="Dettaglio Regione Informa" editable="false" path="PTH-001" infobeanName="NotiziaHomePage"/>
      </page>
      <page editable="false" name="Archivio La Regione Informa" id="FWD-001-003" jsPageName="HOME_ArchivioRegioneInforma">
        <sezione name="Archivio Regione Informa" editable="false" path="PTH-001" infobeanName="NotiziaHomePage" forward_detail="FWD-001-004"/>
      </page>
      <page editable="false" name="Dettaglio Eventi" id="FWD-001-002" jsPageName="HOME_DettaglioEventiHomePage">
        <sezione name="Dettaglio Evento" editable="false" path="PTH-002" infobeanName="NotiziaHomePage"/>
      </page>
      <page editable="false" name="Archivio Eventi" id="FWD-001-001" jsPageName="HOME_ArchivioEventiHomePage">
        <sezione name="Lista Eventi in Archivio" editable="false" path="PTH-002" infobeanName="NotiziaHomePage" forward_detail="FWD-001-002"/>
      </page>
      <page name="Elenco Aree Tematiche" id="FWD-001-005" descr="riporta una tabella con una serie di pulsanti indicanti le arre tematiche del sito" jsPageName="HOME_ElencoAreeTematiche">
        <sezione name="Area Tematica" path="PTH-006" infobeanName="AreaTematica" forward_detail="FWD-001-005-001"/>
        <page name="Siti Tematici" id="FWD-001-005-001" descr="Ciao da angelo" jsPageName="HOME_SitiTematici">
          <sezione name="Siti tematici" path="PTH-003" infobeanName="ExternalLink"/>
        </page>
      </page>
      <page editable="false" name="Dettaglio Primo Piano" id="FWD-001-007" jsPageName="HOME_DettaglioPrimoPiano">
        <sezione name="Dettaglio Primo Piano" editable="false" path="PTH-004" infobeanName="NotiziaHomePage"/>
      </page>
    </page>
  </site>
</site_structures>

I have this code:

public class Parser {

    private Map sites = new Hashtable();
    public void LeggiXML(String xmlFile, String pageId) {

        try {
            System.out.println(pageId);
            SAXBuilder builder = new SAXBuilder();
            Document document = builder.build(xmlFile);
            XPath xp = XPath.newInstance("/site_structures/site");
            Object el = XPath.selectSingleNode(document,"//page[@id='" + pageId + "']/../@name");
            System.out.println(el);
            //getPageKeys(pageId);
        } catch (JDOMException j) {

            j.printStackTrace();
        } catch (IOException ex) {

            ex.printStackTrace();
        }

    }

    public static void main(String[] args) {
        (new Parser()).LeggiXML("structure.xml", "FWD-001-005-001");
    }
}

Well when i try this code i have this error:
java.lang.NoSuchMethodError: org.jdom.Element.getParent()Lorg/jdom/Element;
	at org.jaxen.jdom.DocumentNavigator.getParentAxisIterator(DocumentNavigator.java:252)
	at org.jaxen.expr.iter.IterableParentAxis.iterator(IterableParentAxis.java:82)
	at org.jaxen.expr.DefaultStep.axisIterator(DefaultStep.java:139)
	at org.jaxen.expr.DefaultLocationPath.evaluate(DefaultLocationPath.java:188)
	at org.jaxen.expr.DefaultAbsoluteLocationPath.evaluate(DefaultAbsoluteLocationPath.java:126)
	at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:107)
	at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:716)
	at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:239)
	at org.jaxen.BaseXPath.selectSingleNode(BaseXPath.java:262)
	at org.jdom.xpath.JaxenXPath.selectSingleNode(JaxenXPath.java:153)
	at org.jdom.xpath.XPath.selectSingleNode(XPath.java:368)
	at site.Parser.LeggiXML(Parser.java:56)
	at site.Parser.main(Parser.java:70)
Exception in thread "main" ;

if i use this code:

public class Parser {

    private Map sites = new Hashtable();
    public void LeggiXML(String xmlFile, String pageId) {

        try {
            System.out.println(pageId);
            SAXBuilder builder = new SAXBuilder();
            Document document = builder.build(xmlFile);
            XPath xp = XPath.newInstance("/site_structures/site");
            Object el = XPath.selectSingleNode(document,"//page[@id='" + pageId + "']/@name");
            System.out.println(el);
            //getPageKeys(pageId);
        } catch (JDOMException j) {

            j.printStackTrace();
        } catch (IOException ex) {

            ex.printStackTrace();
        }

    }

    public static void main(String[] args) {
        (new Parser()).LeggiXML("structure.xml", "FWD-001-005-001");
    }
}

All works very fine;how can i avoid this error?
Thanks



____________________________________________________________
6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
Scaricalo su INTERNET GRATIS 6X http://www.libero.it





More information about the jdom-interest mailing list