]> mj.ucw.cz Git - libucw.git/commitdiff
XML: Implemented xml_skip_element().
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Thu, 24 Apr 2008 07:17:15 +0000 (09:17 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Thu, 24 Apr 2008 07:17:15 +0000 (09:17 +0200)
sherlock/xml/parse.c
sherlock/xml/xml.h

index 67ef107659d357029517fb6456c05fc45451aeee..f771b304162bddc1d272115cd855eee60a675f12 100644 (file)
@@ -1137,6 +1137,28 @@ epilog:
   ASSERT(0);
 }
 
+uns
+xml_next_state(struct xml_context *ctx, uns pull)
+{
+  uns saved = ctx->pull;
+  ctx->pull = pull;
+  uns res = xml_next(ctx);
+  ctx->pull = saved;
+  return res;
+}
+
+uns
+xml_skip_element(struct xml_context *ctx)
+{
+  ASSERT(ctx->state == XML_STATE_STAG);
+  struct xml_node *node = ctx->node;
+  uns saved = ctx->pull, res;
+  ctx->pull = XML_PULL_ETAG;
+  while ((res = xml_next(ctx)) && ctx->node != node);
+  ctx->pull = saved;
+  return res;
+}
+
 uns
 xml_parse(struct xml_context *ctx)
 {
index 01b115da5c9ec70d41555093e5439171a5188787..08a4d6f681a00c3337fc73cbfff3abd64c0ca3e3 100644 (file)
@@ -232,6 +232,12 @@ uns xml_parse(struct xml_context *ctx);
 /* Parse with the PUSH interface, return XML_STATE_x (zero on EOF or fatal error) */
 uns xml_next(struct xml_context *ctx);
 
+/* Equivalent to xml_next, but with temporarily changed ctx->pull value */
+uns xml_next_state(struct xml_context *ctx, uns pull);
+
+/* May be called on XML_STATE_STAG to skip it's content; can return XML_STATE_ETAG or XML_STATE_EOF on fatal error */
+uns xml_skip_element(struct xml_context *ctx);
+
 /* Returns the current row number in the document entity */
 uns xml_row(struct xml_context *ctx);