Example #1
0
        /** Writes this attribute to an output stream */
        public void Write(StreamWriter writer)
        {
            writer.Write(Name + " ");
            if (Type is string)
            {
                writer.Write(Type);
            }
            else if (Type is DTDEnumeration)
            {
                DTDEnumeration dtdEnum = (DTDEnumeration)Type;
                dtdEnum.Write(writer);
            }
            else if (Type is DTDNotationList)
            {
                DTDNotationList dtdnl = (DTDNotationList)Type;
                dtdnl.Write(writer);
            }

            if (Decl != null)
            {
                Decl.Write(writer);
            }

            if (DefaultValue != null)
            {
                writer.Write(" \"");
                writer.Write(DefaultValue);
                writer.Write("\"");
            }
            //writer.WriteLine(">");                           original java comment: "Bug!"
        }
        public override bool Equals(object ob)
        {
            if (ob == this)
            {
                return(true);
            }
            if (!(ob is DTDEnumeration))
            {
                return(false);
            }

            DTDEnumeration other = (DTDEnumeration)ob;

            return(Items.Equals(other.Items));
        }
Example #3
0
        protected DTDEnumeration ParseEnumeration()
        {
            DTDEnumeration enumeration = new DTDEnumeration();

            for (;;)
            {
                Token token = Scanner.Get();

                if ((token.Type != Scanner.IDENTIFIER) &&
                    (token.Type != Scanner.NMTOKEN))
                {
                    throw new DTDParseException(Scanner.GetUriId(),
                                                "Invalid token in enumeration: " +
                                                token.Type.Name, Scanner.GetLineNumber(),
                                                Scanner.GetColumn());
                }

                enumeration.Items.Add(token.Value);

                token = Scanner.Peek();

                if (token.Type == Scanner.RPAREN)
                {
                    Scanner.Get();
                    return(enumeration);
                }
                if (token.Type != Scanner.PIPE)
                {
                    throw new DTDParseException(Scanner.GetUriId(),
                                                "Invalid token in enumeration: " +
                                                token.Type.Name, Scanner.GetLineNumber(),
                                                Scanner.GetColumn());
                }
                Scanner.Get(); // eat the pipe
            }
        }