1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-23 17:33:50 +03:00

xpointer: Remove support for XPointer locations

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.

If you configure --with-legacy, old symbols are retained for ABI
compatibility.
This commit is contained in:
Nick Wellnhofer 2024-06-12 18:20:01 +02:00
parent dba1ed85a3
commit 669bd34993
55 changed files with 110 additions and 4498 deletions

View File

@ -1,7 +1,7 @@
.test:
image: registry.gitlab.gnome.org/gnome/libxml2
variables:
BASE_CONFIG: "--with-legacy --with-xptr-locs"
BASE_CONFIG: "--with-legacy"
before_script:
- rm -rf libxml2-build
- mkdir libxml2-build
@ -72,7 +72,7 @@ clang:msan:
tags:
- win32-ps
variables:
BASE_CONFIG: "--with-legacy --with-xptr-locs"
BASE_CONFIG: "--with-legacy"
# Disabled for now, see #658
CONFIG: "--without-python"
CHERE_INVOKING: "yes"

View File

@ -58,7 +58,6 @@ 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" OFF)
set(LIBXML2_XMLCONF_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Working directory for XML Conformance Test Suite")
@ -71,7 +70,7 @@ if(LIBXML2_WITH_PYTHON)
CACHE PATH "Python bindings install directory")
endif()
foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_XPTR_LOCS WITH_ZLIB)
foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
if(LIBXML2_${VARIABLE})
set(${VARIABLE} 1)
else()

View File

@ -121,8 +121,6 @@ AC_ARG_WITH(xpath,
[ --with-xpath XPath 1.0 support (on)])
AC_ARG_WITH(xptr,
[ --with-xptr XPointer support (on)])
AC_ARG_WITH(xptr-locs,
[ --with-xptr-locs XPointer ranges and points (off)])
AC_ARG_WITH(zlib,
[ --with-zlib[[=DIR]] use libz in DIR (off)])
@ -212,12 +210,6 @@ if test "$with_xinclude" = "yes"; then
fi
with_xpath=yes
fi
if test "$with_xptr_locs" = "yes"; then
if test "$with_xptr" = "no"; then
echo WARNING: --with-xptr-locs overrides --without-xptr
fi
with_xptr=yes
fi
if test "$with_xptr" = "yes"; then
if test "$with_xpath" = "no"; then
echo WARNING: --with-xptr overrides --without-xpath
@ -609,21 +601,12 @@ AM_CONDITIONAL(WITH_CATALOG_SOURCES, test "$WITH_CATALOG" = "1")
if test "$with_xptr" = "no" ; then
echo Disabling XPointer support
WITH_XPTR=0
WITH_XPTR_LOCS=0
else
WITH_XPTR=1
fi
AC_SUBST(WITH_XPTR)
AM_CONDITIONAL(WITH_XPTR_SOURCES, test "$WITH_XPTR" = "1")
if test "$with_xptr_locs" != "yes" ; then
WITH_XPTR_LOCS=0
else
echo Enabling Xpointer locations support
WITH_XPTR_LOCS=1
fi
AC_SUBST(WITH_XPTR_LOCS)
if test "$with_c14n" = "no" ; then
echo Disabling C14N support
WITH_C14N=0

View File

