Beispiel #1
0
        public static int Parse(NamingContext /*!*/ namingContext, DTypeDesc caller, PhpResource parser, string data, bool is_final)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser != null)
            {
                return(xmlParser.Parse(caller, namingContext, data, is_final) ? 1 : 0);
            }

            return(0);
        }
Beispiel #2
0
        public static bool SetExternalEntityRefHandler(PhpResource parser, object external_entity_ref_handler_obj)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser == null)
            {
                return(false);
            }

            PhpException.FunctionNotSupported(PhpError.Warning);
            return(false);
        }
Beispiel #3
0
        public static bool SetNotationDeclHandler(PhpResource parser, object notation_decl_handler_obj)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser == null)
            {
                return(false);
            }

            PhpException.FunctionNotSupported(PhpError.Warning);
            return(false);
        }
Beispiel #4
0
        public static bool SetProcessingInstructionHandler(PhpResource parser, object processing_instruction_handler_obj)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser == null)
            {
                return(false);
            }

            var processing_instruction_handler = xmlParser.ObjectToXmlCallback(processing_instruction_handler_obj);

            if (processing_instruction_handler != null)
            {
                xmlParser.ProcessingInstructionHandler = processing_instruction_handler;
                return(true);
            }

            return(false);
        }
Beispiel #5
0
        public static bool Free(PhpResource parser)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser == null)
            {
                return(false);
            }

            // Since .NET hasn't online XML parser, we need the whole XML data to parse them properly.
            // Notice user, he has to parse the XML by passing is_final=true to the last xml_parse function call.
            if (!xmlParser.InputQueueIsEmpty)
            {
                PhpException.Throw(PhpError.Notice, Strings.not_parsed_data_left);
            }

            xmlParser.Dispose();
            return(true);
        }
Beispiel #6
0
        public static bool SetEndNamespaceDeclHandler(PhpResource parser, object end_namespace_decl_handler_obj)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser == null)
            {
                return(false);
            }

            var end_namespace_decl_handler = xmlParser.ObjectToXmlCallback(end_namespace_decl_handler_obj);

            if (end_namespace_decl_handler != null)
            {
                xmlParser.EndNamespaceDeclHandler = end_namespace_decl_handler;

                return(true);
            }

            return(false);
        }
Beispiel #7
0
        public static bool SetCharacterDataHandler(PhpResource parser, object character_data_handler_obj)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser == null)
            {
                return(false);
            }

            var character_data_handler = xmlParser.ObjectToXmlCallback(character_data_handler_obj);

            if (character_data_handler != null)
            {
                xmlParser.CharacterDataHandler = character_data_handler;

                return(true);
            }

            return(false);
        }
Beispiel #8
0
        public static bool SetDefaultHandler(PhpResource parser, object default_handler_obj)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser == null)
            {
                return(false);
            }

            var default_handler = xmlParser.ObjectToXmlCallback(default_handler_obj);

            if (default_handler != null)
            {
                xmlParser.DefaultHandler = default_handler;

                return(true);
            }

            return(false);
        }
Beispiel #9
0
        public static bool SetElementHandler(PhpResource parser, object start_element_handler_obj, object end_element_handler_obj)
        {
            XmlParserResource xmlParser = XmlParserResource.ValidResource(parser);

            if (xmlParser == null)
            {
                return(false);
            }

            var start_element_handler = xmlParser.ObjectToXmlCallback(start_element_handler_obj);
            var end_element_handler   = xmlParser.ObjectToXmlCallback(end_element_handler_obj);

            if (start_element_handler != null && end_element_handler != null)
            {
                xmlParser.StartElementHandler = start_element_handler;
                xmlParser.EndElementHandler   = end_element_handler;

                return(true);
            }

            return(false);
        }