* xmlSnprintfElementContent: * @buf: an output buffer * @size: the buffer size * @content: An element table * @englob: 1 if one must print the englobing parenthesis, 0 otherwise * * This will dump the content of the element content definition * Intended just for the debug routine */
| 1009 | * Intended just for the debug routine |
| 1010 | */ |
| 1011 | void |
| 1012 | xmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob) { |
| 1013 | int len; |
| 1014 | |
| 1015 | if (content == NULL) return; |
| 1016 | len = strlen(buf); |
| 1017 | if (size - len < 50) { |
| 1018 | if ((size - len > 4) && (buf[len - 1] != '.')) |
| 1019 | strcat(buf, " ..."); |
| 1020 | return; |
| 1021 | } |
| 1022 | if (englob) strcat(buf, "("); |
| 1023 | switch (content->type) { |
| 1024 | case XML_ELEMENT_CONTENT_PCDATA: |
| 1025 | strcat(buf, "#PCDATA"); |
| 1026 | break; |
| 1027 | case XML_ELEMENT_CONTENT_ELEMENT: { |
| 1028 | int qnameLen = xmlStrlen(content->name); |
| 1029 | |
| 1030 | if (content->prefix != NULL) |
| 1031 | qnameLen += xmlStrlen(content->prefix) + 1; |
| 1032 | if (size - len < qnameLen + 10) { |
| 1033 | strcat(buf, " ..."); |
| 1034 | return; |
| 1035 | } |
| 1036 | if (content->prefix != NULL) { |
| 1037 | strcat(buf, (char *) content->prefix); |
| 1038 | strcat(buf, ":"); |
| 1039 | } |
| 1040 | if (content->name != NULL) |
| 1041 | strcat(buf, (char *) content->name); |
| 1042 | break; |
| 1043 | } |
| 1044 | case XML_ELEMENT_CONTENT_SEQ: |
| 1045 | if ((content->c1->type == XML_ELEMENT_CONTENT_OR) || |
| 1046 | (content->c1->type == XML_ELEMENT_CONTENT_SEQ)) |
| 1047 | xmlSnprintfElementContent(buf, size, content->c1, 1); |
| 1048 | else |
| 1049 | xmlSnprintfElementContent(buf, size, content->c1, 0); |
| 1050 | len = strlen(buf); |
| 1051 | if (size - len < 50) { |
| 1052 | if ((size - len > 4) && (buf[len - 1] != '.')) |
| 1053 | strcat(buf, " ..."); |
| 1054 | return; |
| 1055 | } |
| 1056 | strcat(buf, " , "); |
| 1057 | if (((content->c2->type == XML_ELEMENT_CONTENT_OR) || |
| 1058 | (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) && |
| 1059 | (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT)) |
| 1060 | xmlSnprintfElementContent(buf, size, content->c2, 1); |
| 1061 | else |
| 1062 | xmlSnprintfElementContent(buf, size, content->c2, 0); |
| 1063 | break; |
| 1064 | case XML_ELEMENT_CONTENT_OR: |
| 1065 | if ((content->c1->type == XML_ELEMENT_CONTENT_OR) || |
| 1066 | (content->c1->type == XML_ELEMENT_CONTENT_SEQ)) |
| 1067 | xmlSnprintfElementContent(buf, size, content->c1, 1); |
| 1068 | else |
no test coverage detected