use of org.apache.xerces.xni.parser.XMLInputSource in project zm-mailbox by Zimbra.
the class HtmlDefang method defang.
public void defang(Reader htmlReader, boolean neuterImages, Writer out) throws IOException {
XMLInputSource source = new XMLInputSource(null, null, null, htmlReader, null);
defang(source, neuterImages, out);
}
use of org.apache.xerces.xni.parser.XMLInputSource in project zm-mailbox by Zimbra.
the class HtmlDefang method defang.
public void defang(InputStream html, boolean neuterImages, Writer out) throws IOException {
XMLInputSource source = new XMLInputSource(null, null, null, html, null);
defang(source, neuterImages, out);
}
use of org.apache.xerces.xni.parser.XMLInputSource in project zm-mailbox by Zimbra.
the class HtmlDetag method detag.
public String detag(String html) {
StringWriter out = new StringWriter();
UnescapeWriter writer = new UnescapeWriter(out, "utf-8");
XMLDocumentFilter[] filters = { this, writer };
XMLParserConfiguration parser = new HTMLConfiguration();
parser.setProperty("http://cyberneko.org/html/properties/filters", filters);
parser.setProperty("http://cyberneko.org/html/properties/names/elems", "match");
parser.setFeature("http://cyberneko.org/html/features/balance-tags", false);
parser.setFeature("http://xml.org/sax/features/namespaces", false);
XMLInputSource source = new XMLInputSource(null, null, null, new StringReader(html), null);
try {
parser.parse(source);
} catch (Exception x) {
ZimbraLog.misc.warn("Can't detag HTML [" + html + "]");
}
//return whatever has been done
return out.toString();
}
use of org.apache.xerces.xni.parser.XMLInputSource in project intellij-community by JetBrains.
the class ModelGen method loadModel.
public void loadModel(final File... modelRoots) throws Exception {
XMLEntityResolver resolver = new XMLEntityResolver() {
public XMLInputSource resolveEntity(XMLResourceIdentifier xmlResourceIdentifier) throws XNIException, IOException {
String esid = xmlResourceIdentifier.getExpandedSystemId();
if (esid == null) {
final String location = schemaLocationMap.get(xmlResourceIdentifier.getNamespace());
if (location != null) {
esid = location;
} else {
return null;
}
}
// Util.log("resolving "+esid);
File f = null;
for (File root : modelRoots) {
if (root == null)
continue;
if (root.isDirectory()) {
final String fileName = esid.substring(esid.lastIndexOf('/') + 1);
f = new File(root, fileName);
} else {
f = root;
}
}
if (f == null || !f.exists()) {
Util.logerr("unable to resolve: " + esid);
return null;
}
esid = f.getPath();
return new XMLInputSource(null, esid, null);
}
};
ArrayList<File> files = new ArrayList<>();
for (File root : modelRoots) {
ContainerUtil.addAll(files, root.listFiles());
}
loader.loadModel(model, files, resolver);
Util.log(model.jtMap.size() + " java types loaded");
}
use of org.apache.xerces.xni.parser.XMLInputSource in project gocd by gocd.
the class XmlReader method setInput.
private void setInput(ThreadContext context, InputStream in, IRubyObject url, Options options) {
this.setState(XML_TEXTREADER_MODE_READING);
config = this.createReader(context.getRuntime(), options);
InputSource inputSource = new InputSource();
ParserContext.setUrl(context, inputSource, url);
XMLInputSource xmlInputSource = new XMLInputSource(inputSource.getPublicId(), inputSource.getSystemId(), null, in, null);
try {
config.setInputSource(xmlInputSource);
} catch (IOException e) {
throw context.getRuntime().newRuntimeError(e.getMessage());
}
this.setState(XML_TEXTREADER_MODE_CLOSED);
}
Aggregations