Beispiel #1
0
 public virtual void UnparsedEntityDecl(string name, string publicId, string systemId, string notationName)
 {
     if (_dtdHandler != null)
     {
         _dtdHandler.UnparsedEntityDecl(name, publicId, systemId, notationName);
     }
 }
Beispiel #2
0
        //
        // Before the endDtd event, deliver all non-PE declarations.
        //
        private void DeliverDTDEvents()
        {
            string ename;
            string nname;
            string publicId;
            string systemId;

            // First, report all notations.
            if (_dtdHandler != _base)
            {
                IEnumerable notationNames = _parser.declaredNotations();

                foreach (object elem in  notationNames)
                {
                    nname    = (string)elem;
                    publicId = _parser.getNotationPublicId(nname);
                    systemId = _parser.getNotationSystemId(nname);
                    _dtdHandler.NotationDecl(nname, publicId, systemId);
                }
            }

            // Next, report all entities.
            if (_dtdHandler != _base || _declHandler != _base)
            {
                IEnumerable entityNames = _parser.declaredEntities();
                int         type;

                foreach (object elem in entityNames)
                {
                    ename = (string)elem;
                    type  = _parser.getEntityType(ename);

                    if (ename[0] == '%')
                    {
                        continue;
                    }

                    // unparsed
                    if (type == XmlParser.ENTITY_NDATA)
                    {
                        publicId = _parser.getEntityPublicId(ename);
                        systemId = _parser.getEntitySystemId(ename);
                        nname    = _parser.getEntityNotationName(ename);
                        _dtdHandler.UnparsedEntityDecl(ename, publicId, systemId, nname);

                        // external parsed
                    }
                    else if (type == XmlParser.ENTITY_TEXT)
                    {
                        publicId = _parser.getEntityPublicId(ename);
                        systemId = _parser.getEntitySystemId(ename);
                        _declHandler.ExternalEntityDecl(ename, publicId, systemId);

                        // internal parsed
                    }
                    else if (type == XmlParser.ENTITY_INTERNAL)
                    {
                        // filter out the built-ins; even if they were
                        // declared, they didn't need to be.
                        if ("lt".Equals(ename) || "gt".Equals(ename) || "quot".Equals(ename) || "apos".Equals(ename) ||
                            "amp".Equals(ename))
                        {
                            continue;
                        }
                        _declHandler.InternalEntityDecl(ename, _parser.getEntityValue(ename));
                    }
                }
            }

            // elements, attributes
            if (_declHandler != _base)
            {
                IEnumerable elementNames = _parser.declaredElements();
                IEnumerable attNames;

                foreach (object elem in elementNames)
                {
                    string model = null;

                    ename = (string)elem;
                    switch (_parser.getElementContentType(ename))
                    {
                    case XmlParser.CONTENT_ANY:
                        model = "ANY";
                        break;

                    case XmlParser.CONTENT_EMPTY:
                        model = "EMPTY";
                        break;

                    case XmlParser.CONTENT_MIXED:
                    case XmlParser.CONTENT_ELEMENTS:
                        model = _parser.getElementContentModel(ename);
                        break;

                    case XmlParser.CONTENT_UNDECLARED:
                    default:
                        model = null;
                        break;
                    }
                    if (model != null)
                    {
                        _declHandler.ElementDecl(ename, model);
                    }

                    attNames = _parser.declaredAttributes(ename);
                    if (attNames != null)
                    {
                        foreach (object att in attNames)
                        {
                            var    aname = (string)att;
                            string type;
                            string valueDefault;
                            string value;

                            switch (_parser.getAttributeType(ename, aname))
                            {
                            case XmlParser.ATTRIBUTE_CDATA:
                                type = "CDATA";
                                break;

                            case XmlParser.ATTRIBUTE_ENTITY:
                                type = "ENTITY";
                                break;

                            case XmlParser.ATTRIBUTE_ENTITIES:
                                type = "ENTITIES";
                                break;

                            case XmlParser.ATTRIBUTE_ENUMERATED:
                                type = _parser.getAttributeEnumeration(ename, aname);
                                break;

                            case XmlParser.ATTRIBUTE_ID:
                                type = "ID";
                                break;

                            case XmlParser.ATTRIBUTE_IDREF:
                                type = "IDREF";
                                break;

                            case XmlParser.ATTRIBUTE_IDREFS:
                                type = "IDREFS";
                                break;

                            case XmlParser.ATTRIBUTE_NMTOKEN:
                                type = "NMTOKEN";
                                break;

                            case XmlParser.ATTRIBUTE_NMTOKENS:
                                type = "NMTOKENS";
                                break;

                            // XXX SAX2 beta doesn't have a way to return the
                            // enumerated list of permitted notations ... SAX1
                            // kluged it as NMTOKEN, but that won't work for
                            // the sort of apps that really use the DTD info
                            case XmlParser.ATTRIBUTE_NOTATION:
                                type = "NOTATION";
                                break;

                            default:
                                _errorHandler.FatalError(new SAXParseException("internal error, att type", this));
                                type = null;
                                break;
                            }

                            switch (_parser.getAttributeDefaultValueType(ename, aname))
                            {
                            case XmlParser.ATTRIBUTE_DEFAULT_IMPLIED:
                                valueDefault = "#IMPLIED";
                                break;

                            case XmlParser.ATTRIBUTE_DEFAULT_REQUIRED:
                                valueDefault = "#REQUIRED";
                                break;

                            case XmlParser.ATTRIBUTE_DEFAULT_FIXED:
                                valueDefault = "#FIXED";
                                break;

                            case XmlParser.ATTRIBUTE_DEFAULT_SPECIFIED:
                                valueDefault = null;
                                break;

                            default:
                                _errorHandler.FatalError(new SAXParseException("internal error, att default", this));
                                valueDefault = null;
                                break;
                            }

                            value = _parser.getAttributeDefaultValue(ename, aname);

                            _declHandler.AttributeDecl(ename, aname, type, valueDefault, value);
                        }
                    }
                }
            }
        }