XmlNode.QName toNodeQName(Context cx, String name, boolean attribute) { XmlNode.Namespace defaultNamespace = getDefaultNamespace(cx).getDelegate(); if (name != null && name.equals("*")) { return XmlNode.QName.create(null, null); } else { if (attribute) { return XmlNode.QName.create(XmlNode.Namespace.GLOBAL, name); } else { return XmlNode.QName.create(defaultNamespace, name); } } }
XmlNode.QName toNodeQName(Context cx, Object namespaceValue, Object nameValue) { // This is duplication of constructQName(cx, namespaceValue, nameValue) // but for XMLName String localName; if (nameValue instanceof QName) { QName qname = (QName) nameValue; localName = qname.localName(); } else { localName = ScriptRuntime.toString(nameValue); } XmlNode.Namespace ns; if (namespaceValue == Undefined.instance) { if ("*".equals(localName)) { ns = null; } else { ns = getDefaultNamespace(cx).getDelegate(); } } else if (namespaceValue == null) { ns = null; } else if (namespaceValue instanceof Namespace) { ns = ((Namespace) namespaceValue).getDelegate(); } else { ns = this.namespacePrototype.constructNamespace(namespaceValue).getDelegate(); } if (localName != null && localName.equals("*")) localName = null; return XmlNode.QName.create(ns, localName); }
private void exportToScope(boolean sealed) { xmlPrototype = newXML(XmlNode.createText(options, "")); xmlListPrototype = newXMLList(); namespacePrototype = Namespace.create(this.globalScope, null, XmlNode.Namespace.GLOBAL); qnamePrototype = QName.create( this, this.globalScope, null, XmlNode.QName.create(XmlNode.Namespace.create(""), "")); xmlPrototype.exportAsJSClass(sealed); xmlListPrototype.exportAsJSClass(sealed); namespacePrototype.exportAsJSClass(sealed); qnamePrototype.exportAsJSClass(sealed); }
/** @deprecated */ XMLName toAttributeName(Context cx, Object nameValue) { if (nameValue instanceof XMLName) { // TODO Will this always be an XMLName of type attribute name? return (XMLName) nameValue; } else if (nameValue instanceof QName) { return XMLName.create(((QName) nameValue).getDelegate(), true, false); } else if (nameValue instanceof Boolean || nameValue instanceof Number || nameValue == Undefined.instance || nameValue == null) { throw badXMLName(nameValue); } else { // TODO Not 100% sure that putting these in global namespace is the right thing to do String localName = null; if (nameValue instanceof String) { localName = (String) nameValue; } else { localName = ScriptRuntime.toString(nameValue); } if (localName != null && localName.equals("*")) localName = null; return XMLName.create( XmlNode.QName.create(XmlNode.Namespace.create(""), localName), true, false); } }