@ -1830,20 +1830,6 @@ xmlShellPrintXPathError(int errorType, const char *arg)
fprintf(stderr,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
fprintf(stderr,
"%s is a point\n", arg);
break;
case XPATH_RANGE:
fprintf(stderr,
"%s is a range\n", arg);
break;
case XPATH_LOCATIONSET:
fprintf(stderr,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
fprintf(stderr,
"%s is user-defined\n", arg);
@ -2992,20 +2978,6 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,
fprintf(ctxt->output,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
fprintf(ctxt->output,
"%s is a point\n", arg);
break;
case XPATH_RANGE:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
case XPATH_LOCATIONSET:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
fprintf(ctxt->output,
"%s is user-defined\n", arg);
@ -3111,20 +3083,6 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,
fprintf(ctxt->output,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
fprintf(ctxt->output,
"%s is a point\n", arg);
break;
case XPATH_RANGE:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
case XPATH_LOCATIONSET:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
fprintf(ctxt->output,
"%s is user-defined\n", arg);
@ -3190,20 +3148,6 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,
fprintf(ctxt->output,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
fprintf(ctxt->output,
"%s is a point\n", arg);
break;
case XPATH_RANGE:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
case XPATH_LOCATIONSET:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
fprintf(ctxt->output,
"%s is user-defined\n", arg);
@ -3277,20 +3221,6 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,
fprintf(ctxt->output,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
fprintf(ctxt->output,
"%s is a point\n", arg);
break;
case XPATH_RANGE:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
case XPATH_LOCATIONSET:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
fprintf(ctxt->output,
"%s is user-defined\n", arg);
@ -3357,20 +3287,6 @@ xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input,
fprintf(ctxt->output,
"%s is a string\n", arg);
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
fprintf(ctxt->output,
"%s is a point\n", arg);
break;
case XPATH_RANGE:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
case XPATH_LOCATIONSET:
fprintf(ctxt->output,
"%s is a range\n", arg);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
fprintf(ctxt->output,
"%s is user-defined\n", arg);

View File

@ -155,13 +155,6 @@ skipped_functions = [
# Legacy
"xmlCleanupPredefinedEntities", "xmlInitializePredefinedEntities",
"xmlSetFeature", "xmlGetFeature", "xmlGetFeaturesList",
# location sets
"xmlXPtrLocationSetAdd",
"xmlXPtrLocationSetCreate",
"xmlXPtrLocationSetDel",
"xmlXPtrLocationSetMerge",
"xmlXPtrLocationSetRemove",
"xmlXPtrWrapLocationSet",
]
#

View File

@ -32,7 +32,6 @@ xmlversion_h.set10('WITH_WRITER', want_writer)
xmlversion_h.set10('WITH_XINCLUDE', want_xinclude)
xmlversion_h.set10('WITH_XPATH', want_xpath)
xmlversion_h.set10('WITH_XPTR', want_xptr)
xmlversion_h.set10('WITH_XPTR_LOCS', want_xptr_locs)
xmlversion_h.set10('WITH_ZLIB', zlib_dep.found())
configure_file(

View File

@ -199,15 +199,6 @@
#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:
*

View File

@ -104,22 +104,15 @@ 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;

View File

@ -28,88 +28,10 @@
extern "C" {
#endif
#if defined(LIBXML_XPTR_LOCS_ENABLED)
/*
* A Location Set
*/
typedef struct _xmlLocationSet xmlLocationSet;
typedef xmlLocationSet *xmlLocationSetPtr;
struct _xmlLocationSet {
int locNr; /* number of locations in the set */
int locMax; /* size of the array as allocated */
xmlXPathObjectPtr *locTab;/* array of locations */
};
/*
* Handling of location sets.
*/
XML_DEPRECATED
XMLPUBFUN xmlLocationSetPtr
xmlXPtrLocationSetCreate (xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN void
xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
XML_DEPRECATED
XMLPUBFUN xmlLocationSetPtr
xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRange (xmlNodePtr start,
int startindex,
xmlNodePtr end,
int endindex);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangePoints (xmlXPathObjectPtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangeNodePoint (xmlNodePtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangePointNode (xmlXPathObjectPtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangeNodes (xmlNodePtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewLocationSetNodes (xmlNodePtr start,
xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangeNodeObject (xmlNodePtr start,
xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewCollapsedRange (xmlNodePtr start);
XML_DEPRECATED
XMLPUBFUN void
xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
XML_DEPRECATED
XMLPUBFUN void
xmlXPtrLocationSetDel (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN void
xmlXPtrLocationSetRemove (xmlLocationSetPtr cur,
int val);
#endif /* defined(LIBXML_XPTR_LOCS_ENABLED) */
/*
* Functions.
*/
XML_DEPRECATED
XMLPUBFUN xmlXPathContextPtr
xmlXPtrNewContext (xmlDocPtr doc,
xmlNodePtr here,
@ -118,18 +40,6 @@ XMLPUBFUN xmlXPathObjectPtr
xmlXPtrEval (const xmlChar *str,
xmlXPathContextPtr ctx);
#if defined(LIBXML_XPTR_LOCS_ENABLED)
XML_DEPRECATED
XMLPUBFUN void
xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
int nargs);
XML_DEPRECATED
XMLPUBFUN xmlNodePtr
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
XML_DEPRECATED
XMLPUBFUN void
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
#endif /* defined(LIBXML_XPTR_LOCS_ENABLED) */
#ifdef __cplusplus
}
#endif

157
legacy.c
View File

@ -1597,174 +1597,163 @@ xmlIOFTPClose(void *context ATTRIBUTE_UNUSED) {
* xpointer.h
*/
#ifndef LIBXML_XPTR_LOCS_ENABLED
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxml/xpointer.h>
/** DOC_DISABLE */
typedef struct _xmlLocationSet *xmlLocationSetPtr;
XMLPUBFUN void *
xmlXPtrNewRange(void *start, int startindex,
void *end, int endindex);
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRange(xmlNodePtr start, int startindex,
xmlNodePtr end, int endindex);
xmlXPathObjectPtr
xmlXPtrNewRange(xmlNodePtr start ATTRIBUTE_UNUSED,
void *
xmlXPtrNewRange(void *start ATTRIBUTE_UNUSED,
int startindex ATTRIBUTE_UNUSED,
xmlNodePtr end ATTRIBUTE_UNUSED,
void *end ATTRIBUTE_UNUSED,
int endindex ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangePoints(xmlXPathObjectPtr start, xmlXPathObjectPtr end);
XMLPUBFUN void *
xmlXPtrNewRangePoints(void *start, void *end);
xmlXPathObjectPtr
xmlXPtrNewRangePoints(xmlXPathObjectPtr start ATTRIBUTE_UNUSED,
xmlXPathObjectPtr end ATTRIBUTE_UNUSED) {
void *
xmlXPtrNewRangePoints(void *start ATTRIBUTE_UNUSED,
void *end ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangePointNode(xmlXPathObjectPtr start, xmlNodePtr end);
XMLPUBFUN void *
xmlXPtrNewRangePointNode(void *start, void *end);
xmlXPathObjectPtr
xmlXPtrNewRangePointNode(xmlXPathObjectPtr start ATTRIBUTE_UNUSED,
xmlNodePtr end ATTRIBUTE_UNUSED) {
void *
xmlXPtrNewRangePointNode(void *start ATTRIBUTE_UNUSED,
void *end ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangeNodePoint(xmlNodePtr start, xmlXPathObjectPtr end);
XMLPUBFUN void *
xmlXPtrNewRangeNodePoint(void *start, void *end);
xmlXPathObjectPtr
xmlXPtrNewRangeNodePoint(xmlNodePtr start ATTRIBUTE_UNUSED,
xmlXPathObjectPtr end ATTRIBUTE_UNUSED) {
void *
xmlXPtrNewRangeNodePoint(void *start ATTRIBUTE_UNUSED,
void *end ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangeNodes(xmlNodePtr start, xmlNodePtr end);
XMLPUBFUN void *
xmlXPtrNewRangeNodes(void *start, void *end);
xmlXPathObjectPtr
xmlXPtrNewRangeNodes(xmlNodePtr start ATTRIBUTE_UNUSED,
xmlNodePtr end ATTRIBUTE_UNUSED) {
void *
xmlXPtrNewRangeNodes(void *start ATTRIBUTE_UNUSED,
void *end ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewCollapsedRange(xmlNodePtr start);
XMLPUBFUN void *
xmlXPtrNewCollapsedRange(void *start);
xmlXPathObjectPtr
xmlXPtrNewCollapsedRange(xmlNodePtr start ATTRIBUTE_UNUSED) {
void *
xmlXPtrNewCollapsedRange(void *start ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewRangeNodeObject(xmlNodePtr start, xmlXPathObjectPtr end);
XMLPUBFUN void *
xmlXPtrNewRangeNodeObject(void *start, void *end);
xmlXPathObjectPtr
xmlXPtrNewRangeNodeObject(xmlNodePtr start ATTRIBUTE_UNUSED,
xmlXPathObjectPtr end ATTRIBUTE_UNUSED) {
void *
xmlXPtrNewRangeNodeObject(void *start ATTRIBUTE_UNUSED,
void *end ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlLocationSetPtr
xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
XMLPUBFUN void *
xmlXPtrLocationSetCreate(void *val);
xmlLocationSetPtr
xmlXPtrLocationSetCreate(xmlXPathObjectPtr val ATTRIBUTE_UNUSED) {
void *
xmlXPtrLocationSetCreate(void *val ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN void
xmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val);
xmlXPtrLocationSetAdd(void *cur, void *val);
void
xmlXPtrLocationSetAdd(xmlLocationSetPtr cur ATTRIBUTE_UNUSED,
xmlXPathObjectPtr val ATTRIBUTE_UNUSED) {
xmlXPtrLocationSetAdd(void *cur ATTRIBUTE_UNUSED,
void *val ATTRIBUTE_UNUSED) {
}
XMLPUBFUN xmlLocationSetPtr
xmlXPtrLocationSetMerge(xmlLocationSetPtr val1, xmlLocationSetPtr val2);
XMLPUBFUN void *
xmlXPtrLocationSetMerge(void *val1, void *val2);
xmlLocationSetPtr
xmlXPtrLocationSetMerge(xmlLocationSetPtr val1 ATTRIBUTE_UNUSED,
xmlLocationSetPtr val2 ATTRIBUTE_UNUSED) {
void *
xmlXPtrLocationSetMerge(void *val1 ATTRIBUTE_UNUSED,
void *val2 ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN void
xmlXPtrLocationSetDel(xmlLocationSetPtr cur, xmlXPathObjectPtr val);
xmlXPtrLocationSetDel(void *cur, void *val);
void
xmlXPtrLocationSetDel(xmlLocationSetPtr cur ATTRIBUTE_UNUSED,
xmlXPathObjectPtr val ATTRIBUTE_UNUSED) {
xmlXPtrLocationSetDel(void *cur ATTRIBUTE_UNUSED,
void *val ATTRIBUTE_UNUSED) {
}
XMLPUBFUN void
xmlXPtrLocationSetRemove(xmlLocationSetPtr cur, int val);
xmlXPtrLocationSetRemove(void *cur, int val);
void
xmlXPtrLocationSetRemove(xmlLocationSetPtr cur ATTRIBUTE_UNUSED,
xmlXPtrLocationSetRemove(void *cur ATTRIBUTE_UNUSED,
int val ATTRIBUTE_UNUSED) {
}
XMLPUBFUN void
xmlXPtrFreeLocationSet(xmlLocationSetPtr obj);
xmlXPtrFreeLocationSet(void *obj);
void
xmlXPtrFreeLocationSet(xmlLocationSetPtr obj ATTRIBUTE_UNUSED) {
xmlXPtrFreeLocationSet(void *obj ATTRIBUTE_UNUSED) {
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewLocationSetNodes(xmlNodePtr start, xmlNodePtr end);
XMLPUBFUN void *
xmlXPtrNewLocationSetNodes(void *start, void *end);
xmlXPathObjectPtr
xmlXPtrNewLocationSetNodes(xmlNodePtr start ATTRIBUTE_UNUSED,
xmlNodePtr end ATTRIBUTE_UNUSED) {
void *
xmlXPtrNewLocationSetNodes(void *start ATTRIBUTE_UNUSED,
void *end ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
XMLPUBFUN void *
xmlXPtrNewLocationSetNodeSet(void *set);
xmlXPathObjectPtr
xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set ATTRIBUTE_UNUSED) {
void *
xmlXPtrNewLocationSetNodeSet(void *set ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlXPathObjectPtr
xmlXPtrWrapLocationSet(xmlLocationSetPtr val);
XMLPUBFUN void *
xmlXPtrWrapLocationSet(void *val);
xmlXPathObjectPtr
xmlXPtrWrapLocationSet(xmlLocationSetPtr val ATTRIBUTE_UNUSED) {
void *
xmlXPtrWrapLocationSet(void *val ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN xmlNodePtr
xmlXPtrBuildNodeList(xmlXPathObjectPtr obj);
XMLPUBFUN void *
xmlXPtrBuildNodeList(void *obj);
xmlNodePtr
xmlXPtrBuildNodeList(xmlXPathObjectPtr obj ATTRIBUTE_UNUSED) {
void *
xmlXPtrBuildNodeList(void *obj ATTRIBUTE_UNUSED) {
return(NULL);
}
XMLPUBFUN void
xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs);
xmlXPtrRangeToFunction(void *ctxt, int nargs);
void
xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt,
xmlXPtrRangeToFunction(void *ctxt ATTRIBUTE_UNUSED,
int nargs ATTRIBUTE_UNUSED) {
XP_ERROR(XPATH_EXPR_ERROR);
}
/** DOC_ENABLE */
#endif /* #ifndef LIBXML_XPTR_LOCS_ENABLED */
#endif /* LIBXML_LEGACY_ENABLED */

View File

@ -80,7 +80,6 @@ want_writer = get_option('writer')
want_xinclude = get_option('xinclude')
want_xpath = get_option('xpath')
want_xptr = get_option('xptr')
want_xptr_locs = get_option('xptr-locs')
# TODO: Options should be three-valued: "yes", "no", default
@ -154,13 +153,6 @@ if want_xinclude == true
want_xpath = true
endif
if want_xptr_locs == true
if want_xptr == false
message('-Dxptr-locs=true overrides -Dxptr')
endif
want_xptr = true
endif
if want_xptr == true
if want_xpath == false
message('-Dxptr=true overrides -Dxpath')
@ -197,7 +189,6 @@ if get_option('minimum')
want_xinclude = false
want_xpath = false
want_xptr = false
want_xptr_locs = false
else
# Disable dependent modules
if want_output == false
@ -833,7 +824,6 @@ summary(
'xinclude': want_xinclude,
'xpath': want_xpath,
'xptr': want_xptr,
'xptr-locs': want_xptr_locs,
'zlib': zlib_dep.found(),
},
section: 'Configuration Options Summary:',

View File

@ -32,7 +32,6 @@
# [X] xinclude
# [X] xpath
# [X] xptr
# [X] xptr-locs
# [X] zlib
# [X] minimum
@ -228,12 +227,6 @@ option('xptr',
description: 'XPointer support'
)
option('xptr-locs',
type: 'boolean',
value: false,
description: 'XPointer ranges and points'
)
option('zlib',
type: 'feature',
description: 'ZLIB support'

View File

@ -414,6 +414,7 @@ deprecated_funcs = {
'xmlXPathInit': True,
'xmlXPtrEvalRangePredicate': True,
'xmlXPtrNewCollapsedRange': True,
'xmlXPtrNewContext': True,
'xmlXPtrNewLocationSetNodes': True,
'xmlXPtrNewRange': True,
'xmlXPtrNewRangeNodes': True,

View File

@ -558,109 +558,6 @@ 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;
PyObject *indexIntoNode;
PyObject *tuple;
node = libxml_xmlNodePtrWrap(obj->user);
indexIntoNode = PY_IMPORT_INT((long) obj->index);
tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, node);
PyTuple_SetItem(tuple, 1, indexIntoNode);
ret = tuple;
break;
}
case XPATH_RANGE:
{
unsigned short bCollapsedRange;
bCollapsedRange = ( (obj->user2 == NULL) ||
((obj->user2 == obj->user) && (obj->index == obj->index2)) );
if ( bCollapsedRange ) {
PyObject *node;
PyObject *indexIntoNode;
PyObject *tuple;
PyObject *list;
list = PyList_New(1);
node = libxml_xmlNodePtrWrap(obj->user);
indexIntoNode = PY_IMPORT_INT((long) obj->index);
tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, node);
PyTuple_SetItem(tuple, 1, indexIntoNode);
PyList_SetItem(list, 0, tuple);
ret = list;
} else {
PyObject *node;
PyObject *indexIntoNode;
PyObject *tuple;
PyObject *list;
list = PyList_New(2);
node = libxml_xmlNodePtrWrap(obj->user);
indexIntoNode = PY_IMPORT_INT((long) obj->index);
tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, node);
PyTuple_SetItem(tuple, 1, indexIntoNode);
PyList_SetItem(list, 0, tuple);
node = libxml_xmlNodePtrWrap(obj->user2);
indexIntoNode = PY_IMPORT_INT((long) obj->index2);
tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, node);
PyTuple_SetItem(tuple, 1, indexIntoNode);
PyList_SetItem(list, 1, tuple);
ret = list;
}
break;
}
case XPATH_LOCATIONSET:
{
xmlLocationSetPtr set;
set = obj->user;
if ( set && set->locNr > 0 ) {
int i;
PyObject *list;
list = PyList_New(set->locNr);
for (i=0; i<set->locNr; i++) {
xmlXPathObjectPtr setobj;
PyObject *pyobj;
setobj = set->locTab[i]; /*xmlXPathObjectPtr setobj*/
pyobj = libxml_xmlXPathObjectPtrWrap(setobj);
/* xmlXPathFreeObject(setobj) is called */
set->locTab[i] = NULL;
PyList_SetItem(list, i, pyobj);
}
set->locNr = 0;
ret = list;
} else {
Py_INCREF(Py_None);
ret = Py_None;
}
break;
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
default:
Py_INCREF(Py_None);
ret = Py_None;

View File

@ -1,44 +0,0 @@
========================
Expression: xpath1(//chapitre[2])
Object is empty (NULL)
========================
Expression: xpath1(//chapter[2])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter2
========================
Expression: xpath1(//chapitre[2])xpath1(//chapter[2])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter2
========================
Expression: xpath1(id("chapter1"))
Object is empty (NULL)
========================
Expression: xpath1(//*[@id="chapter1"])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter1
========================
Expression: xpath1(id("chapter1"))xpath1(//*[@id="chapter1"])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter1

View File

@ -1,7 +0,0 @@
========================
Expression: xmlns(b=abc://d/e:f) xpath1(/b:rootB)
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT rootB
default namespace href=abc://d/e:f

View File

@ -1,9 +0,0 @@
========================
Expression: xpath1(id('chapter1')/p)
Object is a Node Set :
Set contains 4 nodes:
1 ELEMENT p
2 ELEMENT p
3 ELEMENT p
4 ELEMENT p

View File

@ -1,4 +0,0 @@
========================
Expression: xpath1(non-existing-fn())
Object is empty (NULL)

View File

@ -1,27 +0,0 @@
========================
Expression: xpath1(id("chapter1"))
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter1
========================
Expression: xpath1(//*[@id="chapter1"])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter1
========================
Expression: xpath1(id("chapter1"))xpath1(//*[@id="chapter1"])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter1

View File

@ -1,10 +1,10 @@
========================
Expression: xpointer(//chapitre[2])
Expression: xpath1(//chapitre[2])
Object is empty (NULL)
========================
Expression: xpointer(//chapter[2])
Expression: xpath1(//chapter[2])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
@ -13,7 +13,7 @@ Set contains 1 nodes:
content=chapter2
========================
Expression: xpointer(//chapitre[2])xpointer(//chapter[2])
Expression: xpath1(//chapitre[2])xpath1(//chapter[2])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
@ -22,11 +22,11 @@ Set contains 1 nodes:
content=chapter2
========================
Expression: xpointer(id("chapter1"))
Expression: xpath1(id("chapter1"))
Object is empty (NULL)
========================
Expression: xpointer(//*[@id="chapter1"])
Expression: xpath1(//*[@id="chapter1"])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
@ -35,7 +35,7 @@ Set contains 1 nodes:
content=chapter1
========================
Expression: xpointer(id("chapter1"))xpointer(//*[@id="chapter1"])
Expression: xpath1(id("chapter1"))xpath1(//*[@id="chapter1"])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter

View File

@ -1,64 +0,0 @@
========================
Expression: xpointer(//chapter[position() = 2]/range-to(following::chapter[1]))
Object is a Location Set:
1 : Object is a range :
From node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter2
To node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter3
========================
Expression: xpointer(//chapter[position() <= 2]/range-to(following::chapter[1]))
Object is a Location Set:
1 : Object is a range :
From node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter1
To node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter2
2 : Object is a range :
From node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter2
To node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter3
========================
Expression: xpointer(//chapter[position() = last()]/range-to(following::chapter[1]))
Object is empty (NULL)
========================
Expression: xpointer(//chapter[position() = 3]/range-to(/.//chapter[position() = 1]))
Object is a Location Set:
1 : Object is a range :
From node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter1
To node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter3

View File

@ -1,6 +1,6 @@
========================
Expression: xmlns(b=abc://d/e:f) xpointer(/b:rootB)
Expression: xmlns(b=abc://d/e:f) xpath1(/b:rootB)
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT rootB

View File

@ -1,75 +0,0 @@
========================
Expression: xpointer(start-point(string-range(//p,'multiple')))
Object is a Location Set:
1 : Object is a point : index 1 in node TEXT
content=multiple tests
========================
Expression: xpointer(end-point(string-range(//p,'multiple')))
Object is a Location Set:
1 : Object is a point : index 8 in node TEXT
content=multiple tests
========================
Expression: xpointer(start-point(string-range(//p,'test')))
Object is a Location Set:
1 : Object is a point : index 10 in node TEXT
content=a simple test
2 : Object is a point : index 10 in node TEXT
content=multiple tests
3 : Object is a point : index 7 in node TEXT
content=anced test
========================
Expression: xpointer(end-point(string-range(//p,'test')))
Object is a Location Set:
1 : Object is a point : index 13 in node TEXT
content=a simple test
2 : Object is a point : index 13 in node TEXT
content=multiple tests
3 : Object is a point : index 10 in node TEXT
content=anced test
========================
Expression: xpointer(start-point(string-range(//*,'multiple',1,0)))
Object is a Location Set:
1 : Object is a point : index 1 in node TEXT
content=multiple tests
========================
Expression: xpointer(end-point(string-range(//*,'multiple',1,0)))
Object is a Location Set:
1 : Object is a point : index 1 in node TEXT
content=multiple tests
========================
Expression: xpointer(start-point(string-range(//*,'multiple',1,1)))
Object is a Location Set:
1 : Object is a point : index 1 in node TEXT
content=multiple tests
========================
Expression: xpointer(end-point(string-range(//*,'multiple',1,1)))
Object is a Location Set:
1 : Object is a point : index 2 in node TEXT
content=multiple tests
========================
Expression: xpointer(start-point(string-range(//p,'test'))[1])
Object is a Location Set:
1 : Object is a point : index 10 in node TEXT
content=a simple test

View File

@ -1,96 +0,0 @@
========================
Expression: xpointer(string-range(//p, 'simple'))
Object is a Location Set:
1 : Object is a range :
From index 3 in node
TEXT
content=a simple test
To index 8 in node
TEXT
content=a simple test
========================
Expression: xpointer(string-range(//p, 'test'))
Object is a Location Set:
1 : Object is a range :
From index 10 in node
TEXT
content=a simple test
To index 13 in node
TEXT
content=a simple test
2 : Object is a range :
From index 10 in node
TEXT
content=multiple tests
To index 13 in node
TEXT
content=multiple tests
3 : Object is a range :
From index 7 in node
TEXT
content=anced test
To index 10 in node
TEXT
content=anced test
========================
Expression: xpointer(string-range(//p, 'difficult'))
Object is a Location Set:
1 : Object is a range :
From index 3 in node
TEXT
content=a diff
To index 4 in node
TEXT
content=cult one
========================
Expression: xpointer(string-range(//p, 'spanning'))
Object is a Location Set:
1 : Object is a range :
From index 3 in node
TEXT
content=a span
To index 3 in node
TEXT
content=ing one
========================
Expression: xpointer(string-range(//p, 'unbalanced'))
Object is a Location Set:
1 : Object is a range :
From index 8 in node
TEXT
content=and an unbal
To index 5 in node
TEXT
content=anced test
========================
Expression: xpointer(string-range(//seq, ''))
Object is a Location Set:
1 : Object is a collapsed range :
index 1 in node
TEXT
content=123
2 : Object is a collapsed range :
index 2 in node
TEXT
content=123
3 : Object is a collapsed range :
index 3 in node
TEXT
content=123
4 : Object is a collapsed range :
index 4 in node
TEXT
content=123

View File

@ -1,64 +0,0 @@
========================
Expression: xpointer(string-range(//p, 'test', 2))
Object is a Location Set:
1 : Object is a range :
From index 11 in node
TEXT
content=a simple test
To index 13 in node
TEXT
content=a simple test
2 : Object is a range :
From index 11 in node
TEXT
content=multiple tests
To index 13 in node
TEXT
content=multiple tests
3 : Object is a range :
From index 8 in node
TEXT
content=anced test
To index 10 in node
TEXT
content=anced test
========================
Expression: xpointer(string-range(//p, 'test', 2, 2))
Object is a Location Set:
1 : Object is a range :
From index 11 in node
TEXT
content=a simple test
To index 12 in node
TEXT
content=a simple test
2 : Object is a range :
From index 11 in node
TEXT
content=multiple tests
To index 12 in node
TEXT
content=multiple tests
3 : Object is a range :
From index 8 in node
TEXT
content=anced test
To index 9 in node
TEXT
content=anced test
========================
Expression: xpointer(string-range(//p, 'difficult', 1, 0))
Object is a Location Set:
1 : Object is a collapsed range :
index 3 in node
TEXT
content=a diff

View File

@ -1,48 +0,0 @@
========================
Expression: xpointer(string-range(//p, 'test', 1, 0))
Object is a Location Set:
1 : Object is a collapsed range :
index 10 in node
TEXT
content=a simple test
2 : Object is a collapsed range :
index 10 in node
TEXT
content=multiple tests
3 : Object is a collapsed range :
index 7 in node
TEXT
content=anced test
========================
Expression: xpointer(string-range(//*, 'test', 1, 0))
Object is a Location Set:
1 : Object is a collapsed range :
index 10 in node
TEXT
content=a simple test
2 : Object is a collapsed range :
index 10 in node
TEXT
content=multiple tests
3 : Object is a collapsed range :
index 7 in node
TEXT
content=anced test
========================
Expression: xpointer(string-range(//p, 'test', 1, 0)[2])
Object is a Location Set:
1 : Object is a collapsed range :
index 10 in node
TEXT
content=multiple tests
========================
Expression: xpointer(string-range(//*, 'test', 1, 0)[2])
Object is a Location Set:
1 : Object is a collapsed range :
index 10 in node
TEXT
content=multiple tests

View File

@ -1,32 +1,9 @@
========================
Expression: xpointer(id('chapter1')/p)
Expression: xpath1(id('chapter1')/p)
Object is a Node Set :
Set contains 4 nodes:
1 ELEMENT p
2 ELEMENT p
3 ELEMENT p
4 ELEMENT p
========================
Expression: xpointer(id('chapter1')/p[1]/range-to(following-sibling::p[2]))
Object is a Location Set:
1 : Object is a range :
From node
ELEMENT p
To node
ELEMENT p
========================
Expression: xpointer(range-to(id('chapter2')))
Object is a Location Set:
1 : Object is a range :
From node
/
To node
ELEMENT chapter
ATTRIBUTE id
TEXT
content=chapter2

View File

@ -1,4 +1,4 @@
========================
Expression: xpointer(non-existing-fn()/range-to(id('chapter2')))
Expression: xpath1(non-existing-fn())
Object is empty (NULL)

View File

@ -1,6 +1,6 @@
========================
Expression: xpointer(id("chapter1"))
Expression: xpath1(id("chapter1"))
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
@ -9,7 +9,7 @@ Set contains 1 nodes:
content=chapter1
========================
Expression: xpointer(//*[@id="chapter1"])
Expression: xpath1(//*[@id="chapter1"])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
@ -18,7 +18,7 @@ Set contains 1 nodes:
content=chapter1
========================
Expression: xpointer(id("chapter1"))xpointer(//*[@id="chapter1"])
Expression: xpath1(id("chapter1"))xpath1(//*[@id="chapter1"])
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter

View File

@ -2532,7 +2532,7 @@ testXPath(const char *str, int xptr, int expr) {
nb_tests++;
#if defined(LIBXML_XPTR_ENABLED)
if (xptr) {
ctxt = xmlXPtrNewContext(xpathDocument, NULL, NULL);
ctxt = xmlXPathNewContext(xpathDocument);
xmlXPathSetErrorHandler(ctxt, testStructuredErrorHandler, NULL);
res = xmlXPtrEval(BAD_CAST str, ctxt);
} else {
@ -2713,14 +2713,13 @@ static int
xptrDocTest(const char *filename,
const char *resul ATTRIBUTE_UNUSED,
const char *err ATTRIBUTE_UNUSED,
int options) {
int options ATTRIBUTE_UNUSED) {
char pattern[500];
char result[500];
glob_t globbuf;
size_t i;
int ret = 0, res;
const char *subdir = options == -1 ? "xptr-xp1" : "xptr";
xpathDocument = xmlReadFile(filename, NULL,
XML_PARSE_DTDATTR | XML_PARSE_NOENT);
@ -2729,15 +2728,15 @@ xptrDocTest(const char *filename,
return(-1);
}
res = snprintf(pattern, 499, "./test/XPath/%s/%s*",
subdir, baseFilename(filename));
res = snprintf(pattern, 499, "./test/XPath/xptr/%s*",
baseFilename(filename));
if (res >= 499)
pattern[499] = 0;
globbuf.gl_offs = 0;
glob(pattern, GLOB_DOOFFS, NULL, &globbuf);
for (i = 0;i < globbuf.gl_pathc;i++) {
res = snprintf(result, 499, "result/XPath/%s/%s",
subdir, baseFilename(globbuf.gl_pathv[i]));
res = snprintf(result, 499, "result/XPath/xptr/%s",
baseFilename(globbuf.gl_pathv[i]));
if (res >= 499)
result[499] = 0;
res = xpathCommonTest(globbuf.gl_pathv[i], &result[0], 1, 0);
@ -4834,11 +4833,6 @@ testDesc testDescriptions[] = {
0 },
#ifdef LIBXML_XPTR_ENABLED
{ "XPointer document queries regression tests" ,
xptrDocTest, "./test/XPath/docs/*", NULL, NULL, NULL,
-1 },
#endif
#ifdef LIBXML_XPTR_LOCS_ENABLED
{ "XPointer xpointer() queries regression tests" ,
xptrDocTest, "./test/XPath/docs/*", NULL, NULL, NULL,
0 },
#endif

View File

@ -1864,11 +1864,6 @@ 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;

View File

@ -1,6 +0,0 @@
xpath1(//chapitre[2])
xpath1(//chapter[2])
xpath1(//chapitre[2])xpath1(//chapter[2])
xpath1(id("chapter1"))
xpath1(//*[@id="chapter1"])
xpath1(id("chapter1"))xpath1(//*[@id="chapter1"])

View File

@ -1 +0,0 @@
xmlns(b=abc://d/e:f) xpath1(/b:rootB)

View File

@ -1 +0,0 @@
xpath1(id('chapter1')/p)

View File

@ -1 +0,0 @@
xpath1(non-existing-fn())

View File

@ -1,3 +0,0 @@
xpath1(id("chapter1"))
xpath1(//*[@id="chapter1"])
xpath1(id("chapter1"))xpath1(//*[@id="chapter1"])

View File

@ -1,6 +1,6 @@
xpointer(//chapitre[2])
xpointer(//chapter[2])
xpointer(//chapitre[2])xpointer(//chapter[2])
xpointer(id("chapter1"))
xpointer(//*[@id="chapter1"])
xpointer(id("chapter1"))xpointer(//*[@id="chapter1"])
xpath1(//chapitre[2])
xpath1(//chapter[2])
xpath1(//chapitre[2])xpath1(//chapter[2])
xpath1(id("chapter1"))
xpath1(//*[@id="chapter1"])
xpath1(id("chapter1"))xpath1(//*[@id="chapter1"])

View File

@ -1,4 +0,0 @@
xpointer(//chapter[position() = 2]/range-to(following::chapter[1]))
xpointer(//chapter[position() <= 2]/range-to(following::chapter[1]))
xpointer(//chapter[position() = last()]/range-to(following::chapter[1]))
xpointer(//chapter[position() = 3]/range-to(/.//chapter[position() = 1]))

View File

@ -1 +1 @@
xmlns(b=abc://d/e:f) xpointer(/b:rootB)
xmlns(b=abc://d/e:f) xpath1(/b:rootB)

View File

@ -1,9 +0,0 @@
xpointer(start-point(string-range(//p,'multiple')))
xpointer(end-point(string-range(//p,'multiple')))
xpointer(start-point(string-range(//p,'test')))
xpointer(end-point(string-range(//p,'test')))
xpointer(start-point(string-range(//*,'multiple',1,0)))
xpointer(end-point(string-range(//*,'multiple',1,0)))
xpointer(start-point(string-range(//*,'multiple',1,1)))
xpointer(end-point(string-range(//*,'multiple',1,1)))
xpointer(start-point(string-range(//p,'test'))[1])

View File

@ -1,6 +0,0 @@
xpointer(string-range(//p, 'simple'))
xpointer(string-range(//p, 'test'))
xpointer(string-range(//p, 'difficult'))
xpointer(string-range(//p, 'spanning'))
xpointer(string-range(//p, 'unbalanced'))
xpointer(string-range(//seq, ''))

View File

@ -1,3 +0,0 @@
xpointer(string-range(//p, 'test', 2))
xpointer(string-range(//p, 'test', 2, 2))
xpointer(string-range(//p, 'difficult', 1, 0))

View File

@ -1,4 +0,0 @@
xpointer(string-range(//p, 'test', 1, 0))
xpointer(string-range(//*, 'test', 1, 0))
xpointer(string-range(//p, 'test', 1, 0)[2])
xpointer(string-range(//*, 'test', 1, 0)[2])

View File

@ -1,3 +1 @@
xpointer(id('chapter1')/p)
xpointer(id('chapter1')/p[1]/range-to(following-sibling::p[2]))
xpointer(range-to(id('chapter2')))
xpath1(id('chapter1')/p)

View File

@ -1 +1 @@
xpointer(non-existing-fn()/range-to(id('chapter2')))
xpath1(non-existing-fn())

View File

@ -1,3 +1,3 @@
xpointer(id("chapter1"))
xpointer(//*[@id="chapter1"])
xpointer(id("chapter1"))xpointer(//*[@id="chapter1"])
xpath1(id("chapter1"))
xpath1(//*[@id="chapter1"])
xpath1(id("chapter1"))xpath1(//*[@id="chapter1"])

488
testapi.c
View File

@ -52072,40 +52072,6 @@ test_xpathInternals(void) {
return(test_ret);
}
static int
test_xmlXPtrBuildNodeList(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlNodePtr ret_val;
xmlXPathObjectPtr obj; /* the XPointer result from the evaluation. */
int n_obj;
for (n_obj = 0;n_obj < gen_nb_xmlXPathObjectPtr;n_obj++) {
mem_base = xmlMemBlocks();
obj = gen_xmlXPathObjectPtr(n_obj, 0);
ret_val = xmlXPtrBuildNodeList(obj);
desret_xmlNodePtr(ret_val);
call_tests++;
des_xmlXPathObjectPtr(n_obj, obj, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrBuildNodeList",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_obj);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrEval(void) {
int test_ret = 0;
@ -52147,72 +52113,6 @@ test_xmlXPtrEval(void) {
}
static int
test_xmlXPtrEvalRangePredicate(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */
int n_ctxt;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0);
xmlXPtrEvalRangePredicate(ctxt);
call_tests++;
des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrEvalRangePredicate",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewCollapsedRange(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting and ending node */
int n_start;
for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) {
mem_base = xmlMemBlocks();
start = gen_xmlNodePtr(n_start, 0);
ret_val = xmlXPtrNewCollapsedRange(start);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlNodePtr(n_start, start, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewCollapsedRange",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_start);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewContext(void) {
int test_ret = 0;
@ -52222,399 +52122,13 @@ test_xmlXPtrNewContext(void) {
return(test_ret);
}
static int
test_xmlXPtrNewLocationSetNodeSet(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlNodeSetPtr set; /* a node set */
int n_set;
for (n_set = 0;n_set < gen_nb_xmlNodeSetPtr;n_set++) {
mem_base = xmlMemBlocks();
set = gen_xmlNodeSetPtr(n_set, 0);
ret_val = xmlXPtrNewLocationSetNodeSet(set);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlNodeSetPtr(n_set, set, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewLocationSetNodeSet",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_set);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewLocationSetNodes(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the start NodePtr value */
int n_start;
xmlNodePtr end; /* the end NodePtr value or NULL */
int n_end;
for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) {
for (n_end = 0;n_end < gen_nb_xmlNodePtr;n_end++) {
mem_base = xmlMemBlocks();
start = gen_xmlNodePtr(n_start, 0);
end = gen_xmlNodePtr(n_end, 1);
ret_val = xmlXPtrNewLocationSetNodes(start, end);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlNodePtr(n_start, start, 0);
des_xmlNodePtr(n_end, end, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewLocationSetNodes",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_start);
printf(" %d", n_end);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewRange(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting node */
int n_start;
int startindex; /* the start index */
int n_startindex;
xmlNodePtr end; /* the ending point */
int n_end;
int endindex; /* the ending index */
int n_endindex;
for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) {
for (n_startindex = 0;n_startindex < gen_nb_int;n_startindex++) {
for (n_end = 0;n_end < gen_nb_xmlNodePtr;n_end++) {
for (n_endindex = 0;n_endindex < gen_nb_int;n_endindex++) {
mem_base = xmlMemBlocks();
start = gen_xmlNodePtr(n_start, 0);
startindex = gen_int(n_startindex, 1);
end = gen_xmlNodePtr(n_end, 2);
endindex = gen_int(n_endindex, 3);
ret_val = xmlXPtrNewRange(start, startindex, end, endindex);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlNodePtr(n_start, start, 0);
des_int(n_startindex, startindex, 1);
des_xmlNodePtr(n_end, end, 2);
des_int(n_endindex, endindex, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewRange",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_start);
printf(" %d", n_startindex);
printf(" %d", n_end);
printf(" %d", n_endindex);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewRangeNodeObject(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting node */
int n_start;
xmlXPathObjectPtr end; /* the ending object */
int n_end;
for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) {
for (n_end = 0;n_end < gen_nb_xmlXPathObjectPtr;n_end++) {
mem_base = xmlMemBlocks();
start = gen_xmlNodePtr(n_start, 0);
end = gen_xmlXPathObjectPtr(n_end, 1);
ret_val = xmlXPtrNewRangeNodeObject(start, end);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlNodePtr(n_start, start, 0);
des_xmlXPathObjectPtr(n_end, end, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewRangeNodeObject",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_start);
printf(" %d", n_end);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewRangeNodePoint(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting node */
int n_start;
xmlXPathObjectPtr end; /* the ending point */
int n_end;
for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) {
for (n_end = 0;n_end < gen_nb_xmlXPathObjectPtr;n_end++) {
mem_base = xmlMemBlocks();
start = gen_xmlNodePtr(n_start, 0);
end = gen_xmlXPathObjectPtr(n_end, 1);
ret_val = xmlXPtrNewRangeNodePoint(start, end);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlNodePtr(n_start, start, 0);
des_xmlXPathObjectPtr(n_end, end, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewRangeNodePoint",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_start);
printf(" %d", n_end);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewRangeNodes(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting node */
int n_start;
xmlNodePtr end; /* the ending node */
int n_end;
for (n_start = 0;n_start < gen_nb_xmlNodePtr;n_start++) {
for (n_end = 0;n_end < gen_nb_xmlNodePtr;n_end++) {
mem_base = xmlMemBlocks();
start = gen_xmlNodePtr(n_start, 0);
end = gen_xmlNodePtr(n_end, 1);
ret_val = xmlXPtrNewRangeNodes(start, end);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlNodePtr(n_start, start, 0);
des_xmlNodePtr(n_end, end, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewRangeNodes",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_start);
printf(" %d", n_end);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewRangePointNode(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlXPathObjectPtr start; /* the starting point */
int n_start;
xmlNodePtr end; /* the ending node */
int n_end;
for (n_start = 0;n_start < gen_nb_xmlXPathObjectPtr;n_start++) {
for (n_end = 0;n_end < gen_nb_xmlNodePtr;n_end++) {
mem_base = xmlMemBlocks();
start = gen_xmlXPathObjectPtr(n_start, 0);
end = gen_xmlNodePtr(n_end, 1);
ret_val = xmlXPtrNewRangePointNode(start, end);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlXPathObjectPtr(n_start, start, 0);
des_xmlNodePtr(n_end, end, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewRangePointNode",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_start);
printf(" %d", n_end);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrNewRangePoints(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlXPathObjectPtr start; /* the starting point */
int n_start;
xmlXPathObjectPtr end; /* the ending point */
int n_end;
for (n_start = 0;n_start < gen_nb_xmlXPathObjectPtr;n_start++) {
for (n_end = 0;n_end < gen_nb_xmlXPathObjectPtr;n_end++) {
mem_base = xmlMemBlocks();
start = gen_xmlXPathObjectPtr(n_start, 0);
end = gen_xmlXPathObjectPtr(n_end, 1);
ret_val = xmlXPtrNewRangePoints(start, end);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlXPathObjectPtr(n_start, start, 0);
des_xmlXPathObjectPtr(n_end, end, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrNewRangePoints",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_start);
printf(" %d", n_end);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrRangeToFunction(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base;
xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */
int n_ctxt;
int nargs; /* the number of args */
int n_nargs;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) {
for (n_nargs = 0;n_nargs < gen_nb_int;n_nargs++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0);
nargs = gen_int(n_nargs, 1);
xmlXPtrRangeToFunction(ctxt, nargs);
call_tests++;
des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0);
des_int(n_nargs, nargs, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrRangeToFunction",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_nargs);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xpointer(void) {
int test_ret = 0;
if (quiet == 0) printf("Testing xpointer : 13 of 21 functions ...\n");
test_ret += test_xmlXPtrBuildNodeList();
if (quiet == 0) printf("Testing xpointer : 1 of 2 functions ...\n");
test_ret += test_xmlXPtrEval();
test_ret += test_xmlXPtrEvalRangePredicate();
test_ret += test_xmlXPtrNewCollapsedRange();
test_ret += test_xmlXPtrNewContext();
test_ret += test_xmlXPtrNewLocationSetNodeSet();
test_ret += test_xmlXPtrNewLocationSetNodes();
test_ret += test_xmlXPtrNewRange();
test_ret += test_xmlXPtrNewRangeNodeObject();
test_ret += test_xmlXPtrNewRangeNodePoint();
test_ret += test_xmlXPtrNewRangeNodes();
test_ret += test_xmlXPtrNewRangePointNode();
test_ret += test_xmlXPtrNewRangePoints();
test_ret += test_xmlXPtrRangeToFunction();
if (test_ret != 0)
printf("Module xpointer: %d errors\n", test_ret);

View File

@ -35,7 +35,6 @@ var withC14n = true;
var withCatalog = true;
var withXpath = true;
var withXptr = true;
var withXptrLocs = false;
var withXinclude = true;
var withIconv = true;
var withIcu = false;
@ -117,7 +116,6 @@ function usage()
txt += " catalog: Enable catalog support (" + (withCatalog? "yes" : "no") + ")\n";
txt += " xpath: Enable XPath support (" + (withXpath? "yes" : "no") + ")\n";
txt += " xptr: Enable XPointer support (" + (withXptr? "yes" : "no") + ")\n";
txt += " xptr_locs: Enable XPointer locs support (" + (withXptrLocs? "yes" : "no") + ")\n";
txt += " xinclude: Enable XInclude support (" + (withXinclude? "yes" : "no") + ")\n";
txt += " iconv: Enable iconv support (" + (withIconv? "yes" : "no") + ")\n";
txt += " icu: Enable icu support (" + (withIcu? "yes" : "no") + ")\n";
@ -210,7 +208,6 @@ function discoverVersion()
vf.WriteLine("WITH_CATALOG=" + (withCatalog? "1" : "0"));
vf.WriteLine("WITH_XPATH=" + (withXpath? "1" : "0"));
vf.WriteLine("WITH_XPTR=" + (withXptr? "1" : "0"));
vf.WriteLine("WITH_XPTR_LOCS=" + (withXptrLocs? "1" : "0"));
vf.WriteLine("WITH_XINCLUDE=" + (withXinclude? "1" : "0"));
vf.WriteLine("WITH_ICONV=" + (withIconv? "1" : "0"));
vf.WriteLine("WITH_ICU=" + (withIcu? "1" : "0"));
@ -303,8 +300,6 @@ function configureLibxml()
of.WriteLine(s.replace(/\@WITH_XPATH\@/, withXpath? "1" : "0"));
} else if (s.search(/\@WITH_XPTR\@/) != -1) {
of.WriteLine(s.replace(/\@WITH_XPTR\@/, withXptr? "1" : "0"));
} else if (s.search(/\@WITH_XPTR_LOCS\@/) != -1) {
of.WriteLine(s.replace(/\@WITH_XPTR_LOCS\@/, withXptrLocs? "1" : "0"));
} else if (s.search(/\@WITH_XINCLUDE\@/) != -1) {
of.WriteLine(s.replace(/\@WITH_XINCLUDE\@/, withXinclude? "1" : "0"));
} else if (s.search(/\@WITH_ICONV\@/) != -1) {
@ -450,8 +445,6 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
withXpath = strToBool(arg.substring(opt.length + 1, arg.length));
else if (opt == "xptr")
withXptr = strToBool(arg.substring(opt.length + 1, arg.length));
else if (opt == "xptr_locs")
withXptrLocs = strToBool(arg.substring(opt.length + 1, arg.length));
else if (opt == "xinclude")
withXinclude = strToBool(arg.substring(opt.length + 1, arg.length));
else if (opt == "iconv")
@ -633,7 +626,6 @@ txtOut += " C14N support: " + boolToStr(withC14n) + "\n";
txtOut += " Catalog support: " + boolToStr(withCatalog) + "\n";
txtOut += " XPath support: " + boolToStr(withXpath) + "\n";
txtOut += " XPointer support: " + boolToStr(withXptr) + "\n";
txtOut += " XPointer locs: " + boolToStr(withXptrLocs) + "\n";
txtOut += " XInclude support: " + boolToStr(withXinclude) + "\n";
txtOut += " iconv support: " + boolToStr(withIconv) + "\n";
txtOut += " icu support: " + boolToStr(withIcu) + "\n";

View File

@ -786,244 +786,6 @@ error:
return(NULL);
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
/**
* xmlXIncludeGetNthChild:
* @cur: the node
* @no: the child number
*
* Returns the @n'th element child of @cur or NULL
*/
static xmlNodePtr
xmlXIncludeGetNthChild(xmlNodePtr cur, int no) {
int i;
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return(NULL);
cur = cur->children;
for (i = 0;i <= no;cur = cur->next) {
if (cur == NULL)
return(cur);
if ((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_DOCUMENT_NODE) ||
(cur->type == XML_HTML_DOCUMENT_NODE)) {
i++;
if (i == no)
break;
}
}
return(cur);
}
xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level); /* in xpointer.c */
/**
* xmlXIncludeCopyRange:
* @ctxt: the XInclude context
* @obj: the XPointer result from the evaluation.
*
* Build a node list tree copy of the XPointer result.
*
* Returns an xmlNodePtr list or NULL.
* The caller has to free the node tree.
*/
static xmlNodePtr
xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlXPathObjectPtr range) {
/* pointers to generated nodes */
xmlNodePtr list = NULL, last = NULL, listParent = NULL;
xmlNodePtr tmp, tmp2;
/* pointers to traversal nodes */
xmlNodePtr start, cur, end;
int index1, index2;
int level = 0, lastLevel = 0, endLevel = 0, endFlag = 0;
if ((ctxt == NULL) || (range == NULL))
return(NULL);
if (range->type != XPATH_RANGE)
return(NULL);
start = (xmlNodePtr) range->user;
if ((start == NULL) || (start->type == XML_NAMESPACE_DECL))
return(NULL);
end = range->user2;
if (end == NULL)
return(xmlDocCopyNode(start, ctxt->doc, 1));
if (end->type == XML_NAMESPACE_DECL)
return(NULL);
cur = start;
index1 = range->index;
index2 = range->index2;
/*
* level is depth of the current node under consideration
* list is the pointer to the root of the output tree
* listParent is a pointer to the parent of output tree (within
the included file) in case we need to add another level
* last is a pointer to the last node added to the output tree
* lastLevel is the depth of last (relative to the root)
*/
while (cur != NULL) {
/*
* Check if our output tree needs a parent
*/
if (level < 0) {
while (level < 0) {
/* copy must include namespaces and properties */
tmp2 = xmlDocCopyNode(listParent, ctxt->doc, 2);
xmlAddChild(tmp2, list);
list = tmp2;
listParent = listParent->parent;
level++;
}
last = list;
lastLevel = 0;
}
/*
* Check whether we need to change our insertion point
*/
while (level < lastLevel) {
last = last->parent;
lastLevel --;
}
if (cur == end) { /* Are we at the end of the range? */
if (cur->type == XML_TEXT_NODE) {
const xmlChar *content = cur->content;
int len;
if (content == NULL) {
tmp = xmlNewDocTextLen(ctxt->doc, NULL, 0);
} else {
len = index2;
if ((cur == start) && (index1 > 1)) {
content += (index1 - 1);
len -= (index1 - 1);
} else {
len = index2;
}
tmp = xmlNewDocTextLen(ctxt->doc, content, len);
}
/* single sub text node selection */
if (list == NULL)
return(tmp);
/* prune and return full set */
if (level == lastLevel)
xmlAddNextSibling(last, tmp);
else
xmlAddChild(last, tmp);
return(list);
} else { /* ending node not a text node */
endLevel = level; /* remember the level of the end node */
endFlag = 1;
/* last node - need to take care of properties + namespaces */
tmp = xmlDocCopyNode(cur, ctxt->doc, 2);
if (list == NULL) {
list = tmp;
listParent = cur->parent;
last = tmp;
} else {
if (level == lastLevel)
last = xmlAddNextSibling(last, tmp);
else {
last = xmlAddChild(last, tmp);
lastLevel = level;
}
}
if (index2 > 1) {
end = xmlXIncludeGetNthChild(cur, index2 - 1);
index2 = 0;
}
if ((cur == start) && (index1 > 1)) {
cur = xmlXIncludeGetNthChild(cur, index1 - 1);
index1 = 0;
} else {
cur = cur->children;
}
level++; /* increment level to show change */
/*
* Now gather the remaining nodes from cur to end
*/
continue; /* while */
}
} else if (cur == start) { /* Not at the end, are we at start? */
if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE)) {
const xmlChar *content = cur->content;
if (content == NULL) {
tmp = xmlNewDocTextLen(ctxt->doc, NULL, 0);
} else {
if (index1 > 1) {
content += (index1 - 1);
index1 = 0;
}
tmp = xmlNewDocText(ctxt->doc, content);
}
last = list = tmp;
listParent = cur->parent;
} else { /* Not text node */
/*
* start of the range - need to take care of
* properties and namespaces
*/
tmp = xmlDocCopyNode(cur, ctxt->doc, 2);
list = last = tmp;
listParent = cur->parent;
if (index1 > 1) { /* Do we need to position? */
cur = xmlXIncludeGetNthChild(cur, index1 - 1);
level = lastLevel = 1;
index1 = 0;
/*
* Now gather the remaining nodes from cur to end
*/
continue; /* while */
}
}
} else {
tmp = NULL;
switch (cur->type) {
case XML_DTD_NODE:
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_NODE:
/* Do not copy DTD information */
break;
case XML_ENTITY_DECL:
/* handle crossing entities -> stack needed */
break;
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
/* don't consider it part of the tree content */
break;
case XML_ATTRIBUTE_NODE:
/* Humm, should not happen ! */
break;
default:
/*
* Middle of the range - need to take care of
* properties and namespaces
*/
tmp = xmlDocCopyNode(cur, ctxt->doc, 2);
break;
}
if (tmp != NULL) {
if (level == lastLevel)
last = xmlAddNextSibling(last, tmp);
else {
last = xmlAddChild(last, tmp);
lastLevel = level;
}
}
}
/*
* Skip to next node in document order
*/
cur = xmlXPtrAdvanceNode(cur, &level);
if (endFlag && (level >= endLevel))
break;
}
return(list);
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
#ifdef LIBXML_XPTR_ENABLED
/**
* xmlXIncludeCopyXPointer:
@ -1103,33 +865,6 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlXPathObjectPtr obj,
}
break;
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET: {
xmlLocationSetPtr set = (xmlLocationSetPtr) obj->user;
if (set == NULL)
return(NULL);
for (i = 0;i < set->locNr;i++) {
if (last == NULL)
list = last = xmlXIncludeCopyXPointer(ctxt,
set->locTab[i],
targetBase);
else
xmlAddNextSibling(last,
xmlXIncludeCopyXPointer(ctxt, set->locTab[i],
targetBase));
if (last != NULL) {
while (last->next != NULL)
last = last->next;
}
}
break;
}
case XPATH_RANGE:
return(xmlXIncludeCopyRange(ctxt, obj));
case XPATH_POINT:
/* points are ignored in XInclude */
break;
#endif
default:
break;
}
@ -1465,7 +1200,7 @@ loaded:
}
if (ctxt->xpctxt == NULL) {
ctxt->xpctxt = xmlXPtrNewContext(doc, NULL, NULL);
ctxt->xpctxt = xmlXPathNewContext(doc);
if (ctxt->xpctxt == NULL) {
xmlXIncludeErrMemory(ctxt);
goto error;
@ -1492,9 +1227,6 @@ loaded:
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_STRING:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
#endif
case XPATH_USERS:
case XPATH_XSLT_TREE:
xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_XPTR_RESULT,
@ -1505,11 +1237,6 @@ loaded:
case XPATH_NODESET:
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_RANGE:
case XPATH_LOCATIONSET:
break;
#endif
}
set = xptr->nodesetval;
if (set != NULL) {

511
xpath.c
View File

@ -35,9 +35,6 @@
#include <libxml/xpathInternals.h>
#include <libxml/parserInternals.h>
#include <libxml/hash.h>
#ifdef LIBXML_XPTR_LOCS_ENABLED
#include <libxml/xpointer.h>
#endif
#ifdef LIBXML_DEBUG_ENABLED
#include <libxml/debugXML.h>
#endif
@ -790,9 +787,6 @@ typedef enum {
XPATH_OP_PREDICATE,
XPATH_OP_FILTER, /* 16 */
XPATH_OP_SORT /* 17 */
#ifdef LIBXML_XPTR_LOCS_ENABLED
,XPATH_OP_RANGETO
#endif
} xmlXPathOp;
typedef enum {
@ -1187,30 +1181,6 @@ xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
fprintf(output, "%d", i + 1);
xmlXPathDebugDumpNodeList(output, cur->nodeTab[0]->children, depth + 1);
}
#if defined(LIBXML_XPTR_LOCS_ENABLED)
static void
xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
int i;
char shift[100];
for (i = 0;((i < depth) && (i < 25));i++)
shift[2 * i] = shift[2 * i + 1] = ' ';
shift[2 * i] = shift[2 * i + 1] = 0;
if (cur == NULL) {
fprintf(output, "%s", shift);
fprintf(output, "LocationSet is NULL !\n");
return;
}
for (i = 0;i < cur->locNr;i++) {
fprintf(output, "%s", shift);
fprintf(output, "%d : ", i + 1);
xmlXPathDebugDumpObject(output, cur->locTab[i], depth + 1);
}
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/**
* xmlXPathDebugDumpObject:
@ -1279,47 +1249,6 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
xmlDebugDumpString(output, cur->stringval);
fprintf(output, "\n");
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
fprintf(output, "Object is a point : index %d in node", cur->index);
xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1);
fprintf(output, "\n");
break;
case XPATH_RANGE:
if ((cur->user2 == NULL) ||
((cur->user2 == cur->user) && (cur->index == cur->index2))) {
fprintf(output, "Object is a collapsed range :\n");
fprintf(output, "%s", shift);
if (cur->index >= 0)
fprintf(output, "index %d in ", cur->index);
fprintf(output, "node\n");
xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user,
depth + 1);
} else {
fprintf(output, "Object is a range :\n");
fprintf(output, "%s", shift);
fprintf(output, "From ");
if (cur->index >= 0)
fprintf(output, "index %d in ", cur->index);
fprintf(output, "node\n");
xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user,
depth + 1);
fprintf(output, "%s", shift);
fprintf(output, "To ");
if (cur->index2 >= 0)
fprintf(output, "index %d in ", cur->index2);
fprintf(output, "node\n");
xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user2,
depth + 1);
fprintf(output, "\n");
}
break;
case XPATH_LOCATIONSET:
fprintf(output, "Object is a Location Set:\n");
xmlXPathDebugDumpLocationSet(output,
(xmlLocationSetPtr) cur->user, depth);
break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS:
fprintf(output, "Object is user defined\n");
break;
@ -1487,9 +1416,6 @@ xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
case XPATH_OP_ARG: fprintf(output, "ARG"); break;
case XPATH_OP_PREDICATE: fprintf(output, "PREDICATE"); break;
case XPATH_OP_FILTER: fprintf(output, "FILTER"); break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_OP_RANGETO: fprintf(output, "RANGETO"); break;
#endif
default:
fprintf(output, "UNKNOWN %d\n", op->op); return;
}
@ -2024,11 +1950,6 @@ xmlXPathCastToNumberInternal(xmlXPathParserContextPtr ctxt,
ret = xmlXPathCastBooleanToNumber(val->boolval);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
ret = xmlXPathNAN;
break;
@ -4460,10 +4381,6 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
switch (val->type) {
case XPATH_BOOLEAN:
case XPATH_NUMBER:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
break;
case XPATH_STRING:
ret->stringval = xmlStrdup(val->stringval);
@ -4514,14 +4431,6 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
/* Do not deallocate the copied tree value */
ret->boolval = 0;
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET:
{
xmlLocationSetPtr loc = val->user;
ret->user = (void *) xmlXPtrLocationSetMerge(NULL, loc);
break;
}
#endif
case XPATH_USERS:
ret->user = val->user;
break;
@ -4545,11 +4454,6 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
if ((obj->type == XPATH_NODESET) || (obj->type == XPATH_XSLT_TREE)) {
if (obj->nodesetval != NULL)
xmlXPathFreeNodeSet(obj->nodesetval);
#ifdef LIBXML_XPTR_LOCS_ENABLED
} else if (obj->type == XPATH_LOCATIONSET) {
if (obj->user != NULL)
xmlXPtrFreeLocationSet(obj->user);
#endif
} else if (obj->type == XPATH_STRING) {
if (obj->stringval != NULL)
xmlFree(obj->stringval);
@ -4604,13 +4508,6 @@ xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
case XPATH_BOOLEAN:
case XPATH_NUMBER:
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET:
if (obj->user != NULL) {
xmlXPtrFreeLocationSet(obj->user);
}
goto free_obj;
#endif
default:
goto free_obj;
}
@ -4786,11 +4683,6 @@ xmlXPathCastToString(xmlXPathObjectPtr val) {
break;
}
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
ret = xmlStrdup((const xmlChar *) "");
break;
@ -4830,11 +4722,6 @@ xmlXPathConvertString(xmlXPathObjectPtr val) {
res = xmlXPathCastNumberToString(val->floatval);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
break;
}
@ -5044,11 +4931,6 @@ xmlXPathCastToBoolean (xmlXPathObjectPtr val) {
ret = val->boolval;
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
ret = 0;
break;
@ -5964,11 +5846,6 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
ret = (arg1->boolval == ret);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
break;
case XPATH_NODESET:
@ -6021,11 +5898,6 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
}
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
break;
case XPATH_NODESET:
@ -6082,11 +5954,6 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
}
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
break;
case XPATH_NODESET:
@ -6095,11 +5962,6 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
}
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
break;
case XPATH_NODESET:
@ -6175,11 +6037,6 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
arg2->stringval, 0);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
break;
}
@ -6255,11 +6112,6 @@ xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
arg2->stringval, 1);
break;
case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* TODO */
break;
}
@ -9599,11 +9451,6 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
/* Node Type or Function */
if (xmlXPathIsNodeType(name)) {
lc = 1;
#ifdef LIBXML_XPTR_LOCS_ENABLED
} else if (ctxt->xptr &&
xmlStrEqual(name, BAD_CAST "range-to")) {
lc = 1;
#endif
} else {
lc = 0;
}
@ -10234,11 +10081,6 @@ xmlXPathIsAxisName(const xmlChar *name) {
*/
static void
xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
#ifdef LIBXML_XPTR_LOCS_ENABLED
int rangeto = 0;
int op2 = -1;
#endif
SKIP_BLANKS;
if ((CUR == '.') && (NXT(1) == '.')) {
SKIP(2);
@ -10256,36 +10098,6 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
xmlXPathTypeVal type = (xmlXPathTypeVal) 0;
int op1;
/*
* The modification needed for XPointer change to the production
*/
#ifdef LIBXML_XPTR_LOCS_ENABLED
if (ctxt->xptr) {
name = xmlXPathParseNCName(ctxt);
if ((name != NULL) && (xmlStrEqual(name, BAD_CAST "range-to"))) {
op2 = ctxt->comp->last;
xmlFree(name);
SKIP_BLANKS;
if (CUR != '(') {
XP_ERROR(XPATH_EXPR_ERROR);
}
NEXT;
SKIP_BLANKS;
xmlXPathCompileExpr(ctxt, 1);
/* PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, ctxt->comp->last, 0, 0); */
CHECK_ERROR;
SKIP_BLANKS;
if (CUR != ')') {
XP_ERROR(XPATH_EXPR_ERROR);
}
NEXT;
rangeto = 1;
goto eval_predicates;
}
}
#endif
if (CUR == '*') {
axis = AXIS_CHILD;
} else {
@ -10330,9 +10142,6 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
}
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
eval_predicates:
#endif
op1 = ctxt->comp->last;
ctxt->comp->last = -1;
@ -10341,11 +10150,6 @@ eval_predicates:
xmlXPathCompPredicate(ctxt, 0);
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
if (rangeto) {
PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, op1, 0, 0);
} else
#endif
if (PUSH_FULL_EXPR(XPATH_OP_COLLECT, op1, ctxt->comp->last, axis,
test, type, (void *)prefix, (void *)name) == -1) {
xmlFree(prefix);
@ -10587,125 +10391,6 @@ xmlXPathNodeSetFilter(xmlXPathParserContextPtr ctxt,
xpctxt->proximityPosition = oldpp;
}
#ifdef LIBXML_XPTR_LOCS_ENABLED
/**
* xmlXPathLocationSetFilter:
* @ctxt: the XPath Parser context
* @locset: the location set to filter
* @filterOpIndex: the index of the predicate/filter op
* @minPos: minimum position in the filtered set (1-based)
* @maxPos: maximum position in the filtered set (1-based)
*
* Filter a location set, keeping only nodes for which the predicate
* expression matches. Afterwards, keep only nodes between minPos and maxPos
* in the filtered result.
*/
static void
xmlXPathLocationSetFilter(xmlXPathParserContextPtr ctxt,
xmlLocationSetPtr locset,
int filterOpIndex,
int minPos, int maxPos)
{
xmlXPathContextPtr xpctxt;
xmlNodePtr oldnode;
xmlDocPtr olddoc;
xmlXPathStepOpPtr filterOp;
int oldcs, oldpp;
int i, j, pos;
if ((locset == NULL) || (locset->locNr == 0) || (filterOpIndex == -1))
return;
xpctxt = ctxt->context;
oldnode = xpctxt->node;
olddoc = xpctxt->doc;
oldcs = xpctxt->contextSize;
oldpp = xpctxt->proximityPosition;
filterOp = &ctxt->comp->steps[filterOpIndex];
xpctxt->contextSize = locset->locNr;
for (i = 0, j = 0, pos = 1; i < locset->locNr; i++) {
xmlNodePtr contextNode = locset->locTab[i]->user;
int res;
xpctxt->node = contextNode;
xpctxt->proximityPosition = i + 1;
/*
* Also set the xpath document in case things like
* key() are evaluated in the predicate.
*
* TODO: Get real doc for namespace nodes.
*/
if ((contextNode->type != XML_NAMESPACE_DECL) &&
(contextNode->doc != NULL))
xpctxt->doc = contextNode->doc;
res = xmlXPathCompOpEvalToBoolean(ctxt, filterOp, 1);
if (ctxt->error != XPATH_EXPRESSION_OK)
break;
if (res < 0) {
/* Shouldn't happen */
xmlXPathErr(ctxt, XPATH_EXPR_ERROR);
break;
}
if ((res != 0) && ((pos >= minPos) && (pos <= maxPos))) {
if (i != j) {
locset->locTab[j] = locset->locTab[i];
locset->locTab[i] = NULL;
}
j += 1;
} else {
/* Remove the entry from the initial location set. */
xmlXPathFreeObject(locset->locTab[i]);
locset->locTab[i] = NULL;
}
if (res != 0) {
if (pos == maxPos) {
i += 1;
break;
}
pos += 1;
}
}
/* Free remaining nodes. */
for (; i < locset->locNr; i++)
xmlXPathFreeObject(locset->locTab[i]);
locset->locNr = j;
/* If too many elements were removed, shrink table to preserve memory. */
if ((locset->locMax > XML_NODESET_DEFAULT) &&
(locset->locNr < locset->locMax / 2)) {
xmlXPathObjectPtr *tmp;
int locMax = locset->locNr;
if (locMax < XML_NODESET_DEFAULT)
locMax = XML_NODESET_DEFAULT;
tmp = (xmlXPathObjectPtr *) xmlRealloc(locset->locTab,
locMax * sizeof(xmlXPathObjectPtr));
if (tmp == NULL) {
xmlXPathPErrMemory(ctxt);
} else {
locset->locTab = tmp;
locset->locMax = locMax;
}
}
xpctxt->node = oldnode;
xpctxt->doc = olddoc;
xpctxt->contextSize = oldcs;
xpctxt->proximityPosition = oldpp;
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/**
* xmlXPathCompOpEvalPredicate:
* @ctxt: the XPath Parser context
@ -11745,23 +11430,6 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
if (ctxt->value == NULL)
return (total);
#ifdef LIBXML_XPTR_LOCS_ENABLED
/*
* Hum are we filtering the result of an XPointer expression
*/
if (ctxt->value->type == XPATH_LOCATIONSET) {
xmlLocationSetPtr locset = ctxt->value->user;
if (locset != NULL) {
xmlXPathLocationSetFilter(ctxt, locset, op->ch2, 1, 1);
if (locset->locNr > 0)
*first = (xmlNodePtr) locset->locTab[0]->user;
}
return (total);
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/*
* In case of errors, xmlXPathNodeSetFilter can pop additional nodes from
* the stack. We have to temporarily remove the nodeset object from the
@ -12148,18 +11816,6 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
if (ctxt->value == NULL)
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
/*
* Hum are we filtering the result of an XPointer expression
*/
if (ctxt->value->type == XPATH_LOCATIONSET) {
xmlLocationSetPtr locset = ctxt->value->user;
xmlXPathLocationSetFilter(ctxt, locset, op->ch2,
1, locset->locNr);
break;
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/*
* In case of errors, xmlXPathNodeSetFilter can pop additional
* nodes from the stack. We have to temporarily remove the
@ -12187,165 +11843,6 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
xmlXPathNodeSetSort(ctxt->value->nodesetval);
}
break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_OP_RANGETO:{
xmlXPathObjectPtr range;
xmlXPathObjectPtr res, obj;
xmlXPathObjectPtr tmp;
xmlLocationSetPtr newlocset = NULL;
xmlLocationSetPtr oldlocset;
xmlNodeSetPtr oldset;
xmlNodePtr oldnode = ctxt->context->node;
int oldcs = ctxt->context->contextSize;
int oldpp = ctxt->context->proximityPosition;
int i, j;
if (op->ch1 != -1) {
total +=
xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
}
if (ctxt->value == NULL) {
XP_ERROR0(XPATH_INVALID_OPERAND);
}
if (op->ch2 == -1)
break;
if (ctxt->value->type == XPATH_LOCATIONSET) {
/*
* Extract the old locset, and then evaluate the result of the
* expression for all the element in the locset. use it to grow
* up a new locset.
*/
CHECK_TYPE0(XPATH_LOCATIONSET);
if ((ctxt->value->user == NULL) ||
(((xmlLocationSetPtr) ctxt->value->user)->locNr == 0))
break;
obj = valuePop(ctxt);
oldlocset = obj->user;
newlocset = xmlXPtrLocationSetCreate(NULL);
for (i = 0; i < oldlocset->locNr; i++) {
/*
* Run the evaluation with a node list made of a
* single item in the nodelocset.
*/
ctxt->context->node = oldlocset->locTab[i]->user;
ctxt->context->contextSize = oldlocset->locNr;
ctxt->context->proximityPosition = i + 1;
tmp = xmlXPathCacheNewNodeSet(ctxt,
ctxt->context->node);
valuePush(ctxt, tmp);
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
&comp->steps[op->ch2]);
if (ctxt->error != XPATH_EXPRESSION_OK) {
xmlXPtrFreeLocationSet(newlocset);
goto rangeto_error;
}
res = valuePop(ctxt);
if (res->type == XPATH_LOCATIONSET) {
xmlLocationSetPtr rloc =
(xmlLocationSetPtr)res->user;
for (j=0; j<rloc->locNr; j++) {
range = xmlXPtrNewRange(
oldlocset->locTab[i]->user,
oldlocset->locTab[i]->index,
rloc->locTab[j]->user2,
rloc->locTab[j]->index2);
if (range != NULL) {
xmlXPtrLocationSetAdd(newlocset, range);
}
}
} else {
range = xmlXPtrNewRangeNodeObject(
(xmlNodePtr)oldlocset->locTab[i]->user, res);
if (range != NULL) {
xmlXPtrLocationSetAdd(newlocset,range);
}
}
/*
* Cleanup
*/
if (res != NULL) {
xmlXPathReleaseObject(ctxt->context, res);
}
if (ctxt->value == tmp) {
res = valuePop(ctxt);
xmlXPathReleaseObject(ctxt->context, res);
}
}
} else { /* Not a location set */
CHECK_TYPE0(XPATH_NODESET);
obj = valuePop(ctxt);
oldset = obj->nodesetval;
newlocset = xmlXPtrLocationSetCreate(NULL);
if (oldset != NULL) {
for (i = 0; i < oldset->nodeNr; i++) {
/*
* Run the evaluation with a node list made of a single item
* in the nodeset.
*/
ctxt->context->node = oldset->nodeTab[i];
/*
* OPTIMIZE TODO: Avoid recreation for every iteration.
*/
tmp = xmlXPathCacheNewNodeSet(ctxt,
ctxt->context->node);
valuePush(ctxt, tmp);
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
&comp->steps[op->ch2]);
if (ctxt->error != XPATH_EXPRESSION_OK) {
xmlXPtrFreeLocationSet(newlocset);
goto rangeto_error;
}
res = valuePop(ctxt);
range =
xmlXPtrNewRangeNodeObject(oldset->nodeTab[i],
res);
if (range != NULL) {
xmlXPtrLocationSetAdd(newlocset, range);
}
/*
* Cleanup
*/
if (res != NULL) {
xmlXPathReleaseObject(ctxt->context, res);
}
if (ctxt->value == tmp) {
res = valuePop(ctxt);
xmlXPathReleaseObject(ctxt->context, res);
}
}
}
}
/*
* The result is used as the new evaluation set.
*/
valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
rangeto_error:
xmlXPathReleaseObject(ctxt->context, obj);
ctxt->context->node = oldnode;
ctxt->context->contextSize = oldcs;
ctxt->context->proximityPosition = oldpp;
break;
}
#endif /* LIBXML_XPTR_LOCS_ENABLED */
default:
XP_ERROR0(XPATH_INVALID_OPERAND);
break;
@ -12839,14 +12336,6 @@ xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
return(res->nodesetval->nodeNr != 0);
case XPATH_STRING:
return((res->stringval != NULL) && (res->stringval[0] != 0));
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET:{
xmlLocationSetPtr ptr = res->user;
if (ptr == NULL)
return(0);
return (ptr->locNr != 0);
}
#endif
default:
break;
}

2252
xpointer.c

File diff suppressed because it is too large Load Diff