38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xpointer.c : Code to handle XML Pointer
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Base implementation was made accordingly to
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * W3C Candidate Recommendation 7 June 2000
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Added support for the element() scheme described in:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * W3C Proposed Recommendation 13 November 2002
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * http://www.w3.org/TR/2002/PR-xptr-element-20021113/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * See Copyright for the status of this software.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * daniel@veillard.com
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * TODO: better handling of error cases, the full expression should
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * be parsed beforehand instead of a progressive evaluation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * TODO: Access into entities references are not supported now ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * need a start to be able to pop out of entities refs since
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * parent is the endity declaration, not the ref.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* Add support of the xmlns() xpointer scheme to initialize the namespaces */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* #define DEBUG_RANGES */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Unimplemented block at %s:%d\n", \
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal error at %s:%d\n", \
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Some factorized error routines *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrErrMemory:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @extra: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Handle a redefinition of attribute error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_XPOINTER,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrErr:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: an XPTR evaluation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @extra: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Handle a redefinition of attribute error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrErr(xmlXPathParserContextPtr ctxt, int error,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->context->lastError.domain = XML_FROM_XPOINTER;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->context->lastError.str1 = (char *) xmlStrdup(ctxt->base);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->context->lastError.int1 = ctxt->cur - ctxt->base;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->context->lastError.node = ctxt->context->debugNode;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) extra, (const char *) ctxt->base, NULL,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * A few helper functions for child sequences *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* xmlXPtrAdvanceNode is a private function, but used by xinclude.c */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrGetArity:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the number of child for an element, -1 in case of error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrGetIndex:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the index of the node in its parent children list, -1
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * in case of error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrGetNthChild:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @no: the child number
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the @no'th element child of @cur or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Handling of XPointer specific types *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrCmpPoints:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node1: the first node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @index1: the first index
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node2: the second node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @index2: the second index
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Compare two points w.r.t document order
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -2 in case of error 1 if first point < second point, 0 if
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * that's the same point, -1 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrCmpPoints(xmlNodePtr node1, int index1, xmlNodePtr node2, int index2) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-2);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * a couple of optimizations which will avoid computations in most cases
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewPoint:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: the xmlNodePtr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @indx: the indx within the node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrRangeCheckOrder:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @range: an object range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Make sure the points in the range are in the right order
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrRangesEqual:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @range1: the first range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @range2: the second range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Compare two ranges
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns 1 if equal, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrRangesEqual(xmlXPathObjectPtr range1, xmlXPathObjectPtr range2) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewRange:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the starting node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @startindex: the start index
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the ending point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @endindex: the ending index
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewRangePoints:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the starting point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the ending point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type range using 2 Points
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrNewRangePoints(xmlXPathObjectPtr start, xmlXPathObjectPtr end) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewRangePointNode:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the starting point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the ending node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type range from a point to a node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrNewRangePointNode(xmlXPathObjectPtr start, xmlNodePtr end) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewRangeNodePoint:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the starting node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the ending point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type range from a node to a point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrNewRangeNodePoint(xmlNodePtr start, xmlXPathObjectPtr end) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewRangeNodes:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the starting node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the ending node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type range using 2 nodes
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrNewRangeNodes(xmlNodePtr start, xmlNodePtr end) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewCollapsedRange:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the starting and ending node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type range using a single nodes
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewRangeNodeObject:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the starting node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the ending object
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type range from a not to an object
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrNewRangeNodeObject(xmlNodePtr start, xmlXPathObjectPtr end) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Empty set ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret->user2 = end->nodesetval->nodeTab[end->nodesetval->nodeNr - 1];
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrLocationSetCreate:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @val: an initial xmlXPathObjectPtr, or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlLocationSetPtr of type double and of value @val
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlLocationSetPtr) xmlMalloc(sizeof(xmlLocationSet));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync XML_RANGESET_DEFAULT * (size_t) sizeof(xmlXPathObjectPtr));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrLocationSetAdd:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the initial range set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @val: a new xmlXPathObjectPtr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * add a new xmlXPathObjectPtr to an existing LocationSet
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * If the location already exist in the set @val is freed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * check against doublons
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * grow the locTab if needed
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync cur->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync XML_RANGESET_DEFAULT * (size_t) sizeof(xmlXPathObjectPtr));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync temp = (xmlXPathObjectPtr *) xmlRealloc(cur->locTab, cur->locMax *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrLocationSetMerge:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @val1: the first LocationSet
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @val2: the second LocationSet
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Merges two rangesets, all ranges from @val2 are added to @val1
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns val1 once extended or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrLocationSetMerge(xmlLocationSetPtr val1, xmlLocationSetPtr val2) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * !!!!! this can be optimized a lot, knowing that both
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * val1 and val2 already have unicity of their values.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrLocationSetDel:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the initial range set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @val: an xmlXPathObjectPtr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Removes an xmlXPathObjectPtr from an existing LocationSet
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrLocationSetDel(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * check against doublons
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlXPtrLocationSetDel: Range wasn't found in RangeList\n");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrLocationSetRemove:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the initial range set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @val: the index to remove
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Removes an entry from an existing LocationSet list.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrLocationSetRemove(xmlLocationSetPtr cur, int val) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrFreeLocationSet:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @obj: the xmlLocationSetPtr to free
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Free the LocationSet compound (not the actual ranges !).
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewLocationSetNodes:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the start NodePtr value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the end NodePtr value or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type LocationSet and initialize
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * it with the single range made of the two nodes @start and @end
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrNewLocationSetNodes(xmlNodePtr start, xmlNodePtr end) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret->user = xmlXPtrLocationSetCreate(xmlXPtrNewCollapsedRange(start));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret->user = xmlXPtrLocationSetCreate(xmlXPtrNewRangeNodes(start,end));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewLocationSetNodeSet:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @set: a node set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new xmlXPathObjectPtr of type LocationSet and initialize
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * it with all the nodes from @set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrWrapLocationSet:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @val: the LocationSet value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Wrap the LocationSet @val in a new xmlXPathObjectPtr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the newly created object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The parser *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncstatic void xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Macros for accessing the content. Those should be used only by the parser,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * and not exported.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Dirty macros, i.e. one need to make assumption on the context to use them
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * CUR_PTR return the current pointer to the xmlChar to be parsed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * CUR returns the current xmlChar value, i.e. a 8 bit value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * in ISO-Latin or UTF-8.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This should be used internally by the parser
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * only to compare to ASCII values otherwise it would break when
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * running with UTF-8 encoding.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * NXT(n) returns the n'th next xmlChar. Same as CUR is should be used only
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * to compare on ASCII based substring.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * SKIP(n) Skip n xmlChar, and must also be used only to skip ASCII defined
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * strings within the parser.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * CURRENT Returns the current char value, with the full decoding of
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * UTF-8 if we are using this mode. It returns an int.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * NEXT Skip to the next character, this does the proper decoding
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * in UTF-8 mode. It also pop-up unfinished entities on the fly.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * It returns the pointer to the current xmlChar.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrGetChildNo:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @index: the child number
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Move the current node of the nodeset on the stack to the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * given child if found
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int indx) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((indx <= 0) || (oldset == NULL) || (oldset->nodeNr != 1)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync cur = xmlXPtrGetNthChild(oldset->nodeTab[0], indx);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrEvalXPtrPart:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the preparsed Scheme for the XPtrPart
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XPtrPart ::= 'xpointer' '(' XPtrExpr ')'
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * | Scheme '(' SchemeSpecificExpr ')'
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Scheme ::= NCName - 'xpointer' [VC: Non-XPointer schemes]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * SchemeSpecificExpr ::= StringWithBalancedParens
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * StringWithBalancedParens ::=
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [^()]* ('(' StringWithBalancedParens ')' [^()]*)*
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [VC: Parenthesis escaping]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XPtrExpr ::= Expr [VC: Parenthesis escaping]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * VC: Parenthesis escaping:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The end of an XPointer part is signaled by the right parenthesis ")"
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * character that is balanced with the left parenthesis "(" character
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * that began the part. Any unbalanced parenthesis character inside the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * expression, even within literals, must be escaped with a circumflex (^)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * character preceding it. If the expression contains any literal
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * occurrences of the circumflex, each must be escaped with an additional
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * circumflex (that is, ^^). If the unescaped parentheses in the expression
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * are not balanced, a syntax error results.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Parse and evaluate an XPtrPart. Basically it generates the unescaped
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * string and if the scheme is 'xpointer' it will call the XPath interpreter.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * TODO: there is no new scheme registration mechanism
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync buffer = (xmlChar *) xmlMallocAtomic(len * sizeof (xmlChar));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync while (CUR != 0) {
c69b7f1a67029137a3e1f5f5e64f8249fc348c22vboxsync if ((NXT(1) == ')') || (NXT(1) == '(') || (NXT(1) == '^')) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * To evaluate an xpointer scheme element (4.3) we need:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * context initialized to the root
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * context position initalized to 1
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * context size initialized to 1
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->context->node = (xmlNodePtr)ctxt->context->doc;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if (xmlStrEqual(name, (xmlChar *) "element")) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if (xmlStrEqual(name, (xmlChar *) "xmlns")) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* @@ check escaping in the XPointer WD */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* XPTR_XMLNS_SCHEME */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrEvalFullXPtr:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the preparsed Scheme for the first XPtrPart
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * FullXPtr ::= XPtrPart (S? XPtrPart)*
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * As the specs says:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * -----------
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * When multiple XPtrParts are provided, they must be evaluated in
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * left-to-right order. If evaluation of one part fails, the nexti
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * is evaluated. The following conditions cause XPointer part failure:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - An unknown scheme
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - A scheme that does not locate any sub-resource present in the resource
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - A scheme that is not applicable to the media type of the resource
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The XPointer application must consume a failed XPointer part and
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * attempt to evaluate the next one, if any. The result of the first
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XPointer part whose evaluation succeeds is taken to be the fragment
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * located by the XPointer as a whole. If all the parts fail, the result
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * for the XPointer as a whole is a sub-resource error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * -----------
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Parse and evaluate a Full XPtr i.e. possibly a cascade of XPath based
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * expressions or other schemes.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* in case of syntax error, break here */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * If the returned value is a non-empty nodeset
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * or location set, return here.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Evaluating to improper values is equivalent to
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * a sub-resource error, clean-up the stack
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Is there another XPointer part.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrEvalChildSeq:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: a possible ID name of the child sequence
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * ChildSeq ::= '/1' ('/' [0-9]*)*
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * | Name ('/' [0-9]*)+
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Parse and evaluate a Child Sequence. This routine also handle the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * case of a Bare Name used to get a document ID.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XPointer don't allow by syntax to address in mutirooted trees
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * this might prove useful in some cases, warn about it.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((name == NULL) && (CUR == '/') && (NXT(1) != '1')) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrEvalXPointer:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XPointer ::= Name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * | ChildSeq
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * | FullXPtr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Parse and evaluate an XPointer
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Allocate the value stack */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Short evaluation */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* this handle both Bare Names and Child Sequences */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * General routines *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvoid xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvoid xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvoid xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvoid xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvoid xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvoid xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvoid xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNewContext:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the XML document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @here: the node that directly contains the XPointer being evaluated or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @origin: the element from which a user or program initiated traversal of
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the link, or NULL.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create a new XPointer context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the xmlXPathContext just allocated.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrNewContext(xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPathRegisterFunc(ret, (xmlChar *)"range-inside",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPathRegisterFunc(ret, (xmlChar *)"string-range",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPathRegisterFunc(ret, (xmlChar *)"start-point",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrEval:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str: the XPointer expression
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctx: the XPointer context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Evaluate the XPath Location Path in the given context.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the xmlXPathObjectPtr resulting from the evaluation or NULL.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the caller has to free the object.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlXPtrEval: evaluation failed to return a node set\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Evaluation may push a root nodeset which is unused
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlXPtrEval: object(s) left on the eval stack\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrBuildRangeNodeList:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @range: a range object
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a node list tree copy of the range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns an xmlNodePtr list or NULL.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the caller has to free the node tree.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* pointers to generated nodes */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlNodePtr list = NULL, last = NULL, parent = NULL, tmp;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* pointers to traversal nodes */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* single sub text node selection */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* prune and return full set */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Now gather the remaining nodes from cur to end
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync continue; /* while */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Now gather the remaining nodes from cur to end
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync continue; /* while */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Do not copy DTD informations */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync TODO /* handle crossing entities -> stack needed */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* don't consider it part of the tree content */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Humm, should not happen ! */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((list == NULL) || ((last == NULL) && (parent == NULL))) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Skip to next node in document order
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((list == NULL) || ((last == NULL) && (parent == NULL))) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrBuildNodeList:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @obj: the XPointer result from the evaluation.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a node list tree copy of the XPointer result.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will drop Attributes and Namespace declarations.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns an xmlNodePtr list or NULL.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the caller has to free the node tree.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync continue; /* for */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlAddNextSibling(last, xmlCopyNode(set->nodeTab[i], 1));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlLocationSetPtr set = (xmlLocationSetPtr) obj->user;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync list = last = xmlXPtrBuildNodeList(set->locTab[i]);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XPointer functions *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrNbLocChildren:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: an xmlNodePtr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Count the number of location children of @node or the length of the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * string value in case of text/PI/Comments nodes
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the number of location children
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrHereFunction:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nargs: the number of args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Function implementing here() operation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * as described in 5.4.3
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync valuePush(ctxt, xmlXPtrNewLocationSetNodes(ctxt->context->here, NULL));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrOriginFunction:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nargs: the number of args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Function implementing origin() operation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * as described in 5.4.3
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync valuePush(ctxt, xmlXPtrNewLocationSetNodes(ctxt->context->origin, NULL));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrStartPointFunction:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nargs: the number of args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Function implementing start-point() operation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * as described in 5.4.3
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * ----------------
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location-set start-point(location-set)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * For each location x in the argument location-set, start-point adds a
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location of type point to the result location-set. That point represents
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the start point of location x and is determined by the following rules:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type point, the start point is x.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type range, the start point is the start point of x.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type root, element, text, comment, or processing instruction,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - the container node of the start point is x and the index is 0.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type attribute or namespace, the function must signal a
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * syntax error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * ----------------
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * First convert to a location set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* TODO: Namespace Nodes ??? */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /*** Should we raise an error ?
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPathFreeObject(obj);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPathFreeObject(newset);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync XP_ERROR(XPATH_INVALID_TYPE)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrEndPointFunction:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nargs: the number of args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Function implementing end-point() operation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * as described in 5.4.3
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * ----------------------------
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location-set end-point(location-set)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * For each location x in the argument location-set, end-point adds a
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location of type point to the result location-set. That point represents
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the end point of location x and is determined by the following rules:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type point, the resulting point is x.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type range, the resulting point is the end point of x.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type root or element, the container node of the resulting
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * point is x and the index is the number of location children of x.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type text, comment, or processing instruction, the container
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * node of the resulting point is x and the index is the length of the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * string-value of x.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - If x is of type attribute or namespace, the function must signal a
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * syntax error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * ----------------------------
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * First convert to a location set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* TODO: Namespace Nodes ??? */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /*** Should we raise an error ?
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPathFreeObject(obj);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPathFreeObject(newset);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync XP_ERROR(XPATH_INVALID_TYPE)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrCoveringRange:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @loc: the location for which the covering range must be computed
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * A covering range is a range that wholly encompasses a location
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Section 5.3.3. Covering Ranges for All Location Types
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns a new location or NULL in case of error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* !!! our model is slightly different than XPath */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrRangeFunction:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nargs: the number of args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Function implementing the range() function 5.4.3
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location-set range(location-set )
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The range function returns ranges covering the locations in
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the argument location-set. For each location x in the argument
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location-set, a range location representing the covering range of
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * x is added to the result location-set.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * First convert to a location set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The loop is to compute the covering range for each item and add it
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Save the new value and cleanup
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrInsideRange:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @loc: the location for which the inside range must be computed
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * A inside range is a range described in the range-inside() description
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns a new location or NULL in case of error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrRangeInsideFunction:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nargs: the number of args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Function implementing the range-inside() function 5.4.3
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location-set range-inside(location-set )
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The range-inside function returns ranges covering the contents of
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the locations in the argument location-set. For each location x in
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the argument location-set, a range location is added to the result
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location-set. If x is a range location, then x is added to the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * result location-set. If x is not a range location, then x is used
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * as the container location of the start and end points of the range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location to be added; the index of the start point of the range is
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * zero; if the end point is a character point then its index is the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * length of the string-value of x, and otherwise is the number of
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * location children of x.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * First convert to a location set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The loop is to compute the covering range for each item and add it
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Save the new value and cleanup
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrRangeToFunction:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nargs: the number of args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Implement the range-to() XPointer function
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Save the expression pointer since we will have to evaluate
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * it multiple times. Initialize the new set.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Run the evaluation with a node list made of a single item
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * in the nodeset.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The result of the evaluation need to be tested to
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * decided whether the filter succeeded or not
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync range = xmlXPtrNewRangeNodeObject(oldset->nodeTab[i], res);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The result is used as the new evaluation set.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrAdvanceNode:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @level: incremented/decremented to show level in tree
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Advance to the next element or text node in document order
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * TODO: add a stack for entering/exiting entities
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 in case of failure, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncskip: /* This label should only be needed if something is wrong! */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->type == XML_ENTITY_REF_NODE) { /* Shouldn't happen */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrAdvanceChar:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: the node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @indx: the indx
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @bytes: the number of bytes
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Advance a point of the associated number of bytes (not UTF8 chars)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 in case of failure, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync while (bytes >= 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * First position to the beginning of the first text node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * corresponding to this point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * if there is no move needed return the current value.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * We should have a text (or cdata) node ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Strange, the indx in the text node is greater than it's len */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrMatchString:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @string: the string to search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the start textnode
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @startindex: the start index
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the end textnode IN/OUT
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @endindex: the end index IN/OUT
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check whether the document contains @string at the position
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * (@start, @startindex) and limited by the (@end, @endindex) point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 in case of failure, 0 if not found, 1 if found in which case
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * (@start, @startindex) will indicate the position of the beginning
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of the range and (@end, @endindex) will indicate the end
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of the range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync while (stringlen > 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((cur == *end) && (pos + stringlen > *endindex))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync match = (!xmlStrncmp(&cur->content[pos], string, stringlen));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "found range %d bytes at index %d of ->",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync match = (!xmlStrncmp(&cur->content[pos], string, sub));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "found subrange %d bytes at index %d of ->",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrSearchString:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @string: the string to search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @start: the start textnode IN/OUT
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @startindex: the start index IN/OUT
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @end: the end textnode
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @endindex: the end index
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the next occurrence of @string within the document content
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * until the (@end, @endindex) point is reached
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 in case of failure, 0 if not found, 1 if found in which case
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * (@start, @startindex) will indicate the position of the beginning
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of the range and (@end, @endindex) will indicate the end
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of the range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "found '%c' at index %d of ->",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * An empty string is considered to match before each
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * character of the string-value and after the final
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * character.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "found '' at index %d of ->",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrGetLastChar:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: the node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @index: the index
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Computes the point coordinates of the last char of this point
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 in case of failure, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrGetStartPoint:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @obj: an range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: the resulting node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @indx: the resulting index
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * read the object and return the start point coordinates.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 in case of failure, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrGetStartPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *indx) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((obj == NULL) || (node == NULL) || (indx == NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrGetEndPoint:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @obj: an range
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: the resulting node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @indx: the resulting indx
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * read the object and return the end point coordinates.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 in case of failure, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *indx) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((obj == NULL) || (node == NULL) || (indx == NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrStringRangeFunction:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nargs: the number of args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Function implementing the string-range() function
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * range as described in 5.4.2
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * ------------------------------
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [Definition: For each location in the location-set argument,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * string-range returns a set of string ranges, a set of substrings in a
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * string. Specifically, the string-value of the location is searched for
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * substrings that match the string argument, and the resulting location-set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * will contain a range location for each non-overlapping match.]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * An empty string is considered to match before each character of the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * string-value and after the final character. Whitespace in a string
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * is matched literally, with no normalization except that provided by
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XML for line ends. The third argument gives the position of the first
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * character to be in the resulting range, relative to the start of the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * match. The default value is 1, which makes the range start immediately
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * before the first character of the matched string. The fourth argument
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * gives the number of characters in the range; the default is that the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * range extends to the end of the matched string.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Element boundaries, as well as entire embedded nodes such as processing
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * instructions and comments, are ignored as defined in [XPath].
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * If the string in the second argument is not found in the string-value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of the location, or if a value in the third or fourth argument indicates
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * a string that is beyond the beginning or end of the document, the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * expression fails.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The points of the range-locations in the returned location-set will
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * all be character points.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * ------------------------------
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Grab the arguments
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * First convert to a location set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The loop is to search for each element in the location set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the list of location set corresponding to that search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPathDebugDumpObject(stdout, oldset->locTab[i], 0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPtrGetStartPoint(oldset->locTab[i], &start, &startindex);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPtrGetEndPoint(oldset->locTab[i], &end, &endindex);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync found = xmlXPtrSearchString(string->stringval, &start, &startindex,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlXPtrNewRange(start, startindex, fend, fendindex));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Save the new value and cleanup
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlXPtrEvalRangePredicate:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the XPointer Parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [8] Predicate ::= '[' PredicateExpr ']'
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [9] PredicateExpr ::= Expr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Evaluate a predicate as in xmlXPathEvalPredicate() but for
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * a Location Set instead of a node set
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Extract the old set, and then evaluate the result of the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * expression for all the element in the set. use it to grow
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * up a new set.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Save the expression pointer since we will have to evaluate
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * it multiple times. Initialize the new set.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Run the evaluation with a node list made of a single item
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * in the nodeset.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The result of the evaluation need to be tested to
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * decided whether the filter succeeded or not
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The result is used as the new evaluation set.