Exemplo n.º 1
0
        AttributeDeclarationEntry AttributeDeclarationValue(Char c, AttributeDeclarationEntry value)
        {
            while (c.IsSpaceCharacter())
                c = _src.Next;

            var isfixed = false;

            if (c == Specification.NUM)
            {
                do
                {
                    _stringBuffer.Append(c);
                    c = _src.Next;

                    if (c == Specification.EOF)
                        throw new ArgumentException("The document ended unexpectedly.");
                    else if (c == Specification.GT)
                        break;
                }
                while (!c.IsSpaceCharacter());

                var tag = _stringBuffer.ToString();
                _stringBuffer.Clear();

                switch (tag)
                {
                    case "#REQUIRED":
                        value.ValueDefault = new AttributeRequiredValue();
                        return value;
                    case "#IMPLIED":
                        value.ValueDefault = new AttributeImpliedValue();
                        return value;
                    case "#FIXED":
                        isfixed = true;
                        break;
                }

                while (c.IsSpaceCharacter())
                    c = _src.Next;
            }

            var defvalue = AttributeDeclarationBeforeDefaultValue(c);
            _stringBuffer.Clear();
            _src.Advance();

            value.ValueDefault = new AttributeCustomValue
            {
                Value = defvalue,
                IsFixed = isfixed
            };
            return value;
        }
Exemplo n.º 2
0
        AttributeDeclarationEntry AttributeDeclarationType(Char c, AttributeDeclarationEntry value)
        {
            while (c.IsSpaceCharacter())
                c = _src.Next;

            if (c == Specification.RBO)
            {
                var type = new AttributeEnumeratedType();
                value.ValueType = type;
                AttributeDeclarationTypeEnumeration(_src.Next, type);
            }
            else if (c.IsUppercaseAscii())
            {
                var id = String.Empty;

                while (true)
                {
                    if (c.IsSpaceCharacter())
                    {
                        id = _stringBuffer.ToString();
                        _stringBuffer.Clear();
                        break;
                    }
                    else if (c == Specification.GT)
                        throw new ArgumentException("Declaration invalid.");
                    else if (c == Specification.NULL)
                    {
                        RaiseErrorOccurred(ErrorCode.NULL);
                        _stringBuffer.Append(Specification.REPLACEMENT);
                    }
                    else if (c == Specification.EOF)
                        throw new ArgumentException("The document ended unexpectedly.");
                    else
                        _stringBuffer.Append(c);

                    c = _src.Next;
                }

                switch (id)
                {
                    case "CDATA":
                        value.ValueType = new AttributeStringType();
                        break;
                    case "ID":
                        value.ValueType = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.ID };
                        break;
                    case "IDREF":
                        value.ValueType = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.IDREF };
                        break;
                    case "IDREFS":
                        value.ValueType = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.IDREFS };
                        break;
                    case "ENTITY":
                        value.ValueType = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.ENTITY };
                        break;
                    case "ENTITIES":
                        value.ValueType = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.ENTITIES };
                        break;
                    case "NMTOKEN":
                        value.ValueType = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.NMTOKEN };
                        break;
                    case "NMTOKENS":
                        value.ValueType = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.NMTOKENS };
                        break;
                    case "NOTATION":
                        var type = new AttributeEnumeratedType { IsNotation = true };
                        value.ValueType = type;

                        while (c.IsSpaceCharacter())
                            c = _src.Next;

                        if (c != Specification.RBO)
                            throw new ArgumentException("Declaration invalid.");

                        AttributeDeclarationTypeEnumeration(_src.Next, type);
                        break;
                    default:
                        throw new ArgumentException("Declaration invalid.");
                }
            }

            return AttributeDeclarationValue(_src.Next, value);
        }
Exemplo n.º 3
0
        AttributeDeclarationEntry AttributeDeclarationName(Char c)
        {
            var value = new AttributeDeclarationEntry();

            while (true)
            {
                if (c.IsSpaceCharacter())
                {
                    value.Name = _stringBuffer.ToString();
                    _stringBuffer.Clear();
                    break;
                }
                else if (c == Specification.GT)
                    throw new ArgumentException("Declaration invalid.");
                else if (c == Specification.NULL)
                {
                    RaiseErrorOccurred(ErrorCode.NULL);
                    _stringBuffer.Append(Specification.REPLACEMENT);
                }
                else if (c == Specification.EOF)
                    throw new ArgumentException("The document ended unexpectedly.");
                else
                    _stringBuffer.Append(c);

                c = _src.Next;
            }

            return AttributeDeclarationType(_src.Next, value);
        }
