1 16 package org.apache.commons.jxpath.xml; 17 18 import java.io.InputStream ; 19 20 import org.apache.commons.jxpath.JXPathException; 21 import org.jdom.input.SAXBuilder; 22 23 29 public class JDOMParser extends XMLParser2 { 30 31 public Object parseXML(InputStream stream) { 32 if (!isNamespaceAware()) { 33 throw new JXPathException("JDOM parser configuration error. JDOM " 34 + "does not support the namespaceAware=false setting."); 35 } 36 37 try { 38 SAXBuilder builder = new SAXBuilder(); 39 builder.setExpandEntities(isExpandEntityReferences()); 40 builder.setIgnoringElementContentWhitespace( 41 isIgnoringElementContentWhitespace()); 42 builder.setValidation(isValidating()); 43 return builder.build(stream); 44 } 45 catch (Exception ex) { 46 throw new JXPathException("JDOM parser error", ex); 47 } 48 } 49 } | Popular Tags |