Search in sources :

Example 1 with CaseSensitiveXMLElement

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;
}
Also used : com.dexels.navajo.mapping.compiler.navascript.parser.navascript(com.dexels.navajo.mapping.compiler.navascript.parser.navascript) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) IOException(java.io.IOException) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 2 with CaseSensitiveXMLElement

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);
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) HashMap(java.util.HashMap) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 3 with CaseSensitiveXMLElement

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);
        }
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 4 with CaseSensitiveXMLElement

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;
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) InputStreamReader(java.io.InputStreamReader) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException)

Example 5 with CaseSensitiveXMLElement

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);
        }
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)53 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)49 IOException (java.io.IOException)10 InputStreamReader (java.io.InputStreamReader)7 FileReader (java.io.FileReader)5 HashMap (java.util.HashMap)5 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 APIException (com.dexels.navajo.article.APIException)2 Message (com.dexels.navajo.document.Message)2 Property (com.dexels.navajo.document.Property)2 BufferedReader (java.io.BufferedReader)2 InputStream (java.io.InputStream)2 PrintWriter (java.io.PrintWriter)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 XMLParseException (com.dexels.navajo.document.nanoimpl.XMLParseException)1 AdapterFieldDependency (com.dexels.navajo.mapping.compiler.meta.AdapterFieldDependency)1