+static void
+print_labels (xmlNode *node)
+{
+ for (; node; node = node->next)
+ {
+ if (node->type == XML_ELEMENT_NODE
+ && !strcmp((char *) node->name, "label")
+ && node->parent->type == XML_ELEMENT_NODE
+ && !strcmp((char *) node->parent->name, "container"))
+ {
+ for (xmlNode *child = node->children; child; child = child->next)
+ if (child->type == XML_TEXT_NODE)
+ puts ((char *) child->content);
+ }
+
+ print_labels (node->children);
+ }
+}
+
+static void
+print_attributes (xmlNode * a_node)
+{
+ for (xmlNode *node = a_node; node; node = node->next)
+ {
+ if (node->type == XML_ELEMENT_NODE)
+ {
+ printf ("%s", node->name);
+ for (xmlAttr *attr = node->properties; attr; attr = attr->next)
+ {
+ printf (" %s", attr->name);
+ if (!strcmp ((char *) attr->name, "baseFormat"))
+ printf ("=%s", (char *) xmlGetProp (node, attr->name));
+ }
+ putchar ('\n');
+ }
+
+ print_attributes (node->children);
+ }
+}
+
+static void
+print_string(xmlChar *s)
+{
+ for (char *p = (char *) s; *p; p++)
+ if (*p == '\n')
+ printf ("\\n");
+ else
+ putchar (*p);
+}
+
+static void
+print_cdata (xmlNode * a_node)
+{
+ for (xmlNode *node = a_node; node; node = node->next)
+ {
+ if (node->type == XML_CDATA_SECTION_NODE)
+ {
+ print_string (node->content);
+ putchar ('\n');
+ }
+
+ print_cdata (node->children);
+ }
+}
+
+static void
+print_attribute (xmlNode *node, const char *attr)
+{
+ for (; node; node = node->next)
+ {
+ const char *s = (char *) xmlGetProp (node, (xmlChar *) attr);
+ if (s)
+ printf ("%s %s=%s\n", node->name, attr, s);
+
+ print_attribute (node->children, attr);
+ }
+}
+
+static void
+print_xml (xmlDoc *doc, xmlNode *node)
+{
+ xmlBuffer *buf = xmlBufferCreate();
+ xmlNodeDump (buf, doc, node, 0, 0);
+ xmlBufferDump (stdout, buf);
+ xmlBufferFree (buf);
+ putchar ('\n');
+}
+
+static void
+print_element (xmlDoc *doc, xmlNode *node, const char *element)
+{
+ for (; node; node = node->next)
+ {
+ if (node->name && !strcmp(element, (char *) node->name))
+ print_xml (doc, node);
+
+ print_element (doc, node->children, element);
+ }
+}
+
+static void
+print_id (xmlDoc *doc, xmlNode *node, const char *id)
+{
+ for (; node; node = node->next)
+ {
+ if (node->type == XML_ELEMENT_NODE)
+ {
+ const char *node_id = (char *) xmlGetProp (node, (xmlChar *) "id");
+ if (node_id && !strcmp (node_id, id))
+ {
+ print_xml (doc, node);
+ break;
+ }
+ }
+
+ print_id (doc, node->children, id);
+ }
+}
+
+static __attribute__((unused)) xmlNode *
+find_page_setup (xmlNode *node)
+{
+ for (; node; node = node->next)
+ {
+ if (node->name && !strcmp ((char *) node->name, "pageSetup"))
+ return node;
+
+ xmlNode *ps = find_page_setup (node->children);
+ if (ps)
+ return ps;
+ }
+ return NULL;
+}
+
+static void
+print_text (xmlNode *node)
+{
+ for (; node; node = node->next)
+ {
+ if (node->type == XML_ELEMENT_NODE)
+ {
+ printf ("%s", node->name);
+ for (xmlNode *child = node->children; child; child = child->next)
+ if (child->type == XML_TEXT_NODE)
+ {
+ putchar (' ');
+ print_string (child->content);
+ }
+ putchar ('\n');
+ }
+
+ print_text (node->children);
+ }
+}
+
+static void
+check_version (xmlNode *root, const char *version)