* xmlCtxtInitializeLate: * @ctxt: an XML parser context * * Final initialization of the parser context before starting to parse. * * This accounts for users modifying struct members of parser context * directly. */
| 944 | * directly. |
| 945 | */ |
| 946 | static void |
| 947 | xmlCtxtInitializeLate(xmlParserCtxtPtr ctxt) { |
| 948 | xmlSAXHandlerPtr sax; |
| 949 | |
| 950 | /* Avoid unused variable warning if features are disabled. */ |
| 951 | (void) sax; |
| 952 | |
| 953 | /* |
| 954 | * Changing the SAX struct directly is still widespread practice |
| 955 | * in internal and external code. |
| 956 | */ |
| 957 | if (ctxt == NULL) return; |
| 958 | sax = ctxt->sax; |
| 959 | #ifdef LIBXML_SAX1_ENABLED |
| 960 | /* |
| 961 | * Only enable SAX2 if there SAX2 element handlers, except when there |
| 962 | * are no element handlers at all. |
| 963 | */ |
| 964 | if (((ctxt->options & XML_PARSE_SAX1) == 0) && |
| 965 | (sax) && |
| 966 | (sax->initialized == XML_SAX2_MAGIC) && |
| 967 | ((sax->startElementNs != NULL) || |
| 968 | (sax->endElementNs != NULL) || |
| 969 | ((sax->startElement == NULL) && (sax->endElement == NULL)))) |
| 970 | ctxt->sax2 = 1; |
| 971 | #else |
| 972 | ctxt->sax2 = 1; |
| 973 | #endif /* LIBXML_SAX1_ENABLED */ |
| 974 | |
| 975 | /* |
| 976 | * Some users replace the dictionary directly in the context struct. |
| 977 | * We really need an API function to do that cleanly. |
| 978 | */ |
| 979 | ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3); |
| 980 | ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5); |
| 981 | ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36); |
| 982 | if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) || |
| 983 | (ctxt->str_xml_ns == NULL)) { |
| 984 | xmlErrMemory(ctxt); |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | typedef struct { |
| 989 | xmlHashedString prefix; |
no test coverage detected