* xmlSnprintfElements: * @buf: an output buffer * @size: the size of the buffer * @content: An element * @glob: 1 if one must print the englobing parenthesis, 0 otherwise * * This will dump the list of elements to the buffer * Intended just for the debug routine */
| 4990 | * Intended just for the debug routine |
| 4991 | */ |
| 4992 | static void |
| 4993 | xmlSnprintfElements(char *buf, int size, xmlNodePtr node, int glob) { |
| 4994 | xmlNodePtr cur; |
| 4995 | int len; |
| 4996 | |
| 4997 | if (node == NULL) return; |
| 4998 | if (glob) strcat(buf, "("); |
| 4999 | cur = node; |
| 5000 | while (cur != NULL) { |
| 5001 | len = strlen(buf); |
| 5002 | if (size - len < 50) { |
| 5003 | if ((size - len > 4) && (buf[len - 1] != '.')) |
| 5004 | strcat(buf, " ..."); |
| 5005 | return; |
| 5006 | } |
| 5007 | switch (cur->type) { |
| 5008 | case XML_ELEMENT_NODE: |
| 5009 | if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { |
| 5010 | if (size - len < xmlStrlen(cur->ns->prefix) + 10) { |
| 5011 | if ((size - len > 4) && (buf[len - 1] != '.')) |
| 5012 | strcat(buf, " ..."); |
| 5013 | return; |
| 5014 | } |
| 5015 | strcat(buf, (char *) cur->ns->prefix); |
| 5016 | strcat(buf, ":"); |
| 5017 | } |
| 5018 | if (size - len < xmlStrlen(cur->name) + 10) { |
| 5019 | if ((size - len > 4) && (buf[len - 1] != '.')) |
| 5020 | strcat(buf, " ..."); |
| 5021 | return; |
| 5022 | } |
| 5023 | if (cur->name != NULL) |
| 5024 | strcat(buf, (char *) cur->name); |
| 5025 | if (cur->next != NULL) |
| 5026 | strcat(buf, " "); |
| 5027 | break; |
| 5028 | case XML_TEXT_NODE: |
| 5029 | if (xmlIsBlankNode(cur)) |
| 5030 | break; |
| 5031 | /* Falls through. */ |
| 5032 | case XML_CDATA_SECTION_NODE: |
| 5033 | case XML_ENTITY_REF_NODE: |
| 5034 | strcat(buf, "CDATA"); |
| 5035 | if (cur->next != NULL) |
| 5036 | strcat(buf, " "); |
| 5037 | break; |
| 5038 | case XML_ATTRIBUTE_NODE: |
| 5039 | case XML_DOCUMENT_NODE: |
| 5040 | case XML_HTML_DOCUMENT_NODE: |
| 5041 | case XML_DOCUMENT_TYPE_NODE: |
| 5042 | case XML_DOCUMENT_FRAG_NODE: |
| 5043 | case XML_NOTATION_NODE: |
| 5044 | case XML_NAMESPACE_DECL: |
| 5045 | strcat(buf, "???"); |
| 5046 | if (cur->next != NULL) |
| 5047 | strcat(buf, " "); |
| 5048 | break; |
| 5049 | case XML_ENTITY_NODE: |
no test coverage detected