Changeset 187 for trunk/src/helpers/xml.c
- Timestamp:
- Jul 8, 2002, 6:53:23 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/xml.c
r186 r187 1902 1902 * 1903 1903 *@@added V0.9.14 (2001-08-09) [umoeller] 1904 *@@changed V0.9.20 (2002-07-06) [umoeller]: added automatic doctype support 1904 1905 */ 1905 1906 … … 1915 1916 int i = 0; // return error per default 1916 1917 1917 APIRET arc = NO_ERROR;1918 1919 1918 // store the previous parser because 1920 1919 // all the callbacks use the parser pointer … … 1922 1921 pDom->pParser = NULL; 1923 1922 1924 if ( (pDom->pfnExternalHandler) 1923 if ( ( (pDom->pfnExternalHandler) 1924 || (pDom->cSystemIds) // V0.9.20 (2002-07-06) [umoeller] 1925 ) 1925 1926 // create sub-parser and replace the one 1926 1927 // in the DOM with it … … 1930 1931 ) 1931 1932 { 1932 if ((arc = pDom->pfnExternalHandler(pDom, 1933 pDom->pParser, 1934 pcszSystemId, 1935 pcszPublicId))) 1936 { 1937 // error: 1938 // now this needs special handling, since we're 1939 // dealing with a sub-handler here... 1940 1941 if (arc == -1) 1942 // parser error: well, then xmlSetError has been 1943 // called from somewhere in the callbacks already, 1944 // and we can safely ignore this 1945 ; 1933 // run through the predefined doctypes given to us 1934 // in xmlCreateDOM, if any 1935 // V0.9.20 (2002-07-06) [umoeller] 1936 BOOL fCallExternal = TRUE; 1937 ULONG ul; 1938 1939 for (ul = 0; 1940 ul < pDom->cSystemIds; 1941 ++ul) 1942 { 1943 const STATICSYSTEMID *pThis = &pDom->paSystemIds[ul]; 1944 if (!strcmp(pThis->pcszSystemId, pcszSystemId)) 1945 { 1946 // this one matches: 1947 // then parse the corresponding entry given 1948 // to us 1949 if (XML_Parse(pDom->pParser, 1950 pThis->pcszContent, 1951 strlen(pThis->pcszContent), 1952 TRUE)) 1953 i = 1; // success 1954 1955 fCallExternal = FALSE; 1956 1957 break; 1958 } 1959 } 1960 1961 if ( (fCallExternal) // not handled above 1962 && (pDom->pfnExternalHandler) // user handler set 1963 ) 1964 { 1965 APIRET arc; 1966 1967 if (!(arc = pDom->pfnExternalHandler(pDom, 1968 pDom->pParser, 1969 pcszSystemId, 1970 pcszPublicId))) 1971 i = 1; // success 1946 1972 else 1947 1973 { 1948 pDom->arcDOM = arc; 1949 if (pcszSystemId) 1974 // error: 1975 // now this needs special handling, since we're 1976 // dealing with a sub-handler here... 1977 1978 if (arc == -1) 1979 // parser error: well, then xmlSetError has been 1980 // called from somewhere in the callbacks already, 1981 // and we can safely ignore this 1982 ; 1983 else 1950 1984 { 1951 if (!pDom->pxstrFailingNode) 1952 pDom->pxstrFailingNode = xstrCreate(0); 1953 xstrcpy(pDom->pxstrFailingNode, pcszSystemId, 0); 1985 pDom->arcDOM = arc; 1986 if (pcszSystemId) 1987 { 1988 if (!pDom->pxstrFailingNode) 1989 pDom->pxstrFailingNode = xstrCreate(0); 1990 xstrcpy(pDom->pxstrFailingNode, pcszSystemId, 0); 1991 } 1992 pDom->pcszErrorDescription = xmlDescribeError(arc); 1993 pDom->ulErrorLine = XML_GetCurrentLineNumber(pDom->pParser); 1994 pDom->ulErrorColumn = XML_GetCurrentColumnNumber(pDom->pParser); 1954 1995 } 1955 pDom->pcszErrorDescription = xmlDescribeError(arc);1956 pDom->ulErrorLine = XML_GetCurrentLineNumber(pDom->pParser);1957 pDom->ulErrorColumn = XML_GetCurrentColumnNumber(pDom->pParser);1958 1996 } 1959 1997 } 1960 1961 i = 1; // success1962 1998 } 1963 1999 else 1964 2000 xmlSetError(pDom, 1965 (!arc) ? ERROR_DOM_INVALID_EXTERNAL_HANDLER : arc,2001 ERROR_DOM_INVALID_EXTERNAL_HANDLER, 1966 2002 NULL, 1967 2003 FALSE); … … 2336 2372 * not all @expat features are supported yet. 2337 2373 * 2374 * flParserFlags is any combination of the following: 2375 * 2376 * -- DF_PARSECOMMENTS: XML @comments are to be returned in 2377 * the DOM tree. Otherwise they are discarded. 2378 * 2379 * -- DF_PARSEDTD: add the @DTD of the document into the DOM tree 2380 * as well and validate the document, if a DTD was found. 2381 * Otherwise just parse and do not validate. 2382 * 2383 * DF_PARSEDTD is required for external entities to work 2384 * also. 2385 * 2386 * -- DF_FAIL_IF_NO_DTD: fail if no @DTD was found. Useful 2387 * if you want to enforce validation. @@todo 2388 * 2389 * -- DF_DROP_WHITESPACE: discard all @whitespace for those 2390 * elements that can only have element content. Whitespace 2391 * will be preserved only for elements that can have 2392 * mixed content. -- If this flag is not set, all whitespace 2393 * is preserved. 2394 * 2338 2395 * The following callbacks can be specified (any of these 2339 2396 * can be NULL): … … 2371 2428 * the int at index 0x94 to 0x00f6. 2372 2429 * 2373 * pvCallbackUser is a user parameter which is simply stored 2374 * in the XMLDOM struct which is returned. Since the XMLDOM 2375 * is passed to all the callbacks, you can access that pointer 2376 * from them. 2377 * 2378 * flParserFlags is any combination of the following: 2379 * 2380 * -- DF_PARSECOMMENTS: XML @comments are to be returned in 2381 * the DOM tree. Otherwise they are discarded. 2382 * 2383 * -- DF_PARSEDTD: add the @DTD of the document into the DOM tree 2384 * as well and validate the document, if a DTD was found. 2385 * Otherwise just parse and do not validate. 2386 * 2387 * DF_PARSEDTD is required for external entities to work 2388 * also. 2389 * 2390 * -- DF_FAIL_IF_NO_DTD: fail if no @DTD was found. Useful 2391 * if you want to enforce validation. @@todo 2392 * 2393 * -- DF_DROP_WHITESPACE: discard all @whitespace for those 2394 * elements that can only have element content. Whitespace 2395 * will be preserved only for elements that can have 2396 * mixed content. -- If this flag is not set, all whitespace 2397 * is preserved. 2430 * -- pvCallbackUser is a user parameter which is simply stored 2431 * in the XMLDOM struct which is returned. Since the XMLDOM 2432 * is passed to all the callbacks, you can access that pointer 2433 * from them. 2398 2434 * 2399 2435 *@@added V0.9.9 (2001-02-14) [umoeller] … … 2402 2438 2403 2439 APIRET xmlCreateDOM(ULONG flParserFlags, // in: DF_* parser flags 2440 const STATICSYSTEMID *paSystemIds, // in: array of STATICSYSTEMID's or NULL 2441 ULONG cSystemIds, // in: array item count 2404 2442 PFNGETCPDATA pfnGetCPData, // in: codepage callback or NULL 2405 2443 PFNEXTERNALHANDLER pfnExternalHandler, // in: external entity callback or NULL … … 2422 2460 pDom->pfnExternalHandler = pfnExternalHandler; 2423 2461 pDom->pvCallbackUser = pvCallbackUser; 2462 2463 // these added with V0.9.20 (2002-07-06) [umoeller] 2464 pDom->paSystemIds = paSystemIds; 2465 pDom->cSystemIds = cSystemIds; 2424 2466 2425 2467 lstInit(&pDom->llElementStack, … … 2470 2512 CommentHandler); 2471 2513 2472 if (pfnExternalHandler) 2514 if ( (pfnExternalHandler) 2515 || (cSystemIds) // V0.9.20 (2002-07-06) [umoeller] 2516 ) 2473 2517 XML_SetExternalEntityRefHandler(pDom->pParser, 2474 2518 ExternalEntityRefHandler);
Note:
See TracChangeset
for help on using the changeset viewer.