private void call(String script) throws ParserConfigurationException, TransformerConfigurationException { File callerScript = this.currentScript; Document doc = null; try { this.currentScript = new File(script); DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); doc = db.parse(this.currentScript); } catch (Exception ex) { this.currentScript = callerScript; Utils.onError(new Error.FileParse(script)); return; } NodeList operations = doc.getDocumentElement().getChildNodes(); for (int i = 0; i < operations.getLength(); i++) { Node operation = operations.item(i); if (operation.getNodeType() != Node.ELEMENT_NODE) continue; call(operation); } this.currentScript = callerScript; }
private void appendNodes(Document doc, Node target, NodeList nodes) { for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); target.appendChild(doc.importNode(node, true)); } }