OLD | NEW |
1 /* | 1 /* |
2 * xpointer.c : Code to handle XML Pointer | 2 * xpointer.c : Code to handle XML Pointer |
3 * | 3 * |
4 * Base implementation was made accordingly to | 4 * Base implementation was made accordingly to |
5 * W3C Candidate Recommendation 7 June 2000 | 5 * W3C Candidate Recommendation 7 June 2000 |
6 * http://www.w3.org/TR/2000/CR-xptr-20000607 | 6 * http://www.w3.org/TR/2000/CR-xptr-20000607 |
7 * | 7 * |
8 * Added support for the element() scheme described in: | 8 * Added support for the element() scheme described in: |
9 * W3C Proposed Recommendation 13 November 2002 | 9 * W3C Proposed Recommendation 13 November 2002 |
10 * http://www.w3.org/TR/2002/PR-xptr-element-20021113/ | 10 * http://www.w3.org/TR/2002/PR-xptr-element-20021113/ |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 xmlXPtrNewContext(xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin) { | 1325 xmlXPtrNewContext(xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin) { |
1326 xmlXPathContextPtr ret; | 1326 xmlXPathContextPtr ret; |
1327 | 1327 |
1328 ret = xmlXPathNewContext(doc); | 1328 ret = xmlXPathNewContext(doc); |
1329 if (ret == NULL) | 1329 if (ret == NULL) |
1330 return(ret); | 1330 return(ret); |
1331 ret->xptr = 1; | 1331 ret->xptr = 1; |
1332 ret->here = here; | 1332 ret->here = here; |
1333 ret->origin = origin; | 1333 ret->origin = origin; |
1334 | 1334 |
1335 xmlXPathRegisterFunc(ret, (xmlChar *)"range-to", | |
1336 xmlXPtrRangeToFunction); | |
1337 xmlXPathRegisterFunc(ret, (xmlChar *)"range", | 1335 xmlXPathRegisterFunc(ret, (xmlChar *)"range", |
1338 xmlXPtrRangeFunction); | 1336 xmlXPtrRangeFunction); |
1339 xmlXPathRegisterFunc(ret, (xmlChar *)"range-inside", | 1337 xmlXPathRegisterFunc(ret, (xmlChar *)"range-inside", |
1340 xmlXPtrRangeInsideFunction); | 1338 xmlXPtrRangeInsideFunction); |
1341 xmlXPathRegisterFunc(ret, (xmlChar *)"string-range", | 1339 xmlXPathRegisterFunc(ret, (xmlChar *)"string-range", |
1342 xmlXPtrStringRangeFunction); | 1340 xmlXPtrStringRangeFunction); |
1343 xmlXPathRegisterFunc(ret, (xmlChar *)"start-point", | 1341 xmlXPathRegisterFunc(ret, (xmlChar *)"start-point", |
1344 xmlXPtrStartPointFunction); | 1342 xmlXPtrStartPointFunction); |
1345 xmlXPathRegisterFunc(ret, (xmlChar *)"end-point", | 1343 xmlXPathRegisterFunc(ret, (xmlChar *)"end-point", |
1346 xmlXPtrEndPointFunction); | 1344 xmlXPtrEndPointFunction); |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2236 valuePush(ctxt, xmlXPtrWrapLocationSet(newset)); | 2234 valuePush(ctxt, xmlXPtrWrapLocationSet(newset)); |
2237 xmlXPathFreeObject(set); | 2235 xmlXPathFreeObject(set); |
2238 } | 2236 } |
2239 | 2237 |
2240 /** | 2238 /** |
2241 * xmlXPtrRangeToFunction: | 2239 * xmlXPtrRangeToFunction: |
2242 * @ctxt: the XPointer Parser context | 2240 * @ctxt: the XPointer Parser context |
2243 * @nargs: the number of args | 2241 * @nargs: the number of args |
2244 * | 2242 * |
2245 * Implement the range-to() XPointer function | 2243 * Implement the range-to() XPointer function |
| 2244 * |
| 2245 * Obsolete. range-to is not a real function but a special type of location |
| 2246 * step which is handled in xpath.c. |
2246 */ | 2247 */ |
2247 void | 2248 void |
2248 xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) { | 2249 xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, |
2249 xmlXPathObjectPtr range; | 2250 int nargs ATTRIBUTE_UNUSED) { |
2250 const xmlChar *cur; | 2251 XP_ERROR(XPATH_EXPR_ERROR); |
2251 xmlXPathObjectPtr res, obj; | |
2252 xmlXPathObjectPtr tmp; | |
2253 xmlLocationSetPtr newset = NULL; | |
2254 xmlNodeSetPtr oldset; | |
2255 int i; | |
2256 | |
2257 if (ctxt == NULL) return; | |
2258 CHECK_ARITY(1); | |
2259 /* | |
2260 * Save the expression pointer since we will have to evaluate | |
2261 * it multiple times. Initialize the new set. | |
2262 */ | |
2263 CHECK_TYPE(XPATH_NODESET); | |
2264 obj = valuePop(ctxt); | |
2265 oldset = obj->nodesetval; | |
2266 ctxt->context->node = NULL; | |
2267 | |
2268 cur = ctxt->cur; | |
2269 newset = xmlXPtrLocationSetCreate(NULL); | |
2270 | |
2271 for (i = 0; i < oldset->nodeNr; i++) { | |
2272 » ctxt->cur = cur; | |
2273 | |
2274 » /* | |
2275 » * Run the evaluation with a node list made of a single item | |
2276 » * in the nodeset. | |
2277 » */ | |
2278 » ctxt->context->node = oldset->nodeTab[i]; | |
2279 » tmp = xmlXPathNewNodeSet(ctxt->context->node); | |
2280 » valuePush(ctxt, tmp); | |
2281 | |
2282 » xmlXPathEvalExpr(ctxt); | |
2283 » CHECK_ERROR; | |
2284 | |
2285 » /* | |
2286 » * The result of the evaluation need to be tested to | |
2287 » * decided whether the filter succeeded or not | |
2288 » */ | |
2289 » res = valuePop(ctxt); | |
2290 » range = xmlXPtrNewRangeNodeObject(oldset->nodeTab[i], res); | |
2291 » if (range != NULL) { | |
2292 » xmlXPtrLocationSetAdd(newset, range); | |
2293 » } | |
2294 | |
2295 » /* | |
2296 » * Cleanup | |
2297 » */ | |
2298 » if (res != NULL) | |
2299 » xmlXPathFreeObject(res); | |
2300 » if (ctxt->value == tmp) { | |
2301 » res = valuePop(ctxt); | |
2302 » xmlXPathFreeObject(res); | |
2303 » } | |
2304 | |
2305 » ctxt->context->node = NULL; | |
2306 } | |
2307 | |
2308 /* | |
2309 * The result is used as the new evaluation set. | |
2310 */ | |
2311 xmlXPathFreeObject(obj); | |
2312 ctxt->context->node = NULL; | |
2313 ctxt->context->contextSize = -1; | |
2314 ctxt->context->proximityPosition = -1; | |
2315 valuePush(ctxt, xmlXPtrWrapLocationSet(newset)); | |
2316 } | 2252 } |
2317 | 2253 |
2318 /** | 2254 /** |
2319 * xmlXPtrAdvanceNode: | 2255 * xmlXPtrAdvanceNode: |
2320 * @cur: the node | 2256 * @cur: the node |
2321 * @level: incremented/decremented to show level in tree | 2257 * @level: incremented/decremented to show level in tree |
2322 * | 2258 * |
2323 * Advance to the next element or text node in document order | 2259 * Advance to the next element or text node in document order |
2324 * TODO: add a stack for entering/exiting entities | 2260 * TODO: add a stack for entering/exiting entities |
2325 * | 2261 * |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3022 } | 2958 } |
3023 | 2959 |
3024 NEXT; | 2960 NEXT; |
3025 SKIP_BLANKS; | 2961 SKIP_BLANKS; |
3026 } | 2962 } |
3027 | 2963 |
3028 #define bottom_xpointer | 2964 #define bottom_xpointer |
3029 #include "elfgcchack.h" | 2965 #include "elfgcchack.h" |
3030 #endif | 2966 #endif |
3031 | 2967 |
OLD | NEW |