public override bool Equals(object ob) { if (ob == this) { return(true); } if (!(ob is DTDItem)) { return(false); } DTDItem other = (DTDItem)ob; if (Cardinal == null) { if (other.Cardinal != null) { return(false); } } else { if (!Cardinal.Equals(other.Cardinal)) { return(false); } } return(true); }
protected DTDContainer ParseChoiceSequence() { TokenType separator = null; DTDContainer cs = null; for (;;) { DTDItem item = ParseCp(); Token token = Scanner.Get(); if ((token.Type == Scanner.PIPE) || (token.Type == Scanner.COMMA)) { if ((separator != null) && (separator != token.Type)) { throw new DTDParseException(Scanner.GetUriId(), "Can't mix separators in a choice/sequence", Scanner.GetLineNumber(), Scanner.GetColumn()); } separator = token.Type; if (cs == null) { if (token.Type == Scanner.PIPE) { cs = new DTDChoice(); } else { cs = new DTDSequence(); } } cs.Items.Add(item); } else if (token.Type == Scanner.RPAREN) { if (cs == null) { cs = new DTDSequence(); } cs.Items.Add(item); return(cs); } else { throw new DTDParseException(Scanner.GetUriId(), "Found invalid token in sequence: " + token.Type.Name, Scanner.GetLineNumber(), Scanner.GetColumn()); } } }
protected void RemoveElements(Hashtable h, DTD dtd, DTDItem item) { if (item is DTDName) { h.Remove(((DTDName)item).Value); } else if (item is DTDContainer) { foreach (DTDItem dtditem in ((DTDContainer)item).Items) { RemoveElements(h, dtd, dtditem); } } }
public static void DumpDtdItem(DTDItem item) { if (item == null) { return; } if (item is DTDAny) { Console.Write("Any"); } else if (item is DTDEmpty) { Console.Write("Empty"); } else if (item is DTDName) { Console.Write(((DTDName)item).Value); } else if (item is DTDChoice) { Console.Write("("); List <DTDItem> items = ((DTDChoice)item).Items; bool isFirst = true; foreach (DTDItem dtditem in items) { if (!isFirst) { Console.Write("|"); } isFirst = false; DumpDtdItem(dtditem); } Console.Write(")"); } else if (item is DTDSequence) { Console.Write("("); List <DTDItem> items = ((DTDSequence)item).Items; bool isFirst = true; foreach (DTDItem dtditem in items) { if (!isFirst) { Console.Write(","); } isFirst = false; DumpDtdItem(dtditem); } Console.Write(")"); } else if (item is DTDMixed) { Console.Write("("); List <DTDItem> items = ((DTDMixed)item).Items; bool isFirst = true; foreach (DTDItem dtditem in items) { if (!isFirst) { Console.Write(","); } isFirst = false; DumpDtdItem(dtditem); } Console.Write(")"); } else if (item is DTDPCData) { Console.Write("#PCDATA"); } if (item.Cardinal == DTDCardinal.ZEROONE) { Console.Write("?"); } else if (item.Cardinal == DTDCardinal.ZEROMANY) { Console.Write("*"); } else if (item.Cardinal == DTDCardinal.ONEMANY) { Console.Write("+"); } }