Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
   *
   * This Source Code Form is subject to the terms of the Mozilla Public
   * License, v. 2.0. If a copy of the MPL was not distributed with this
   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  
  package org.mozilla.javascript.xmlimpl;
  
This abstract class describes what all XML objects (XML, XMLList) should have in common.

See also:
XML
 
 abstract class XMLObjectImpl extends XMLObject {
     private static final Object XMLOBJECT_TAG = "XMLObject";
     private XMLLibImpl lib;
     private boolean prototypeFlag;
 
     protected XMLObjectImpl(XMLLibImpl libScriptable scope,
                             XMLObject prototype)
     {
         initialize(libscopeprototype);
     }
 
     final void initialize(XMLLibImpl libScriptable scope,
                           XMLObject prototype)
     {
         setParentScope(scope);
         setPrototype(prototype);
          = (prototype == null);
         this. = lib;
     }
 
     final boolean isPrototype() {
         return ;
     }
 
     XMLLibImpl getLib() {
         return ;
     }
 
     final XML newXML(XmlNode node) {
         return .newXML(node);
     }
 
     XML xmlFromNode(XmlNode node) {
         if (node.getXml() == null) {
             node.setXmlnewXML(node) );
         }
         return node.getXml();
     }
 
     final XMLList newXMLList() {
         return .newXMLList();
     }
 
     final XMLList newXMLListFrom(Object o) {
         return .newXMLListFrom(o);
     }
 
     final XmlProcessor getProcessor() {
         return .getProcessor();
     }
 
     final QName newQName(String uriString localNameString prefix) {
         return .newQName(urilocalNameprefix);
     }
 
     final QName newQName(XmlNode.QName name) {
         return .newQName(name);
     }
 
     final Namespace createNamespace(XmlNode.Namespace declaration) {
         if (declaration == nullreturn null;
         return .createNamespacesnew XmlNode.Namespace[] { declaration } )[0];
     }
 
     final Namespace[] createNamespaces(XmlNode.Namespace[] declarations) {
         return .createNamespaces(declarations);
     }
 
 
     @Override
     public final Scriptable getPrototype() {
         return super.getPrototype();
     }
 
     @Override
     public final void setPrototype(Scriptable prototype) {
         super.setPrototype(prototype);
     }
 
     @Override
     public final Scriptable getParentScope() {
         return super.getParentScope();
    }
    @Override
    public final void setParentScope(Scriptable parent) {
        super.setParentScope(parent);
    }
    @Override
    public final Object getDefaultValue(Class<?> hint) {
        return this.toString();
    }
    @Override
    public final boolean hasInstance(Scriptable scriptable) {
        return super.hasInstance(scriptable);
    }

    
ecmaHas(cx, id) calls this after resolving when id to XMLName and checking it is not Uint32 index.
    abstract boolean hasXMLProperty(XMLName name);

    
ecmaGet(cx, id) calls this after resolving when id to XMLName and checking it is not Uint32 index.
    abstract Object getXMLProperty(XMLName name);

    
ecmaPut(cx, id, value) calls this after resolving when id to XMLName and checking it is not Uint32 index.
    abstract void putXMLProperty(XMLName nameObject value);

    
ecmaDelete(cx, id) calls this after resolving when id to XMLName and checking it is not Uint32 index.
    abstract void deleteXMLProperty(XMLName name);

    
Test XML equality with target the target.
    abstract boolean equivalentXml(Object target);
    abstract void addMatches(XMLList rvXMLName name);
    private XMLList getMatches(XMLName name) {
        XMLList rv = newXMLList();
        addMatches(rvname);
        return rv;
    }
    abstract XML getXML();
    // Methods from section 12.4.4 in the spec
    abstract XMLList child(int index);
    abstract XMLList child(XMLName xmlName);
    abstract XMLList children();
    abstract XMLList comments();
    abstract boolean contains(Object xml);
    abstract XMLObjectImpl copy();
    abstract XMLList elements(XMLName xmlName);
    abstract boolean hasOwnProperty(XMLName xmlName);
    abstract boolean hasComplexContent();
    abstract boolean hasSimpleContent();
    abstract int length();
    abstract void normalize();
    abstract Object parent();
    abstract XMLList processingInstructions(XMLName xmlName);
    abstract boolean propertyIsEnumerable(Object member);
    abstract XMLList text();
    @Override
    public abstract String toString();
    abstract String toSource(int indent);
    abstract String toXMLString();
    abstract Object valueOf();
    protected abstract Object jsConstructor(Context cxboolean inNewExprObject[] args);
    //
    //
    // Methods overriding ScriptableObject
    //
    //

    
