use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class NS3ToNSXML method parseNavascript.
public InputStream parseNavascript(String fileContent) throws Exception {
navascript parser = new navascript(fileContent, this);
input = fileContent;
parser.parse_Navascript();
String result = xmlString.toString();
// System.err.println(result);
XMLElement xe = new CaseSensitiveXMLElement(true);
xe.parseString(result);
parseXML(myNavascript, xe, 0);
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(in);
new Thread() {
public void run() {
myNavascript.write(out);
try {
out.close();
} catch (IOException e) {
logger.error(e.getLocalizedMessage(), e);
}
}
}.start();
return in;
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class MapMetaData method parse.
public void parse(XMLElement in, String scriptName, Writer sw) throws MetaCompileException, IOException, ClassNotFoundException {
// Remember tsl attributes.
Map<String, String> tslAttributes = new HashMap<>();
Iterator<String> all = in.enumerateAttributeNames();
while (all.hasNext()) {
String name = all.next();
String value = in.getAttribute(name) + "";
tslAttributes.put(name, value);
}
XMLElement result = new CaseSensitiveXMLElement();
result.setName("tsl");
generateCode(in, result, scriptName);
// Reinsert tsl attributes.
all = tslAttributes.keySet().iterator();
while (all.hasNext()) {
String name = all.next().toString();
String value = tslAttributes.get(name);
result.setAttribute(name, value);
}
result.write(sw);
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class MapMetaData method readExtentionDefinition.
public void readExtentionDefinition(ExtensionDefinition ed) throws IOException, ClassNotFoundException, KeywordException {
// System.err.println("In MapMetaData. ExtensionDefinition: " + ed);
BufferedReader br = new BufferedReader(new InputStreamReader(ed.getDefinitionAsStream(), StandardCharsets.UTF_8));
XMLElement config = new CaseSensitiveXMLElement();
config.parseFromReader(br);
br.close();
if (config.getName().equals("adapterdef")) {
Vector<XMLElement> allmaps = config.getElementsByTagName("map");
for (int i = 0; i < allmaps.size(); i++) {
XMLElement map = allmaps.get(i);
addMapDefinition(map);
}
}
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class MapMetaData method isMetaScript.
public static boolean isMetaScript(String fullScriptPath) {
try (InputStreamReader isr = new InputStreamReader(new FileInputStream(fullScriptPath), StandardCharsets.UTF_8)) {
XMLElement x = new CaseSensitiveXMLElement();
x.parseFromReader(isr);
return (x.getName().equals("navascript"));
} catch (Exception e) {
AuditLog.log("", "Something went wrong while in determination of metascript status of script: " + fullScriptPath + "(" + e.getMessage() + ")", Level.WARNING);
return false;
}
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class ScriptInheritance method doInject.
private void doInject(XMLElement subScript, XMLElement child, String scriptPath, List<String> inheritedScripts) throws Exception {
// find inject tags.
Vector<XMLElement> children = (child == null ? subScript.getChildren() : child.getChildren());
if (!scriptPath.endsWith("/")) {
scriptPath = scriptPath + "/";
}
for (int i = 0; i < children.size(); i++) {
if (children.get(i).getName().equalsIgnoreCase("inject")) {
XMLElement injectNode = children.get(i);
String script = (String) injectNode.getAttribute("script");
XMLElement result = null;
if (script != null) {
// Recursively do inheritance for inherited scripts...
File f = new File(scriptPath + script + ".xml");
if (!f.exists()) {
f = new File(scriptPath + script + ".ns");
}
BufferedReader br = new BufferedReader(new InputStreamReader(inherit(new FileInputStream(f), scriptPath, inheritedScripts), "UTF-8"));
XMLElement superScript = new CaseSensitiveXMLElement();
superScript.parseFromReader(br);
br.close();
inheritedScripts.add(script);
result = extend(superScript, injectNode);
}
children.remove(i);
children.add(i, result);
} else {
doInject(subScript, children.get(i), scriptPath, inheritedScripts);
}
}
}
Aggregations