[jdom-interest] Converting from DOM to JDOM

Antony Corfield Antony.Corfield at las.ox.ac.uk
Tue May 15 04:36:49 PDT 2001


Hi,

I'm converting between JDOM and DOM using DOMOutputter to produce
org.w3c.dom.Element for input to Xalan processor which works fine.

    DOMOutputter domOut = new DOMOutputter();
    org.w3c.dom.Element domElement = null;

    try {
      domElement = domOut.output(jdomElement);
    }
    catch (JDOMException e) {
      System.out.println("JDOMException");
    }

    return domElement;

However, when I try converting the DOM Node, Element or Document back to
JDOM using DOMBuilder:

    DOMBuilder domBuilder = new DOMBuilder();
    org.jdom.Element jdomElement = domBuilder.build(domElement);

I get the following error: org.jdom.IllegalNameException: The name "null" is
not legal for JDOM/XML elements: XML names cannot be null or empty.

I have checked that the DOM Node (getNodeName()) or Element (getTagName())
does indeed have a name! Is this a name space problem, or has anyone found
similar problems?

Thanks,

Antony


______________________________________________________________________
Antony Corfield                           Java Developer JAFER Project

email: Antony.Corfield at las.ox.ac.uk       Libraries Automation Service
  tel: +44 (01865) 284454                 99 Banbury Rd
  fax: +44 (01865) 278275                 Oxford OX2 6JX
______________________________________________________________________





More information about the jdom-interest mailing list