public XMLList (XMLLib lib, object inputObject) : this (lib) { string frag; if (inputObject == null || inputObject is Undefined) { frag = ""; } else if (inputObject is XML) { XML xml = (XML)inputObject; Add (xml); } else if (inputObject is XMLList) { XMLList xmll = (XMLList)inputObject; AddRange (xmll); } else { frag = ScriptConvert.ToString (inputObject).Trim (); if (!frag.StartsWith ("<>")) { frag = "<>" + frag + "</>"; } frag = "<fragment>" + frag.Substring (2); if (!frag.EndsWith ("</>")) { throw ScriptRuntime.TypeError ("XML with anonymous tag missing end anonymous tag"); } frag = frag.Substring (0, frag.Length - 3) + "</fragment>"; XML orgXML = XML.CreateFromJS (lib, frag); // Now orphan the children and add them to our XMLList. XMLList children = (XMLList)orgXML.Children (); AddRange (children); } }
internal static Namespace Parse(XMLLib lib, Context cx, Object uriValue) { String prefix; String uri; if (uriValue is Namespace) { Namespace ns = (Namespace)uriValue; prefix = ns.Prefix; uri = ns.Uri; } else if (uriValue is QName) { QName qname = (QName)uriValue; uri = qname.Uri; if (uri != null) { prefix = qname.Prefix; } else { uri = qname.ToString(); prefix = null; } } else { uri = ScriptConvert.ToString(uriValue); prefix = (uri.Length == 0) ? "" : null; } return(new Namespace(lib, prefix, uri)); }
internal static XMLName Parse(XMLLib lib, Context cx, string name) { if (name == null) { throw new ArgumentNullException("name"); } int l = name.Length; if (l != 0) { char firstChar = name [0]; if (firstChar == '*') { if (l == 1) { return(FormStar()); } } else if (firstChar == '@') { XMLName xmlName = FormProperty("", name.Substring(1)); xmlName.IsAttributeName = true; return(xmlName); } } String uri = lib.GetDefaultNamespaceURI(cx); return(XMLName.FormProperty(uri, name)); }
public Namespace(XMLLib lib, string uri) : base(lib.GlobalScope, lib.namespacePrototype) { if (uri == null) throw new System.ArgumentException (); this.lib = lib; this.prefix = (uri.Length == 0) ? "" : null; this.uri = uri; }
internal QName (XMLLib lib, string uri, string localName, string prefix) : base (lib.GlobalScope, lib.qnamePrototype) { if (localName == null) throw new System.ArgumentException (); this.lib = lib; this.uri = uri; this.prefix = prefix; this.localName = localName; }
internal static QName Parse(XMLLib lib, Context cx, object namespaceValue, object nameValue) { String uri; String localName; String prefix; if (nameValue is QName) { QName qname = (QName)nameValue; localName = qname.LocalName; } else { localName = ScriptConvert.ToString(nameValue); } Namespace ns; if (namespaceValue == Undefined.Value) { if ("*".Equals(localName)) { ns = null; } else { ns = lib.GetDefaultNamespace(cx); } } else if (namespaceValue == null) { ns = null; } else if (namespaceValue is Namespace) { ns = (Namespace)namespaceValue; } else { ns = Namespace.Parse(lib, cx, namespaceValue); } if (ns == null) { uri = null; prefix = null; } else { uri = ns.Uri; prefix = ns.Prefix; } return(new QName(lib, uri, localName, prefix)); }
public Namespace(XMLLib lib, string uri) : base(lib.GlobalScope, lib.namespacePrototype) { if (uri == null) { throw new System.ArgumentException(); } this.lib = lib; this.prefix = (uri.Length == 0) ? "" : null; this.uri = uri; }
internal QName(XMLLib lib, string uri, string localName, string prefix) : base(lib.GlobalScope, lib.qnamePrototype) { if (localName == null) { throw new System.ArgumentException(); } this.lib = lib; this.uri = uri; this.prefix = prefix; this.localName = localName; }
public static XMLLib ExtractFromScope(IScriptable scope) { XMLLib lib = ExtractFromScopeOrNull(scope); if (lib != null) { return(lib); } string msg = ScriptRuntime.GetMessage("msg.XML.not.available"); throw Context.ReportRuntimeError(msg); }
public static Namespace Parse(XMLLib lib, Context cx, Object prefixValue, Object uriValue) { String prefix; String uri; if (uriValue is QName) { QName qname = (QName)uriValue; uri = qname.Uri; if (uri == null) { uri = qname.ToString(); } } else { uri = ScriptConvert.ToString(uriValue); } if (uri.Length == 0) { if (prefixValue == Undefined.Value) { prefix = ""; } else { prefix = ScriptConvert.ToString(prefixValue); if (prefix.Length != 0) { throw ScriptRuntime.TypeError( "Illegal prefix '" + prefix + "' for 'no namespace'."); } } } else if (prefixValue == Undefined.Value) { prefix = ""; } else if (!lib.IsXMLName(cx, prefixValue)) { prefix = ""; } else { prefix = ScriptConvert.ToString(prefixValue); } return(new Namespace(lib, prefix, uri)); }
public Namespace(XMLLib lib, string prefix, string uri) : base(lib.GlobalScope, lib.namespacePrototype) { if (uri == null) throw new System.ArgumentException (); if (uri.Length == 0) { // prefix should be "" for empty uri if (prefix == null) throw new System.ArgumentException (); if (prefix.Length != 0) throw new System.ArgumentException (); } this.lib = lib; this.prefix = prefix; this.uri = uri; }
internal static QName Parse(XMLLib lib, Context cx, object value) { QName result; if (value is QName) { QName qname = (QName)value; result = new QName(lib, qname.Uri, qname.LocalName, qname.Prefix); } else { result = Parse(lib, cx, ScriptConvert.ToString(value)); } return(result); }
public static void Init(IScriptable scope, bool zealed) { XMLLib impl = new XMLLib(scope); impl.SetDefaultSettings(); impl.BindToScope(scope); impl.xmlPrototype = XML.CreateEmptyXml(impl); impl.xmlPrototype.ExportAsJSClass(zealed); impl.xmlListPrototype = new XMLList(impl); impl.xmlListPrototype.ExportAsJSClass(zealed); impl.qnamePrototype = new QName(impl); impl.qnamePrototype.ExportAsJSClass(zealed); impl.namespacePrototype = new Namespace(impl); impl.namespacePrototype.ExportAsJSClass(zealed); }
public XMLList(XMLLib lib, object inputObject) : this(lib) { string frag; if (inputObject == null || inputObject is Undefined) { frag = ""; } else if (inputObject is XML) { XML xml = (XML)inputObject; Add(xml); } else if (inputObject is XMLList) { XMLList xmll = (XMLList)inputObject; AddRange(xmll); } else { frag = ScriptConvert.ToString(inputObject).Trim(); if (!frag.StartsWith("<>")) { frag = "<>" + frag + "</>"; } frag = "<fragment>" + frag.Substring(2); if (!frag.EndsWith("</>")) { throw ScriptRuntime.TypeError("XML with anonymous tag missing end anonymous tag"); } frag = frag.Substring(0, frag.Length - 3) + "</fragment>"; XML orgXML = XML.CreateFromJS(lib, frag); // Now orphan the children and add them to our XMLList. XMLList children = (XMLList)orgXML.Children(); AddRange(children); } }
public Namespace(XMLLib lib, string prefix, string uri) : base(lib.GlobalScope, lib.namespacePrototype) { if (uri == null) { throw new System.ArgumentException(); } if (uri.Length == 0) { // prefix should be "" for empty uri if (prefix == null) { throw new System.ArgumentException(); } if (prefix.Length != 0) { throw new System.ArgumentException(); } } this.lib = lib; this.prefix = prefix; this.uri = uri; }
internal static QName Parse(XMLLib lib, Context cx, string localName) { if (localName == null) { throw new ArgumentNullException("localName"); } String uri; String prefix; if ("*".Equals(localName)) { uri = null; prefix = null; } else { Namespace ns = lib.GetDefaultNamespace(cx); uri = ns.Uri; prefix = ns.Prefix; } return(new QName(lib, uri, localName, prefix)); }
protected internal XMLObject (XMLLib lib, XMLObject prototype) : base (lib.GlobalScope, prototype) { this.lib = lib; }
internal QName(XMLLib lib) : base(lib.GlobalScope, lib.qnamePrototype) { this.lib = lib; }
internal static Namespace Parse(XMLLib lib, Context cx) { return(new Namespace(lib, "", "")); }
public XML(XMLLib lib, XmlNode underlyingNode) : base(lib, lib.xmlPrototype) { this.lib = lib; this.underlyingNode = underlyingNode; }
internal static XMLName Parse(XMLLib lib, Context cx, string name) { if (name == null) throw new ArgumentNullException ("name"); int l = name.Length; if (l != 0) { char firstChar = name [0]; if (firstChar == '*') { if (l == 1) { return FormStar (); } } else if (firstChar == '@') { XMLName xmlName = FormProperty ("", name.Substring (1)); xmlName.IsAttributeName = true; return xmlName; } } String uri = lib.GetDefaultNamespaceURI (cx); return XMLName.FormProperty (uri, name); }
internal QName(XMLLib lib, QName qname) : this(lib, qname.Uri, qname.LocalName, qname.Prefix) { ; }
internal static XML CreateFromJS(XMLLib lib, Object inputObject) { string frag = ""; if (inputObject == null || inputObject == Undefined.Value) { frag = ""; } else if (inputObject is XMLObject) { frag = ((XMLObject)inputObject).ToXMLString (); } else { frag = ScriptConvert.ToString (inputObject); } if (frag.Trim ().StartsWith ("<>")) { throw ScriptRuntime.TypeError ("Invalid use of XML object anonymous tags <></>."); } XmlDocument doc = null; if (frag.IndexOf ("<") == -1) { // Must be solo text node doc = new XmlDocument (); XmlNode node = doc.CreateTextNode (frag); return new XML (lib, node); } doc = new XmlDocument (); try { using (StringReader sr = new StringReader (frag)) { XmlTextReader xr = new XMLTextReader (lib, sr); doc.Load (xr); } } catch (XmlException e) { throw ScriptRuntime.TypeError (e.Message); } return new XML (lib, doc); }
public static Namespace Parse (XMLLib lib, Context cx, Object prefixValue, Object uriValue) { String prefix; String uri; if (uriValue is QName) { QName qname = (QName)uriValue; uri = qname.Uri; if (uri == null) { uri = qname.ToString (); } } else { uri = ScriptConvert.ToString (uriValue); } if (uri.Length == 0) { if (prefixValue == Undefined.Value) { prefix = ""; } else { prefix = ScriptConvert.ToString (prefixValue); if (prefix.Length != 0) { throw ScriptRuntime.TypeError ( "Illegal prefix '" + prefix + "' for 'no namespace'."); } } } else if (prefixValue == Undefined.Value) { prefix = ""; } else if (!lib.IsXMLName (cx, prefixValue)) { prefix = ""; } else { prefix = ScriptConvert.ToString (prefixValue); } return new Namespace (lib, prefix, uri); }
internal static Namespace Parse (XMLLib lib, Context cx, Object uriValue) { String prefix; String uri; if (uriValue is Namespace) { Namespace ns = (Namespace)uriValue; prefix = ns.Prefix; uri = ns.Uri; } else if (uriValue is QName) { QName qname = (QName)uriValue; uri = qname.Uri; if (uri != null) { prefix = qname.Prefix; } else { uri = qname.ToString (); prefix = null; } } else { uri = ScriptConvert.ToString (uriValue); prefix = (uri.Length == 0) ? "" : null; } return new Namespace (lib, prefix, uri); }
internal static XMLName Parse(XMLLib lib, Context cx, Object value) { XMLName result; if (value is XMLName) { result = (XMLName)value; } else if (value is String) { String str = (String)value; long test = ScriptRuntime.testUint32String(str); if (test >= 0) { ScriptRuntime.storeUint32Result(cx, test); result = null; } else { result = Parse(lib, cx, str); } } else if (CliHelper.IsNumber(value)) { double d = ScriptConvert.ToNumber(value); long l = (long)d; if (l == d && 0 <= l && l <= 0xFFFFFFFFL) { ScriptRuntime.storeUint32Result(cx, l); result = null; } else { throw XMLLib.BadXMLName(value); } } else if (value is QName) { QName qname = (QName)value; String uri = qname.Uri; bool number = false; result = null; if (uri != null && uri.Length == 0) { // Only in this case qname.toString() can resemble uint32 long test = ScriptRuntime.testUint32String(uri); if (test >= 0) { ScriptRuntime.storeUint32Result(cx, test); number = true; } } if (!number) { result = XMLName.FormProperty(uri, qname.LocalName); } } else if (value is Boolean || value == Undefined.Value || value == null) { throw XMLLib.BadXMLName(value); } else { String str = ScriptConvert.ToString(value); long test = ScriptRuntime.testUint32String(str); if (test >= 0) { ScriptRuntime.storeUint32Result(cx, test); result = null; } else { result = Parse(lib, cx, str); } } return(result); }
internal XMLCtor(XML xml, object tag, int id, int arity) : base(xml, tag, id, arity) { _lib = xml.lib; ActivatePrototypeMap(MaxFunctionId); }
public static void Init (IScriptable scope, bool zealed) { XMLLib impl = new XMLLib (scope); impl.SetDefaultSettings (); impl.BindToScope (scope); impl.xmlPrototype = XML.CreateEmptyXml (impl); impl.xmlPrototype.ExportAsJSClass (zealed); impl.xmlListPrototype = new XMLList (impl); impl.xmlListPrototype.ExportAsJSClass (zealed); impl.qnamePrototype = new QName (impl); impl.qnamePrototype.ExportAsJSClass (zealed); impl.namespacePrototype = new Namespace (impl); impl.namespacePrototype.ExportAsJSClass (zealed); }
public XMLTextReader(XMLLib lib, StringReader sr) : base(sr) { this.lib = lib; }
internal static QName Parse (XMLLib lib, Context cx, object value) { QName result; if (value is QName) { QName qname = (QName)value; result = new QName (lib, qname.Uri, qname.LocalName, qname.Prefix); } else { result = Parse (lib, cx, ScriptConvert.ToString (value)); } return result; }
internal static XML CreateEmptyXml(XMLLib impl) { return new XML (impl); }
internal static QName Parse (XMLLib lib, Context cx, string localName) { if (localName == null) throw new ArgumentNullException ("localName"); String uri; String prefix; if ("*".Equals (localName)) { uri = null; prefix = null; } else { Namespace ns = lib.GetDefaultNamespace (cx); uri = ns.Uri; prefix = ns.Prefix; } return new QName (lib, uri, localName, prefix); }
public XML(XMLLib lib) : base(lib, lib.xmlPrototype) { this.lib = lib; }
internal static QName Parse (XMLLib lib, Context cx, object namespaceValue, object nameValue) { String uri; String localName; String prefix; if (nameValue is QName) { QName qname = (QName)nameValue; localName = qname.LocalName; } else { localName = ScriptConvert.ToString (nameValue); } Namespace ns; if (namespaceValue == Undefined.Value) { if ("*".Equals (localName)) { ns = null; } else { ns = lib.GetDefaultNamespace (cx); } } else if (namespaceValue == null) { ns = null; } else if (namespaceValue is Namespace) { ns = (Namespace)namespaceValue; } else { ns = Namespace.Parse (lib, cx, namespaceValue); } if (ns == null) { uri = null; prefix = null; } else { uri = ns.Uri; prefix = ns.Prefix; } return new QName (lib, uri, localName, prefix); }
internal static XMLName Parse(XMLLib lib, Context cx, Object value) { XMLName result; if (value is XMLName) { result = (XMLName)value; } else if (value is String) { String str = (String)value; long test = ScriptRuntime.testUint32String (str); if (test >= 0) { ScriptRuntime.storeUint32Result (cx, test); result = null; } else { result = Parse (lib, cx, str); } } else if (CliHelper.IsNumber (value)) { double d = ScriptConvert.ToNumber (value); long l = (long)d; if (l == d && 0 <= l && l <= 0xFFFFFFFFL) { ScriptRuntime.storeUint32Result (cx, l); result = null; } else { throw XMLLib.BadXMLName (value); } } else if (value is QName) { QName qname = (QName)value; String uri = qname.Uri; bool number = false; result = null; if (uri != null && uri.Length == 0) { // Only in this case qname.toString() can resemble uint32 long test = ScriptRuntime.testUint32String (uri); if (test >= 0) { ScriptRuntime.storeUint32Result (cx, test); number = true; } } if (!number) { result = XMLName.FormProperty (uri, qname.LocalName); } } else if (value is Boolean || value == Undefined.Value || value == null) { throw XMLLib.BadXMLName (value); } else { String str = ScriptConvert.ToString (value); long test = ScriptRuntime.testUint32String (str); if (test >= 0) { ScriptRuntime.storeUint32Result (cx, test); result = null; } else { result = Parse (lib, cx, str); } } return result; }
internal XMLCtor(XML xml, object tag, int id, int arity) : base(xml, tag, id, arity) { this.lib = xml.lib; ActivatePrototypeMap(MAX_FUNCTION_ID); }
internal XMLCtor(XML xml, object tag, int id, int arity) : base(xml, tag, id, arity) { this.lib = xml.lib; ActivatePrototypeMap (MAX_FUNCTION_ID); }
internal QName (XMLLib lib, QName qname) : this (lib, qname.Uri, qname.LocalName, qname.Prefix) { ; }
internal QName (XMLLib lib) : base (lib.GlobalScope, lib.qnamePrototype) { this.lib = lib; }
internal Namespace(XMLLib lib) : base(lib.GlobalScope, lib.namespacePrototype) { this.lib = lib; }
internal static Namespace Parse (XMLLib lib, Context cx) { return new Namespace (lib, "", ""); }
public XMLList(XMLLib lib) : base(lib, lib.xmlListPrototype) { this.lib = lib; }
internal Namespace (XMLLib lib) : base (lib.GlobalScope, lib.namespacePrototype) { this.lib = lib; }
protected internal XMLObject(XMLLib lib, XMLObject prototype) : base(lib.GlobalScope, prototype) { this.lib = lib; }