XMLObject always compare with any value and equivalentValues never returns org.mozilla.javascript.Scriptable.NOT_FOUND for them but rather calls equivalentXml(value) and wrap the result as Boolean.
    @Override
    protected final Object equivalentValues(Object value) {
        boolean result = equivalentXml(value);
        return result ? . : .;
    }
    //
    //
    // Methods overriding XMLObject
    //
    //

    
Implementation of ECMAScript [[Has]]
    @Override
    public final boolean has(Context cxObject id) {
        if (cx == nullcx = Context.getCurrentContext();
        XMLName xmlName = .toXMLNameOrIndex(cxid);
        if (xmlName == null) {
            long index = ScriptRuntime.lastUint32Result(cx);
            // XXX Fix this cast
            return has((int)indexthis);
        }
        return hasXMLProperty(xmlName);
    }
    @Override
    public boolean has(String nameScriptable start) {
        Context cx = Context.getCurrentContext();
        return hasXMLProperty(.toXMLNameFromString(cxname));
    }
    
Implementation of ECMAScript [[Get]]
    @Override
    public final Object get(Context cxObject id) {
        if (cx == nullcx = Context.getCurrentContext();
        XMLName xmlName = .toXMLNameOrIndex(cxid);
        if (xmlName == null) {
            long index = ScriptRuntime.lastUint32Result(cx);
            // XXX Fix this cast
            Object result = get((int)indexthis);
            if (result == .) {
                result = .;
            }
            return result;
        }
        return getXMLProperty(xmlName);
    }
    @Override
    public Object get(String nameScriptable start) {
        Context cx = Context.getCurrentContext();
        return getXMLProperty(.toXMLNameFromString(cxname));
    }
    
Implementation of ECMAScript [[Put]]
    @Override
    public final void put(Context cxObject idObject value) {
        if (cx == nullcx = Context.getCurrentContext();
        XMLName xmlName = .toXMLNameOrIndex(cxid);
        if (xmlName == null) {
            long index = ScriptRuntime.lastUint32Result(cx);
            // XXX Fix this cast
            put((int)indexthisvalue);
            return;
        }
        putXMLProperty(xmlNamevalue);
    }
    public void put(String nameScriptable startObject value) {
        Context cx = Context.getCurrentContext();
        putXMLProperty(.toXMLNameFromString(cxname), value);
    }
    
Implementation of ECMAScript [[Delete]].
    @Override
    public final boolean delete(Context cxObject id) {
        if (cx == nullcx = Context.getCurrentContext();
        XMLName xmlName = .toXMLNameOrIndex(cxid);
        if (xmlName == null) {
            long index = ScriptRuntime.lastUint32Result(cx);
            // XXX Fix this
            delete((int)index);
            return true;
        }
        deleteXMLProperty(xmlName);
        return true;
    }
    @Override
    public void delete(String name) {
        Context cx = Context.getCurrentContext();
        deleteXMLProperty(.toXMLNameFromString(cxname));
    }
    @Override
    public Object getFunctionProperty(Context cxint id) {
        if (isPrototype()) {
            return super.get(id, this);
        } else {
            Scriptable proto = getPrototype();
            if (proto instanceof XMLObject) {
                return ((XMLObject)proto).getFunctionProperty(cxid);
            }
        }
        return ;
    }
    @Override
    public Object getFunctionProperty(Context cxString name) {
        if (isPrototype()) {
            return super.get(name, this);
        } else {
            Scriptable proto = getPrototype();
            if (proto instanceof XMLObject) {
                return ((XMLObject)proto).getFunctionProperty(cxname);
            }
        }
        return ;
    }
    //    TODO    Can this be made more strongly typed?
    @Override
    public Ref memberRef(Context cxObject elemint memberTypeFlags) {
        boolean attribute = (memberTypeFlags & .) != 0;
        boolean descendants = (memberTypeFlags & .) != 0;
        if (!attribute && !descendants) {
            // Code generation would use ecma(Get|Has|Delete|Set) for
            // normal name identifiers so one ATTRIBUTE_FLAG
            // or DESCENDANTS_FLAG has to be set
            throw Kit.codeBug();
        }
        XmlNode.QName qname = .toNodeQName(cxelemattribute);
        XMLName rv = XMLName.create(qnameattributedescendants);
        rv.initXMLObject(this);
        return rv;
    }

    
Generic reference to implement x::ns, x.@ns::y, x..@ns::y etc.
    @Override
    public Ref memberRef(Context cxObject namespaceObject elem,
            int memberTypeFlags)
    {
        boolean attribute = (memberTypeFlags & .) != 0;
        boolean descendants = (memberTypeFlags & .) != 0;
        XMLName rv = XMLName.create(.toNodeQName(cxnamespaceelem),
                attributedescendants);
        rv.initXMLObject(this);
        return rv;
    }
    @Override
    public NativeWith enterWith(Scriptable scope) {
        return new XMLWithScope(scopethis);
    }
    @Override
    public NativeWith enterDotQuery(Scriptable scope) {
        XMLWithScope xws = new XMLWithScope(scopethis);
        xws.initAsDotQuery();
        return xws;
    }
    @Override
    public final Object addValues(Context cxboolean thisIsLeft,
        Object value) {
        if (value instanceof XMLObject) {
            XMLObject v1v2;
            if (thisIsLeft) {
                v1 = this;
                v2 = (XMLObject)value;
            } else {
                v1 = (XMLObject)value;
                v2 = this;
            }
            return .addXMLObjects(cxv1v2);
        }
        if (value == .) {
            // both "xml + undefined" and "undefined + xml" gives String(xml)
            return ScriptRuntime.toString(this);
        }
        return super.addValues(cxthisIsLeftvalue);
    }
    //
    //
    // IdScriptableObject machinery
    //
    //
    final void exportAsJSClass(boolean sealed) {
         = true;
        exportAsJSClass(getParentScope(), sealed);
    }
// #string_id_map#
    private final static int
        Id_constructor             = 1,
        Id_addNamespace            = 2,
        Id_appendChild             = 3,
        Id_attribute               = 4,
        Id_attributes              = 5,
        Id_child                   = 6,
        Id_childIndex              = 7,
        Id_children                = 8,
        Id_comments                = 9,
        Id_contains                = 10,
        Id_copy                    = 11,
        Id_descendants             = 12,
        Id_elements                = 13,
        Id_inScopeNamespaces       = 14,
        Id_insertChildAfter        = 15,
        Id_insertChildBefore       = 16,
        Id_hasOwnProperty          = 17,
        Id_hasComplexContent       = 18,
        Id_hasSimpleContent        = 19,
        Id_length                  = 20,
        Id_localName               = 21,
        Id_name                    = 22,
        Id_namespace               = 23,
        Id_namespaceDeclarations   = 24,
        Id_nodeKind                = 25,
        Id_normalize               = 26,
        Id_parent                  = 27,
        Id_prependChild            = 28,
        Id_processingInstructions  = 29,
        Id_propertyIsEnumerable    = 30,
        Id_removeNamespace         = 31,
        Id_replace                 = 32,
        Id_setChildren             = 33,
        Id_setLocalName            = 34,
        Id_setName                 = 35,
        Id_setNamespace            = 36,
        Id_text                    = 37,
        Id_toString                = 38,
        Id_toSource                = 39,
        Id_toXMLString             = 40,
        Id_valueOf                 = 41,
        MAX_PROTOTYPE_ID           = 41;
    @Override
    protected int findPrototypeId(String s) {
        int id;
// #generated# Last update: 2008-10-21 12:32:31 MESZ
        L0: { id = 0; String X = nullint c;
            L: switch (s.length()) {
            case 4: c=s.charAt(0);
                if (c=='c') { X="copy";id=; }
                else if (c=='n') { X="name";id=; }
                else if (c=='t') { X="text";id=; }
                break L;
            case 5: X="child";id=break L;
            case 6: c=s.charAt(0);
                if (c=='l') { X="length";id=; }
                else if (c=='p') { X="parent";id=; }
                break L;
            case 7: c=s.charAt(0);
                if (c=='r') { X="replace";id=; }
                else if (c=='s') { X="setName";id=; }
                else if (c=='v') { X="valueOf";id=; }
                break L;
            case 8: switch (s.charAt(2)) {
                case 'S'c=s.charAt(7);
                    if (c=='e') { X="toSource";id=; }
                    else if (c=='g') { X="toString";id=; }
                    break L;
                case 'd'X="nodeKind";id=break L;
                case 'e'X="elements";id=break L;
                case 'i'X="children";id=break L;
                case 'm'X="comments";id=break L;
                case 'n'X="contains";id=break L;
                } break L;
            case 9: switch (s.charAt(2)) {
                case 'c'X="localName";id=break L;
                case 'm'X="namespace";id=break L;
                case 'r'X="normalize";id=break L;
                case 't'X="attribute";id=break L;
                } break L;
            case 10: c=s.charAt(0);
                if (c=='a') { X="attributes";id=; }
                else if (c=='c') { X="childIndex";id=; }
                break L;
            case 11: switch (s.charAt(0)) {
                case 'a'X="appendChild";id=break L;
                case 'c'X="constructor";id=break L;
                case 'd'X="descendants";id=break L;
                case 's'X="setChildren";id=break L;
                case 't'X="toXMLString";id=break L;
                } break L;
            case 12: c=s.charAt(0);
                if (c=='a') { X="addNamespace";id=; }
                else if (c=='p') { X="prependChild";id=; }
                else if (c=='s') {
                    c=s.charAt(3);
                    if (c=='L') { X="setLocalName";id=; }
                    else if (c=='N') { X="setNamespace";id=; }
                }
                break L;
            case 14: X="hasOwnProperty";id=break L;
            case 15: X="removeNamespace";id=break L;
            case 16: c=s.charAt(0);
                if (c=='h') { X="hasSimpleContent";id=; }
                else if (c=='i') { X="insertChildAfter";id=; }
                break L;
            case 17: c=s.charAt(3);
                if (c=='C') { X="hasComplexContent";id=; }
                else if (c=='c') { X="inScopeNamespaces";id=; }
                else if (c=='e') { X="insertChildBefore";id=; }
                break L;
            case 20: X="propertyIsEnumerable";id=break L;
            case 21: X="namespaceDeclarations";id=break L;
            case 22: X="processingInstructions";id=break L;
            }
            if (X!=null && X!=s && !X.equals(s)) id = 0;
            break L0;
        }
// #/generated#
        return id;
    }
// #/string_id_map#
    @Override
    protected void initPrototypeId(int id) {
        String s;
        int arity;
        switch (id) {
            case : {
                IdFunctionObject ctor;
                if (this instanceof XML) {
                    ctor = new XMLCtor((XML)thisid, 1);
                } else {
                    ctor = new IdFunctionObject(thisid, 1);
                }
                initPrototypeConstructor(ctor);
                return;
            }
            case :      arity=1; s="addNamespace";      break;
            case :       arity=1; s="appendChild";       break;
            case :         arity=1; s="attribute";         break;
            case :        arity=0; s="attributes";        break;
            case :             arity=1; s="child";             break;
            case :        arity=0; s="childIndex";        break;
            case :          arity=0; s="children";          break;
            case :          arity=0; s="comments";          break;
            case :          arity=1; s="contains";          break;
            case :              arity=0; s="copy";              break;
            case :       arity=1; s="descendants";       break;
            case :          arity=1; s="elements";          break;
            case arity=0; s="hasComplexContent"break;
            case :    arity=1; s="hasOwnProperty";    break;
            case :  arity=0; s="hasSimpleContent";  break;
            case arity=0; s="inScopeNamespaces"break;
            case :  arity=2; s="insertChildAfter";  break;
            case arity=2; s="insertChildBefore"break;
            case :            arity=0; s="length";            break;
            case :         arity=0; s="localName";         break;
            case :              arity=0; s="name";              break;
            case :         arity=1; s="namespace";         break;
            case :
                arity=0; s="namespaceDeclarations"break;
            case :          arity=0; s="nodeKind";          break;
            case :         arity=0; s="normalize";         break;
            case :            arity=0; s="parent";            break;
            case :      arity=1; s="prependChild";      break;
            case :
                arity=1; s="processingInstructions"break;
            case :
                arity=1; s="propertyIsEnumerable"break;
            case :   arity=1; s="removeNamespace";   break;
            case :           arity=2; s="replace";           break;
            case :       arity=1; s="setChildren";       break;
            case :      arity=1; s="setLocalName";      break;
            case :           arity=1; s="setName";           break;
            case :      arity=1; s="setNamespace";      break;
            case :              arity=0; s="text";              break;
            case :          arity=0; s="toString";          break;
            case :          arity=1; s="toSource";          break;
            case :       arity=1; s="toXMLString";       break;
            case :           arity=0; s="valueOf";           break;
            defaultthrow new IllegalArgumentException(String.valueOf(id));
        }
        initPrototypeMethod(idsarity);
    }
    private Object[] toObjectArray(Object[] typed) {
        Object[] rv = new Object[typed.length];
        for (int i=0; i<rv.lengthi++) {
            rv[i] = typed[i];
        }
        return rv;
    }
    private void xmlMethodNotFound(Object objectString name) {
        throw ScriptRuntime.notFunctionError(objectname);
    }
    @Override
    public Object execIdCall(IdFunctionObject fContext cxScriptable scope,
                             Scriptable thisObjObject[] args)
    {
        if (!f.hasTag()) {
            return super.execIdCall(fcxscopethisObjargs);
        }
        int id = f.methodId();
        if (id == ) {
            return jsConstructor(cxthisObj == nullargs);
        }
        // All (XML|XMLList).prototype methods require thisObj to be XML
        if (!(thisObj instanceof XMLObjectImpl))
            throw incompatibleCallError(f);
        XMLObjectImpl realThis = (XMLObjectImpl)thisObj;
        XML xml = realThis.getXML();
        switch (id) {
            case : {
                if (xml == nullxmlMethodNotFound(realThis"appendChild");
                return xml.appendChild(arg(args, 0));
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"addNamespace");
                Namespace ns = .castToNamespace(cxarg(args, 0));
                return xml.addNamespace(ns);
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"childIndex");
                return ScriptRuntime.wrapInt(xml.childIndex());
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"inScopeNamespaces");
                return cx.newArray(scopetoObjectArray(xml.inScopeNamespaces()));
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"insertChildAfter");
                Object arg0 = arg(args, 0);
                if (arg0 == null || arg0 instanceof XML) {
                    return xml.insertChildAfter((XML)arg0arg(args, 1));
                }
                return .;
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"insertChildBefore");
                Object arg0 = arg(args, 0);
                if (arg0 == null || arg0 instanceof XML) {
                    return xml.insertChildBefore((XML)arg0arg(args, 1));
                }
                return .;
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"localName");
                return xml.localName();
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"name");
                return xml.name();
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"namespace");
                String prefix = (args.length > 0) ? ScriptRuntime.toString(args[0]) : null;
                Namespace rv = xml.namespace(prefix);
                if (rv == null) {
                    return .;
                } else {
                    return rv;
                }
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"namespaceDeclarations");
                Namespace[] array = xml.namespaceDeclarations();
                return cx.newArray(scopetoObjectArray(array));
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"nodeKind");
                return xml.nodeKind();
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"prependChild");
                return xml.prependChild(arg(args, 0));
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"removeNamespace");
                Namespace ns = .castToNamespace(cxarg(args, 0));
                return xml.removeNamespace(ns);
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"replace");
                XMLName xmlName = .toXMLNameOrIndex(cxarg(args, 0));
                Object arg1 = arg(args, 1);
                if (xmlName == null) {
                    //    I refuse to believe that this number will exceed 2^31
                    int index = (int)ScriptRuntime.lastUint32Result(cx);
                    return xml.replace(indexarg1);
                } else {
                    return xml.replace(xmlNamearg1);
                }
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"setChildren");
                return xml.setChildren(arg(args, 0));
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"setLocalName");
                String localName;
                Object arg = arg(args, 0);
                if (arg instanceof QName) {
                    localName = ((QName)arg).localName();
                } else {
                    localName = ScriptRuntime.toString(arg);
                }
                xml.setLocalName(localName);
                return .;
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"setName");
                Object arg = (args.length != 0) ? args[0] : .;
                QName qname = .constructQName(cxarg);
                xml.setName(qname);
                return .;
            }
            case : {
                if (xml == nullxmlMethodNotFound(realThis"setNamespace");
                Namespace ns = .castToNamespace(cxarg(args, 0));
                xml.setNamespace(ns);
                return .;
            }
            case : {
                XMLName xmlName = XMLName.create.toNodeQName(cxarg(args, 0), true), truefalse );
                return realThis.getMatches(xmlName);
            }
            case :
                return realThis.getMatches(XMLName.create(XmlNode.QName.create(nullnull), truefalse));
            case : {
                XMLName xmlName = .toXMLNameOrIndex(cxarg(args, 0));
                if (xmlName == null) {
                    //    Two billion or so is a fine upper limit, so we cast to int
                    int index = (int)ScriptRuntime.lastUint32Result(cx);
                    return realThis.child(index);
                } else {
                    return realThis.child(xmlName);
                }
            }
            case :
                return realThis.children();
            case :
                return realThis.comments();
            case :
                return ScriptRuntime.wrapBoolean(
                    realThis.contains(arg(args, 0)));
            case :
                return realThis.copy();
            case : {
                XmlNode.QName qname = (args.length == 0) ? XmlNode.QName.create(nullnull) : .toNodeQName(cxargs[0], false);
                return realThis.getMatches( XMLName.create(qnamefalsetrue) );
            }
            case : {
                XMLName xmlName = (args.length == 0)
                ? XMLName.formStar()
                : .toXMLName(cxargs[0]);
                return realThis.elements(xmlName);
            }
            case : {
                XMLName xmlName = .toXMLName(cxarg(args, 0));
                return ScriptRuntime.wrapBoolean(
                    realThis.hasOwnProperty(xmlName));
            }
            case :
                return ScriptRuntime.wrapBoolean(realThis.hasComplexContent());
            case :
                return ScriptRuntime.wrapBoolean(realThis.hasSimpleContent());
            case :
                return ScriptRuntime.wrapInt(realThis.length());
            case :
                realThis.normalize();
                return .;
            case :
                return realThis.parent();
            case : {
                XMLName xmlName = (args.length > 0)
                ? .toXMLName(cxargs[0])
                : XMLName.formStar();
                return realThis.processingInstructions(xmlName);
            }
            case : {
                return ScriptRuntime.wrapBoolean(
                    realThis.propertyIsEnumerable(arg(args, 0)));
            }
            case :
                return realThis.text();
            case :
                return realThis.toString();
            case :
                int indent = ScriptRuntime.toInt32(args, 0);
                return realThis.toSource(indent);
            case : {
                return realThis.toXMLString();
            }
            case :
                return realThis.valueOf();
        }
        throw new IllegalArgumentException(String.valueOf(id));
    }
    private static Object arg(Object[] argsint i) {
        return (i < args.length) ? args[i] : .;
    }
    final XML newTextElementXML(XmlNode referenceXmlNode.QName qnameString value) {
        return .newTextElementXML(referenceqnamevalue);
    }
    /* TODO: Hopefully this can be replaced with ecmaToXml below. */
    final XML newXMLFromJs(Object inputObject) {
        return .newXMLFromJs(inputObject);
    }
    final XML ecmaToXml(Object object) {
        return .ecmaToXml(object);
    }
        //    TODO    Check this
        String quoted = .escapeAttributeValue(s);
        return quoted.substring(1, quoted.length() - 1);
    }
    final XML createEmptyXML() {
        return newXML(XmlNode.createEmpty(getProcessor()));
    }