use of org.cyberneko.html.parsers.DOMParser in project ofbiz-framework by apache.
the class UelFunctions method readHtmlDocument.
public static Document readHtmlDocument(String str) {
Document document = null;
try {
URL url = FlexibleLocation.resolveLocation(str);
if (url != null) {
DOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/namespaces", false);
parser.parse(url.toExternalForm());
document = parser.getDocument();
} else {
Debug.logError("Unable to locate HTML document " + str, module);
}
} catch (IOException | SAXException e) {
Debug.logError(e, "Error while reading HTML document " + str, module);
}
return document;
}
use of org.cyberneko.html.parsers.DOMParser in project nimbus by nimbus-org.
the class DOMHTMLConverter method toDOM.
protected Document toDOM(InputStream is) throws ConvertException {
DOMParser parser = new DOMParser();
try {
final InputSource inputSource = new InputSource(is);
if (characterEncodingToObject != null) {
String encoding = (String) IANA2JAVA_ENCODING_MAP.get(characterEncodingToObject);
if (encoding == null) {
encoding = characterEncodingToObject;
}
inputSource.setEncoding(encoding);
}
if (isSynchronizedDomParse) {
final Object lock = parser.getClass();
synchronized (lock) {
parser.parse(inputSource);
}
} else {
parser.parse(inputSource);
}
return parser.getDocument();
} catch (SAXException e) {
throw new ConvertException(e);
} catch (IOException e) {
throw new ConvertException(e);
}
}
Aggregations