protected void ParseAttlist() { Token token = Expect(Scanner.IDENTIFIER); DTDElement element = (DTDElement)Dtd.Elements[token.Value]; DTDAttlist attlist = new DTDAttlist(token.Value); Dtd.Items.Add(attlist); if (element == null) { element = new DTDElement(token.Value); Dtd.Elements[token.Value] = element; } token = Scanner.Peek(); while (token.Type != Scanner.GT) { ParseAttdef(Scanner, element, attlist); token = Scanner.Peek(); } // MAW Version 1.17 // Prior to this version, the parser didn't actually consume the > at the // end of the ATTLIST definition. Because the parser ignored unexpected tokens // at the top level, it was ignoring the >. In parsing DOCBOOK, however, there // were two unexpected tokens, bringing this error to light. Expect(Scanner.GT); }
public override bool Equals(object ob) { if (ob == this) { return(true); } if (!(ob is DTDAttlist)) { return(false); } DTDAttlist other = (DTDAttlist)ob; if ((Name == null) && (other.Name != null)) { return(false); } if ((Name != null) && Name != other.Name) { return(false); } return(Attributes.Equals(other.Attributes)); }
protected void ParseAttdef(Scanner scanner, DTDElement element, DTDAttlist attlist) { Token token = Expect(Scanner.IDENTIFIER); DTDAttribute attr = new DTDAttribute(token.Value); attlist.Attributes.Add(attr); element.Attributes[token.Value] = attr; token = scanner.Get(); if (token.Type == Scanner.IDENTIFIER) { if (token.Value.Equals("NOTATION")) { attr.Type = ParseNotationList(); } else { attr.Type = token.Value; } } else if (token.Type == Scanner.LPAREN) { attr.Type = ParseEnumeration(); } token = scanner.Peek(); if (token.Type == Scanner.IDENTIFIER) { scanner.Get(); if (token.Value.Equals("#FIXED")) { attr.Decl = DTDDecl.FIXED; token = scanner.Get(); attr.DefaultValue = token.Value; } else if (token.Value.Equals("#REQUIRED")) { attr.Decl = DTDDecl.REQUIRED; } else if (token.Value.Equals("#IMPLIED")) { attr.Decl = DTDDecl.IMPLIED; } else { throw new DTDParseException(scanner.GetUriId(), "Invalid token in attribute declaration: " + token.Value, scanner.GetLineNumber(), scanner.GetColumn()); } } else if (token.Type == Scanner.STRING) { scanner.Get(); attr.Decl = DTDDecl.VALUE; attr.DefaultValue = token.Value; } }