Ejemplo n.º 1
0
        protected void PEReference(Char c, Boolean use = true)
        {
            var buffer = Pool.NewStringBuilder();

            if (c.IsXmlNameStart())
            {
                do
                {
                    buffer.Append(c);
                    c = _stream.Next;
                }while (c.IsXmlName());

                var temp = buffer.ToPool();

                if (c == Specification.SC)
                {
                    var p = _container.GetParameter(temp);

                    if (p != null)
                    {
                        if (use)
                        {
                            _stream.Push(temp, p.NodeValue);
                            return;
                        }
                        else
                        {
                            throw Errors.Xml(ErrorCode.DtdPEReferenceInvalid);
                        }
                    }
                }
            }

            if (use)
            {
                throw Errors.Xml(ErrorCode.DtdPEReferenceInvalid);
            }

            _stringBuffer.Append(Specification.PERCENT).Append(buffer.ToString());
        }
Ejemplo n.º 2
0
        protected void PEReference(Char c, Boolean use = true)
        {
            var buffer = StringBuilderPool.Obtain();

            if (c.IsXmlNameStart())
            {
                do
                {
                    buffer.Append(c);
                    c = _stream.Next;
                }while (c.IsXmlName());

                var temp = buffer.ToPool();

                if (c == Symbols.Semicolon)
                {
                    var p = _container.GetParameter(temp);

                    if (p != null)
                    {
                        if (use)
                        {
                            _stream.Push(temp, p.NodeValue);
                            return;
                        }
                        else
                        {
                            throw new DomException(DomError.InvalidAccess);
                        }
                    }
                }
            }

            if (use)
            {
                throw new DomException(DomError.InvalidAccess);
            }

            StringBuffer.Append(Symbols.Percent).Append(buffer.ToString());
        }