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

Function test1

lib_acl/samples/xml/xml3/xml.c:569–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569static void test1(void)
570{
571 const char* data = "<?xml version=\"1.0\" encoding=\"gb2312\"?>\r\n"
572 "<?xml-stylesheet type=\"text/xsl\"\r\n"
573 "\thref=\"http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl\"?>\r\n"
574 "<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"\r\n"
575 "\t\"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\" [\r\n"
576 " <!ENTITY xmllint \"<command>xmllint</command>\">\r\n"
577 "]>\r\n"
578 "<root name1 = \"value1\" name2 = \"val\\ue2\" name3 = \"v\\al'ue3\">hello world!</root>\r\n";
579 ACL_XML2 *xml;
580 ACL_XML2_NODE *node;
581 const char *encoding, *type, *href;
582 size_t size = strlen(data) * 3;
583 ACL_VSTRING *buf = acl_vstring_alloc(size);
584 const char *ptr;
585
586 xml = acl_xml2_alloc(buf);
587
588 printf("------------------------------------------------------\r\n");
589
590 printf("%s\r\n", data);
591
592 acl_xml2_update(xml, data);
593
594 printf("--------------- walk_xml_node ------------------------\r\n");
595
596 walk_xml_node(xml->root, 0);
597
598 printf("--------------- walk_xml_node end --------------------\r\n");
599
600 printf("Enter any key to continue ...\r\n");
601 getchar();
602
603 printf("----------------- lookup meta data -------------------\r\n");
604 encoding = acl_xml2_getEncoding(xml);
605 type = acl_xml2_getType(xml);
606 node = acl_xml2_getElementMeta(xml, "xml-stylesheet");
607 if (node)
608 href = acl_xml2_getElementAttrVal(node, "href");
609 else
610 href = NULL;
611
612 printf("xml encoding: %s\r\n", encoding ? encoding : "null");
613 printf("xml type: %s\r\n", type ? type : "null");
614 printf("xml href: %s\r\n", href ? href : "null");
615
616 printf("----------------- lookup meta data end ---------------\r\n");
617
618 printf("Enter any key to continue ...\r\n");
619 getchar();
620 test_getElementsByTagName(xml, "root");
621
622 printf("----------------- build xml -------------------------\r\n");
623 ptr = acl_xml2_build(xml);
624 printf("%s\r\n", ptr);
625 printf("----------------- build xml end ---------------------\r\n");
626 acl_vstring_free(buf);

Callers 1

mainFunction · 0.70

Calls 12

acl_vstring_allocFunction · 0.85
acl_xml2_allocFunction · 0.85
acl_xml2_updateFunction · 0.85
acl_xml2_getEncodingFunction · 0.85
acl_xml2_getTypeFunction · 0.85
acl_xml2_getElementMetaFunction · 0.85
acl_xml2_buildFunction · 0.85
acl_vstring_freeFunction · 0.85
acl_xml2_freeFunction · 0.85
walk_xml_nodeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…