Exemplo n.º 1
0
        private void ReadAttribute(byte ident)
        {
            if (attributes.Count == attr_count)
            {
                attributes.Add(new AttrNodeInfo(this));
            }
            AttrNodeInfo a = attributes [attr_count++];

            a.Reset();
            a.Position = source.Position;

            switch (ident)
            {
            case BF.AttrString:
                a.LocalName = ReadUTF8();
                break;

            case BF.AttrStringPrefix:
                a.Prefix = ReadUTF8();
                a.NSSlot = ns_slot++;
                goto case BF.AttrString;

            case BF.AttrIndex:
                a.DictLocalName = ReadDictName();
                break;

            case BF.AttrIndexPrefix:
                a.Prefix = ReadUTF8();
                a.NSSlot = ns_slot++;
                goto case BF.AttrIndex;

            default:
                if (BF.PrefixNAttrStringStart <= ident && ident <= BF.PrefixNAttrStringEnd)
                {
                    a.Prefix    = ((char)('a' + ident - BF.PrefixNAttrStringStart)).ToString();
                    a.LocalName = ReadUTF8();
                    break;
                }
                else if (BF.PrefixNAttrIndexStart <= ident && ident <= BF.PrefixNAttrIndexEnd)
                {
                    a.Prefix        = ((char)('a' + ident - BF.PrefixNAttrIndexStart)).ToString();
                    a.DictLocalName = ReadDictName();
                    break;
                }
                else
                {
                    throw new XmlException(String.Format("Unexpected attribute node type: 0x{0:X02}", ident));
                }
            }
            ReadAttributeValueBinary(a);
        }
Exemplo n.º 2
0
        private void ReadNamespace(byte ident)
        {
            // create attrubute slot.
            if (attributes.Count == attr_count)
            {
                attributes.Add(new AttrNodeInfo(this));
            }
            AttrNodeInfo a = attributes [attr_count++];

            a.Reset();
            a.Position = source.Position;

            string prefix = null, ns = null;
            XmlDictionaryString dns = null;

            switch (ident)
            {
            case BF.DefaultNSString:
                prefix = String.Empty;
                ns     = ReadUTF8();
                break;

            case BF.PrefixNSString:
                prefix = ReadUTF8();
                ns     = ReadUTF8();
                break;

            case BF.DefaultNSIndex:
                prefix = String.Empty;
                dns    = ReadDictName();
                ns_dict_store.Add(ns_store.Count, dns);
                ns = dns.Value;
                break;

            case BF.PrefixNSIndex:
                prefix = ReadUTF8();
                dns    = ReadDictName();
                ns_dict_store.Add(ns_store.Count, dns);
                ns = dns.Value;
                break;
            }

            // fill attribute slot.
            a.Prefix     = prefix.Length > 0 ? "xmlns" : String.Empty;
            a.LocalName  = prefix.Length > 0 ? prefix : "xmlns";
            a.NS         = "http://www.w3.org/2000/xmlns/";
            a.ValueIndex = attr_value_count;
            if (attr_value_count == attr_values.Count)
            {
                attr_values.Add(new NodeInfo(true));
            }
            NodeInfo v = attr_values [attr_value_count++];

            v.Reset();
            v.Value     = ns;
            v.ValueType = BF.Chars8;
            v.NodeType  = XmlNodeType.Text;

            ns_store.Add(new QName(prefix, ns));
            context.NamespaceManager.AddNamespace(prefix, ns);
        }