(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Xml / QualifiedName.cs
blobacc1f5c5d21da3cc39878560771701ff1dbb70d9
1 //
2 // Microsoft.Web.Services.Xml.QualifiedName.cs
3 //
4 // Author: Todd Berman <tberman@gentoo.org>
5 //
6 // (C) 2003 Todd Berman
8 using System;
9 using System.Xml;
11 namespace Microsoft.Web.Services.Xml
13 public class QualifiedName : XmlQualifiedName
16 private string _prefix;
18 public QualifiedName (string prefix, string name, string namespaceURI) : base (name, namespaceURI)
20 if(prefix == null) {
21 throw new ArgumentNullException ("prefix");
23 _prefix = prefix;
26 public static QualifiedName FromString (string value, XmlNode node)
28 if(node == null) {
29 throw new ArgumentNullException ("node");
32 if(value.IndexOf(':') > 0) {
33 string[] strings = value.Split(':');
35 if(strings.Length != 2 || strings[0].Length == 0 || strings[1].Length == 0) {
36 throw new FormatException ("xml_ImproperQName");
39 string nspace = node.GetNamespaceOfPrefix (strings[0]);
41 if(nspace == null) {
42 throw new FormatException ("xml_CouldNotResolveNSPrefix");
45 if(nspace.Length == 0) {
46 throw new FormatException ("xml_CouldNotResolveNSPrefix");
49 return new QualifiedName (strings[0], strings[1], nspace);
52 throw new FormatException ("xml_ImproperQName");
55 public XmlAttribute GetNamespaceDecl (XmlDocument document)
57 if(document == null) {
58 throw new ArgumentNullException ("document");
60 XmlAttribute attrib = document.CreateAttribute("xmlns",
61 _prefix,
62 "http://www.w3.org/2000/xmlns");
64 attrib.Value = Namespace;
65 return attrib;
68 public void GetQualifiedName (XmlDocument document, XmlElement element)
70 if(document == null) {
71 throw new ArgumentNullException ("document");
73 if(element == null) {
74 throw new ArgumentNullException ("element");
76 element.InnerText = Value;
77 if(Namespace != element.NamespaceURI) {
78 element.Attributes.Append(GetNamespaceDecl(document));
82 public string Prefix {
83 get { return _prefix; }
86 public string Value {
87 get { return _prefix + ":" + Name; }