MCPcopy Create free account
hub / github.com/acl-dev/acl / test1

Function test1

lib_acl/samples/xml/xml1/xml.c:451–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449}
450
451static void test1(void)
452{
453 const char* data = "<?xml version=\"1.0\" encoding=\"gb2312\"?>\r\n"
454 "<?xml-stylesheet type=\"text/xsl\"\r\n"
455 "\thref=\"http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl\"?>\r\n"
456 "\t<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"\r\n"
457 "\t\"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\" [\r\n"
458 " <!ENTITY xmllint \"<command>xmllint</command>\">\r\n"
459 "]>\r\n"
460 "<root name1 = \"\\\"value1\\\"\" name2 = \"val\\ue2\" name3 = \"v\\al'u\'e3\" />\r\n";
461 ACL_XML *xml = acl_xml_alloc();
462 ACL_ITER node_it, attr_it;
463 ACL_XML_NODE *node;
464 const char *encoding, *type, *href;
465
466 printf("data: %s\r\n", data);
467 acl_xml_update(xml, data);
468 acl_foreach(node_it, xml) {
469 ACL_XML_NODE *tmp = (ACL_XML_NODE*) node_it.data;
470 printf("tag: %s\r\n", STR(tmp->ltag));
471 acl_foreach(attr_it, tmp->attr_list) {
472 ACL_XML_ATTR *attr = (ACL_XML_ATTR*) attr_it.data;
473 printf("\tattr_name: %s, attr_value: %s\r\n",
474 STR(attr->name), STR(attr->value));
475 }
476 }
477
478 printf("------------------------------------------------------\r\n");
479
480 encoding = acl_xml_getEncoding(xml);
481 type = acl_xml_getType(xml);
482 node = acl_xml_getElementMeta(xml, "xml-stylesheet");
483 if (node)
484 href = acl_xml_getElementAttrVal(node, "href");
485 else
486 href = NULL;
487 printf("xml encoding: %s, type: %s, href: %s\r\n",
488 encoding ? encoding : "null", type ? type : "null",
489 href ? href : "null");
490 acl_xml_free(xml);
491}
492
493static void usage(const char *procname)
494{

Callers 1

mainFunction · 0.70

Calls 8

acl_xml_allocFunction · 0.85
acl_xml_updateFunction · 0.85
acl_xml_getEncodingFunction · 0.85
acl_xml_getTypeFunction · 0.85
acl_xml_getElementMetaFunction · 0.85
acl_xml_freeFunction · 0.85
acl_foreachFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…