Exemplo n.º 4
0
        AttributeDeclarationEntry AttributeDeclarationValue(Char c, AttributeDeclarationEntry value)
        {
            while (c.IsSpaceCharacter())
                c = _stream.Next;

            var isfixed = false;

            if (c == Specification.NUM)
            {
                do
                {
                    _stringBuffer.Append(c);
                    c = _stream.Next;

                    if (c == Specification.EOF)
                        throw Errors.Xml(ErrorCode.EOF);
                    else if (c == Specification.GT)
                        break;
                }
                while (!c.IsSpaceCharacter());

                var tag = _stringBuffer.ToString();
                _stringBuffer.Clear();

                switch (tag)
                {
                    case REQUIRED:
                        value.Default = new AttributeRequiredValue();
                        return value;
                    case IMPLIED:
                        value.Default = new AttributeImpliedValue();
                        return value;
                    case FIXED:
                        isfixed = true;
                        break;
                }

                while (c.IsSpaceCharacter())
                    c = _stream.Next;
            }

            var defvalue = AttributeDeclarationBeforeDefaultValue(c);
            _stream.Advance();

            value.Default = new AttributeCustomValue
            {
                Value = defvalue,
                IsFixed = isfixed
            };
            return value;
        }
Exemplo n.º 5
0
        AttributeDeclarationEntry AttributeDeclarationType(Char c, AttributeDeclarationEntry value)
        {
            while (c.IsSpaceCharacter())
                c = _stream.Next;

            if (c == Specification.RBO)
            {
                var type = new AttributeEnumeratedType();
                value.Type = type;
                AttributeDeclarationTypeEnumeration(_stream.Next, type);
            }
            else if (c.IsUppercaseAscii())
            {
                var id = String.Empty;

                while (true)
                {
                    if (c.IsSpaceCharacter())
                    {
                        id = _stringBuffer.ToString();
                        _stringBuffer.Clear();
                        break;
                    }
                    else if (c == Specification.GT)
                        throw Errors.Xml(ErrorCode.DtdAttListInvalid);
                    else if (c == Specification.NULL)
                    {
                        RaiseErrorOccurred(ErrorCode.NULL);
                        _stringBuffer.Append(Specification.REPLACEMENT);
                    }
                    else if (c == Specification.EOF)
                        throw Errors.Xml(ErrorCode.EOF);
                    else
                        _stringBuffer.Append(c);

                    c = _stream.Next;
                }

                switch (id)
                {
                    case CDATA:
                        value.Type = new AttributeStringType();
                        break;

                    case ID:
                        value.Type = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.ID };
                        break;

                    case IDREF:
                        value.Type = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.IDREF };
                        break;

                    case IDREFS:
                        value.Type = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.IDREFS };
                        break;

                    case ENTITY:
                        value.Type = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.ENTITY };
                        break;

                    case ENTITIES:
                        value.Type = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.ENTITIES };
                        break;

                    case NMTOKEN:
                        value.Type = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.NMTOKEN };
                        break;

                    case NMTOKENS:
                        value.Type = new AttributeTokenizedType { Value = AttributeTokenizedType.TokenizedType.NMTOKENS };
                        break;

                    case NOTATION:
                        var type = new AttributeEnumeratedType { IsNotation = true };
                        value.Type = type;

                        while (c.IsSpaceCharacter())
                            c = _stream.Next;

                        if (c != Specification.RBO)
                            throw Errors.Xml(ErrorCode.DtdAttListInvalid);

                        AttributeDeclarationTypeEnumeration(_stream.Next, type);
                        break;

                    default:
                        throw Errors.Xml(ErrorCode.DtdAttListInvalid);
                }
            }

            return AttributeDeclarationValue(_stream.Next, value);
        }
Exemplo n.º 6
0
        AttributeDeclarationEntry AttributeDeclarationName(Char c)
        {
            var value = new AttributeDeclarationEntry();

            do
            {
                _stringBuffer.Append(c);
                c = _stream.Next;
            }
            while (c.IsXmlName());

            if (!c.IsSpaceCharacter())
                throw Errors.Xml(ErrorCode.DtdAttListInvalid);

            value.Name = _stringBuffer.ToString();
            _stringBuffer.Clear();
            return AttributeDeclarationType(_stream.Next, value);
        }