* xmlXPtrAdvanceNode: * @cur: the node * @level: incremented/decremented to show level in tree * * Advance to the next element or text node in document order * TODO: add a stack for entering/exiting entities * * Returns -1 in case of failure, 0 otherwise */
| 2249 | * Returns -1 in case of failure, 0 otherwise |
| 2250 | */ |
| 2251 | xmlNodePtr |
| 2252 | xmlXPtrAdvanceNode(xmlNodePtr cur, int *level) { |
| 2253 | next: |
| 2254 | if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) |
| 2255 | return(NULL); |
| 2256 | if (cur->children != NULL) { |
| 2257 | cur = cur->children ; |
| 2258 | if (level != NULL) |
| 2259 | (*level)++; |
| 2260 | goto found; |
| 2261 | } |
| 2262 | skip: /* This label should only be needed if something is wrong! */ |
| 2263 | if (cur->next != NULL) { |
| 2264 | cur = cur->next; |
| 2265 | goto found; |
| 2266 | } |
| 2267 | do { |
| 2268 | cur = cur->parent; |
| 2269 | if (level != NULL) |
| 2270 | (*level)--; |
| 2271 | if (cur == NULL) return(NULL); |
| 2272 | if (cur->next != NULL) { |
| 2273 | cur = cur->next; |
| 2274 | goto found; |
| 2275 | } |
| 2276 | } while (cur != NULL); |
| 2277 | |
| 2278 | found: |
| 2279 | if ((cur->type != XML_ELEMENT_NODE) && |
| 2280 | (cur->type != XML_TEXT_NODE) && |
| 2281 | (cur->type != XML_DOCUMENT_NODE) && |
| 2282 | (cur->type != XML_HTML_DOCUMENT_NODE) && |
| 2283 | (cur->type != XML_CDATA_SECTION_NODE)) { |
| 2284 | if (cur->type == XML_ENTITY_REF_NODE) { /* Shouldn't happen */ |
| 2285 | goto skip; |
| 2286 | } |
| 2287 | goto next; |
| 2288 | } |
| 2289 | return(cur); |
| 2290 | } |
| 2291 | |
| 2292 | /** |
| 2293 | * xmlXPtrAdvanceChar: |
no outgoing calls
no test coverage detected