Commit 67070107 authored by Nick Wellnhofer's avatar Nick Wellnhofer
Browse files

Add configuration flag for XPointer locations support

Add a new configuration flag that controls whether the outdated support
for XPointer locations (ranges and points) is enabled.

    --with-xptr-locs          # Autotools
    LIBXML2_WITH_XPTR_LOCS    # CMake

The latest spec for what it essentially an XPath extension seems to be
this working draft from 2002:

    https://www.w3.org/TR/xptr-xpointer/

The xpointer() scheme is listed as "being reviewed" in the XPointer
registry since at least 2006. libxml2 seems to be the only modern
software that tries to implement this spec, but the code has many bugs
and quality issues.

The flag defaults to "off" and support for this extensions has to be
requested explicitly. The relevant API functions are deprecated.
parent 9a0be0dc
......@@ -19,33 +19,31 @@
script:
- |
ln -s /tests/xmlconf
sh autogen.sh $CONFIG
sh autogen.sh --with-ftp --with-legacy --with-xptr-locs $CONFIG
make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
make CFLAGS="$CFLAGS -Werror" check
gcc:
extends: .test
variables:
CONFIG: '--with-ftp --with-legacy'
CFLAGS: "-O2 -std=c89 -D_XOPEN_SOURCE=700"
gcc:python3:
extends: .test
variables:
CONFIG: '--with-ftp --with-legacy'
CFLAGS: "-O2"
PYTHON: "/usr/bin/python3"
gcc:static:
extends: .test
variables:
CONFIG: "--disable-shared --with-ftp --with-legacy --without-python"
CONFIG: "--disable-shared --without-python"
CFLAGS: "-O2"
clang:asan:
extends: .test
variables:
CONFIG: "--with-ftp --with-legacy --without-python"
CONFIG: "--without-python"
CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,integer -fno-sanitize-recover=all -Wno-error=cast-align"
# LeakSanitizer requires SYS_CAP_PTRACE
......@@ -57,7 +55,7 @@ clang:msan:
only:
- schedules
variables:
CONFIG: "--with-ftp --with-legacy --without-python --without-zlib --without-lzma"
CONFIG: "--without-python --without-zlib --without-lzma"
CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory -Wno-error=cast-align"
......
......@@ -59,6 +59,7 @@ option(LIBXML2_WITH_WRITER "Add the xmlWriter saving interface" ON)
option(LIBXML2_WITH_XINCLUDE "Add the XInclude support" ON)
option(LIBXML2_WITH_XPATH "Add the XPATH support" ON)
option(LIBXML2_WITH_XPTR "Add the XPointer support" ON)
option(LIBXML2_WITH_XPTR_LOCS "Add support for XPointer locations" OFF)
option(LIBXML2_WITH_ZLIB "Use libz" ON)
set(LIBXML2_XMLCONF_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Working directory for XML Conformance Test Suite")
......@@ -96,7 +97,7 @@ if(LIBXML2_WITH_ZLIB)
find_package(ZLIB REQUIRED)
endif()
foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_XPTR_LOCS WITH_ZLIB)
if(LIBXML2_${VARIABLE})
set(${VARIABLE} 1)
else()
......
......@@ -160,6 +160,8 @@ AC_ARG_WITH(xpath,
[ --with-xpath add the XPATH support (on)])
AC_ARG_WITH(xptr,
[ --with-xptr add the XPointer support (on)])
AC_ARG_WITH(xptr-locs,
[ --with-xptr-locs add support for XPointer locations (off)])
AC_ARG_WITH(modules,
[ --with-modules add the dynamic modules support (on)])
AC_ARG_WITH(zlib,
......@@ -199,6 +201,10 @@ if test "$with_reader" = "yes"
then
with_push=yes
fi
if test "$with_xptr_locs" = "yes"
then
with_xptr=yes
fi
if test "$with_xptr" = "yes"
then
with_xpath=yes
......@@ -1071,6 +1077,7 @@ AC_SUBST(TEST_CATALOG)
if test "$with_xptr" = "no" ; then
echo Disabling XPointer support
WITH_XPTR=0
WITH_XPTR_LOCS=0
XPTR_OBJ=
else
WITH_XPTR=1
......@@ -1079,8 +1086,14 @@ else
echo XPointer requires XPath support - enabling it
with_xpath=yes
fi
if test "$with_xptr_locs" = "yes" ; then
WITH_XPTR_LOCS=1
else
WITH_XPTR_LOCS=0
fi
fi
AC_SUBST(WITH_XPTR)
AC_SUBST(WITH_XPTR_LOCS)
AC_SUBST(XPTR_OBJ)
if test "$with_c14n" = "no" ; then
......
......@@ -1840,6 +1840,7 @@ xmlShellPrintXPathError(int errorType, const char *arg)
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
......@@ -1852,6 +1853,7 @@ xmlShellPrintXPathError(int errorType, const char *arg)
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
......@@ -2998,6 +3000,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
......@@ -3010,6 +3013,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
......@@ -3115,6 +3119,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
......@@ -3127,6 +3132,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
......@@ -3192,6 +3198,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
......@@ -3204,6 +3211,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
......@@ -3277,6 +3285,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
......@@ -3289,6 +3298,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
......@@ -3355,6 +3365,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg);
......@@ -3367,6 +3378,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg);
......
......@@ -4461,6 +4461,12 @@
<macro name='XML_XPATH_NOVAR' file='xpath'>
<info>forbid variables in expression</info>
</macro>
<macro name='XPATH_LOCATIONSET' file='xpath'>
</macro>
<macro name='XPATH_POINT' file='xpath'>
</macro>
<macro name='XPATH_RANGE' file='xpath'>
</macro>
<macro name='XP_ERROR' file='xpathInternals'>
<info>Macro to raise an XPath error and return.</info>
<arg name='X' info='the error code'/>
......@@ -18255,7 +18261,7 @@ Could we use @subtypes for this?'/>
<arg name='no' type='int' info='the error number'/>
</function>
<function name='xmlXPtrBuildNodeList' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Build a node list tree copy of the XPointer result. This will drop Attributes and Namespace declarations.</info>
<return type='xmlNodePtr' info='an xmlNodePtr list or NULL. the caller has to free the node tree.'/>
<arg name='obj' type='xmlXPathObjectPtr' info='the XPointer result from the evaluation.'/>
......@@ -18268,53 +18274,53 @@ Could we use @subtypes for this?'/>
<arg name='ctx' type='xmlXPathContextPtr' info='the XPointer context'/>
</function>
<function name='xmlXPtrEvalRangePredicate' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>[8] Predicate ::= &apos;[&apos; PredicateExpr &apos;]&apos; [9] PredicateExpr ::= Expr Evaluate a predicate as in xmlXPathEvalPredicate() but for a Location Set instead of a node set</info>
<return type='void'/>
<arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPointer Parser context'/>
</function>
<function name='xmlXPtrFreeLocationSet' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Free the LocationSet compound (not the actual ranges !).</info>
<return type='void'/>
<arg name='obj' type='xmlLocationSetPtr' info='the xmlLocationSetPtr to free'/>
</function>
<function name='xmlXPtrLocationSetAdd' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>add a new xmlXPathObjectPtr to an existing LocationSet If the location already exist in the set @val is freed.</info>
<return type='void'/>
<arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/>
<arg name='val' type='xmlXPathObjectPtr' info='a new xmlXPathObjectPtr'/>
</function>
<function name='xmlXPtrLocationSetCreate' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlLocationSetPtr of type double and of value @val</info>
<return type='xmlLocationSetPtr' info='the newly created object.'/>
<arg name='val' type='xmlXPathObjectPtr' info='an initial xmlXPathObjectPtr, or NULL'/>
</function>
<function name='xmlXPtrLocationSetDel' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Removes an xmlXPathObjectPtr from an existing LocationSet</info>
<return type='void'/>
<arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/>
<arg name='val' type='xmlXPathObjectPtr' info='an xmlXPathObjectPtr'/>
</function>
<function name='xmlXPtrLocationSetMerge' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Merges two rangesets, all ranges from @val2 are added to @val1</info>
<return type='xmlLocationSetPtr' info='val1 once extended or NULL in case of error.'/>
<arg name='val1' type='xmlLocationSetPtr' info='the first LocationSet'/>
<arg name='val2' type='xmlLocationSetPtr' info='the second LocationSet'/>
</function>
<function name='xmlXPtrLocationSetRemove' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Removes an entry from an existing LocationSet list.</info>
<return type='void'/>
<arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/>
<arg name='val' type='int' info='the index to remove'/>
</function>
<function name='xmlXPtrNewCollapsedRange' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range using a single nodes</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting and ending node'/>
......@@ -18328,20 +18334,20 @@ Could we use @subtypes for this?'/>
<arg name='origin' type='xmlNodePtr' info='the element from which a user or program initiated traversal of the link, or NULL.'/>
</function>
<function name='xmlXPtrNewLocationSetNodeSet' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type LocationSet and initialize it with all the nodes from @set</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='set' type='xmlNodeSetPtr' info='a node set'/>
</function>
<function name='xmlXPtrNewLocationSetNodes' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type LocationSet and initialize it with the single range made of the two nodes @start and @end</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the start NodePtr value'/>
<arg name='end' type='xmlNodePtr' info='the end NodePtr value or NULL'/>
</function>
<function name='xmlXPtrNewRange' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting node'/>
......@@ -18350,49 +18356,49 @@ Could we use @subtypes for this?'/>
<arg name='endindex' type='int' info='the ending index'/>
</function>
<function name='xmlXPtrNewRangeNodeObject' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range from a not to an object</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting node'/>
<arg name='end' type='xmlXPathObjectPtr' info='the ending object'/>
</function>
<function name='xmlXPtrNewRangeNodePoint' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range from a node to a point</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting node'/>
<arg name='end' type='xmlXPathObjectPtr' info='the ending point'/>
</function>
<function name='xmlXPtrNewRangeNodes' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range using 2 nodes</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting node'/>
<arg name='end' type='xmlNodePtr' info='the ending node'/>
</function>
<function name='xmlXPtrNewRangePointNode' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range from a point to a node</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlXPathObjectPtr' info='the starting point'/>
<arg name='end' type='xmlNodePtr' info='the ending node'/>
</function>
<function name='xmlXPtrNewRangePoints' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range using 2 Points</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlXPathObjectPtr' info='the starting point'/>
<arg name='end' type='xmlXPathObjectPtr' info='the ending point'/>
</function>
<function name='xmlXPtrRangeToFunction' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Implement the range-to() XPointer function Obsolete. range-to is not a real function but a special type of location step which is handled in xpath.c.</info>
<return type='void'/>
<arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPointer Parser context'/>
<arg name='nargs' type='int' info='the number of args'/>
</function>
<function name='xmlXPtrWrapLocationSet' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond>
<cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Wrap the LocationSet @val in a new xmlXPathObjectPtr</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='val' type='xmlLocationSetPtr' info='the LocationSet value'/>
......@@ -155,6 +155,13 @@ skipped_functions = [
# Legacy
"xmlCleanupPredefinedEntities", "xmlInitializePredefinedEntities",
"xmlSetFeature", "xmlGetFeature", "xmlGetFeaturesList",
# location sets
"xmlXPtrLocationSetAdd",
"xmlXPtrLocationSetCreate",
"xmlXPtrLocationSetDel",
"xmlXPtrLocationSetMerge",
"xmlXPtrLocationSetRemove",
"xmlXPtrWrapLocationSet",
]
#
......
......@@ -247,6 +247,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_XPTR_ENABLED
#endif
/**
* LIBXML_XPTR_LOCS_ENABLED:
*
* Whether support for XPointer locations is configured in
*/
#if @WITH_XPTR_LOCS@
#define LIBXML_XPTR_LOCS_ENABLED
#endif
/**
* LIBXML_XINCLUDE_ENABLED:
*
......
......@@ -104,13 +104,23 @@ typedef enum {
XPATH_BOOLEAN = 2,
XPATH_NUMBER = 3,
XPATH_STRING = 4,
#ifdef LIBXML_XPTR_LOCS_ENABLED
XPATH_POINT = 5,
XPATH_RANGE = 6,
XPATH_LOCATIONSET = 7,
#endif
XPATH_USERS = 8,
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
} xmlXPathObjectType;
#ifndef LIBXML_XPTR_LOCS_ENABLED
/** DOC_DISABLE */
#define XPATH_POINT 5
#define XPATH_RANGE 6
#define XPATH_LOCATIONSET 7
/** DOC_ENABLE */
#endif
typedef struct _xmlXPathObject xmlXPathObject;
typedef xmlXPathObject *xmlXPathObjectPtr;
struct _xmlXPathObject {
......
......@@ -28,6 +28,7 @@
extern "C" {
#endif
#ifdef LIBXML_XPTR_LOCS_ENABLED
/*
* A Location Set
*/
......@@ -43,51 +44,68 @@ struct _xmlLocationSet {
* Handling of location sets.
*/
XML_DEPRECATED
XMLPUBFUN xmlLocationSetPtr XMLCALL
xmlXPtrLocationSetCreate (xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
XML_DEPRECATED
XMLPUBFUN xmlLocationSetPtr XMLCALL
xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRange (xmlNodePtr start,
int startindex,
xmlNodePtr end,
int endindex);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangePoints (xmlXPathObjectPtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodePoint (xmlNodePtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangePointNode (xmlXPathObjectPtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodes (xmlNodePtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewLocationSetNodes (xmlNodePtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodeObject (xmlNodePtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewCollapsedRange (xmlNodePtr start);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrLocationSetDel (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrLocationSetRemove (xmlLocationSetPtr cur,
int val);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/*
* Functions.
......@@ -99,13 +117,18 @@ XMLPUBFUN xmlXPathContextPtr XMLCALL
XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrEval (const xmlChar *str,
xmlXPathContextPtr ctx);
#ifdef LIBXML_XPTR_LOCS_ENABLED
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
int nargs);
XML_DEPRECATED
XMLPUBFUN xmlNodePtr XMLCALL
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
#ifdef __cplusplus
}
#endif
......
......@@ -320,6 +320,12 @@ deprecated_funcs = {
'xmlSchemaCleanupTypes': True,
'xmlSchemaInitTypes': True,
'xmlXPathInit': True,
'xmlXPtrEvalRangePredicate': True,
'xmlXPtrNewCollapsedRange': True,
'xmlXPtrNewLocationSetNodes': True,
'xmlXPtrNewRange': True,
'xmlXPtrNewRangeNodes': True,
'xmlXPtrRangeToFunction': True,
}
def skip_function(name):
......
......@@ -603,6 +603,7 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
case XPATH_STRING:
ret = PY_IMPORT_STRING((char *) obj->stringval);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
{
PyObject *node;
......@@ -704,6 +705,7 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
}
break;
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
default:
#ifdef DEBUG
printf("Unable to convert XPath object type %d\n", obj->type);
......
......@@ -2596,7 +2596,7 @@ xpathDocTest(const char *filename,
return(ret);
}
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
/**
* xptrDocTest:
* @filename: the file to parse
......@@ -4527,7 +4527,7 @@ testDesc testDescriptions[] = {
{ "XPath document queries regression tests" ,
xpathDocTest, "./test/XPath/docs/*", NULL, NULL, NULL,
0 },
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_LOCS_ENABLED
{ "XPointer document queries regression tests" ,
xptrDocTest, "./test/XPath/docs/*", NULL, NULL, NULL,
0 },
......
......@@ -1833,9 +1833,11 @@ xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
failed = 1;
break;
case XPATH_UNDEFINED:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif
case XPATH_USERS:
failed = 1;
break;
......
......@@ -50749,7 +50749,7 @@ static int
test_xmlXPtrBuildNodeList(void) {
int test_ret = 0;
 
#if defined(LIBXML_XPTR_ENABLED)
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlNodePtr ret_val;
xmlXPathObjectPtr obj; /* the XPointer result from the evaluation. */
......@@ -50824,7 +50824,7 @@ static int
test_xmlXPtrEvalRangePredicate(void) {
int test_ret = 0;
 
#if defined(LIBXML_XPTR_ENABLED)
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */
int n_ctxt;
......@@ -50851,159 +50851,12 @@ test_xmlXPtrEvalRangePredicate(void) {
return(test_ret);
}
 
#ifdef LIBXML_XPTR_ENABLED
#define gen_nb_xmlLocationSetPtr 1
static xmlLocationSetPtr gen_xmlLocationSetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
return(NULL);
}
static void des_xmlLocationSetPtr(int no ATTRIBUTE_UNUSED, xmlLocationSetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
}
#endif
static int
test_xmlXPtrLocationSetAdd(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED)
int mem_base;
xmlLocationSetPtr cur; /* the initial range set */
int n_cur;
xmlXPathObjectPtr val; /* a new xmlXPathObjectPtr */
int n_val;
for (n_cur = 0;n_cur < gen_nb_xmlLocationSetPtr;n_cur++) {
for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) {
mem_base = xmlMemBlocks();
cur = gen_xmlLocationSetPtr(n_cur, 0);
val = gen_xmlXPathObjectPtr(n_val, 1);
xmlXPtrLocationSetAdd(cur, val);
call_tests++;
des_xmlLocationSetPtr(n_cur, cur, 0);
des_xmlXPathObjectPtr(n_val, val, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrLocationSetAdd",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_cur);
printf(" %d", n_val);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}