示例#1
0
 public DmNode CreateChild(DmQName name)
 {
     if (_childs == null)
         _childs = new Dictionary<DmQName, DmNode>();
     DmNode node;
     if (_childs.TryGetValue(name, out node))
         return node;
     node = new DmElement(name);
     node._parent = this;
     _childs.Add(name, node);
     return node;
 }
示例#2
0
 public DmNode CreateAttribute(DmQName name)
 {
     if (_attributes == null)
         _attributes = new Dictionary<DmQName, DmNode>();
     DmNode node;
     if (_attributes.TryGetValue(name, out node))
         return node;
     node = new DmAttribute(name);
     node._parent = this;
     _attributes.Add(name, node);
     return node;
 }
示例#3
0
 public DmNode CreateChildPI(string name, XmlNameTable nameTable)
 {
     DmQName id = new DmQName(String.Empty, name, DmPI.InternalNs, nameTable);
     if (_childs == null)
         _childs = new Dictionary<DmQName, DmNode>();
     DmNode node;
     if (_childs.TryGetValue(id, out node))
         return node;
     node = new DmPI(id.localName);
     node._parent = this;
     _childs.Add(id, node);
     return node;
 }
示例#4
0
 public override void WriteStartAttribute(string prefix, string localName, string namespaceUri)
 {
     if (context == null)
         throw new XQueryException(Properties.Resources.InvalidAttributeSequence);
     if (prefix == null)
         prefix = String.Empty;
     if (localName == null)
         throw new ArgumentException();
     if (namespaceUri == null)
         namespaceUri = String.Empty;
     if (!cflag || _text != null)
         throw new XQueryException(Properties.Resources.XQTY0024, new XmlQualifiedName(localName, namespaceUri));
     _state = WriteState.Attribute;
     _attr_text = null;
     DmNode node = context.node;
     XdmElement element = context.element;
     if (namespaceUri == xmlns)
     {
         ns2 = new XdmNamespace();
         ns2._name = String.IsNullOrEmpty(prefix) ? 
             String.Empty : localName;
         nsflag = true;
         if (NamespaceManager != null)
         {
             if (!context.scopeFlag)
             {
                 NamespaceManager.PushScope();
                 context.scopeFlag = true;
             }
         }
     }
     else
     {
         if (attr == null)
             element._attributes = attr = new XdmAttribute();
         else
         {
             XdmAttribute tmp = new XdmAttribute();
             attr._next = tmp;
             attr = tmp;
         }
         if (NamespaceManager != null && prefix != "")
         {
             string ns = NamespaceManager.LookupNamespace(prefix);
             if (ns != null && ns != namespaceUri)
             {
                 prefix = NamespaceManager.LookupPrefix(namespaceUri);
                 if (prefix == null)
                 {   // Generate new prefix
                     int k = 1;
                     do
                     {
                         prefix = String.Format("ns{0}", k++);
                     }
                     while (NamespaceManager.LookupNamespace(prefix) != null);
                     NamespaceManager.AddNamespace(prefix, namespaceUri);
                 }
             }
         }
         DmQName name = new DmQName(prefix, localName, namespaceUri, NameTable);
         attr._dm = (DmAttribute)context.node.CreateAttribute(name);
         nsflag = false;
         if (hs != null)
         {
             if (hs.Contains(name))
                 throw new XQueryException(Properties.Resources.XQDY0025,
                     new XmlQualifiedName(node.LocalName, node.NamespaceURI), 
                     new XmlQualifiedName(localName, namespaceUri));
             hs.Add(name);
         }
     }
 }
示例#5
0
 public DmElement(DmQName name)
 {
     _name = name;
 }
示例#6
0
 public DmAttribute(DmQName name)
 {
     _name = name;
 }