use of org.talend.xml.sax.simpleparser.model.XMLNodes in project tdi-studio-se by Talend.
the class SimpleSAXLooper method initLoopEntries.
private void initLoopEntries() {
multiCache = DataBufferCache2.getInstance();
for (XMLNodes ns : nodesList) {
for (XMLNode node : ns.getNodes().values()) {
String column = node.originPath;
String resultCol = node.loopPath;
String[] splits = column.split("/");
for (String tmp : splits) {
if (tmp.equals("..")) {
resultCol = resultCol.substring(0, resultCol.lastIndexOf("/"));
node.setAttrOutOfLoop(true);
} else if (tmp.equals(".")) {
node.isDot = true;
} else {
resultCol += "/" + tmp;
}
}
node.nodePath = resultCol;
}
}
}
use of org.talend.xml.sax.simpleparser.model.XMLNodes in project tdi-studio-se by Talend.
the class SimpleSAXLooper method call.
public Object call() throws Exception {
Reader reader = null;
try {
DefaultHandler handler = null;
if (nodesList.size() > 0) {
SAXLoopCompositeHandler chd = new SAXLoopCompositeHandler();
for (int i = 0; i < nodesList.size(); i++) {
XMLNodes ns = nodesList.get(i);
chd.register(new SimpleSAXLoopHandler(ns, multiCache));
}
handler = chd;
} else {
hd = new SimpleSAXLoopHandler(nodes, bcache);
handler = hd;
}
SAXParser saxParser = null;
if (!ignoreDTD) {
//orginal code
saxParser = SAXParserFactory.newInstance().newSAXParser();
} else {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
saxParser = spf.newSAXParser();
}
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
if (fileURL != null) {
// routines.system.UnicodeReader.java is used to ignore the BOM of the source file.
reader = new UnicodeReader(new java.io.FileInputStream(fileURL), this.charset);
org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader);
saxParser.parse(inSource, handler);
} else {
reader = new UnicodeReader(is, this.charset);
org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader);
saxParser.parse(inSource, handler);
}
} finally {
try {
if (reader != null) {
reader.close();
}
} finally {
if (multiCache != null) {
multiCache.notifyErrorOccurred();
}
if (bcache != null) {
bcache.notifyErrorOccurred();
}
}
}
return null;
}
Aggregations