MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlSchemaVPushText

Function xmlSchemaVPushText

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:26584–26710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26582#define XML_SCHEMA_PUSH_TEXT_VOLATILE 3
26583
26584static int
26585xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
26586 int nodeType, const xmlChar *value, int len,
26587 int mode, int *consumed)
26588{
26589 /*
26590 * Unfortunately we have to duplicate the text sometimes.
26591 * OPTIMIZE: Maybe we could skip it, if:
26592 * 1. content type is simple
26593 * 2. whitespace is "collapse"
26594 * 3. it consists of whitespace only
26595 *
26596 * Process character content.
26597 */
26598 if (consumed != NULL)
26599 *consumed = 0;
26600 if (INODE_NILLED(vctxt->inode)) {
26601 /*
26602 * SPEC cvc-elt (3.3.4 - 3.2.1)
26603 * "The element information item must have no character or
26604 * element information item [children]."
26605 */
26606 VERROR(XML_SCHEMAV_CVC_ELT_3_2_1, NULL,
26607 "Neither character nor element content is allowed "
26608 "because the element is 'nilled'");
26609 return (vctxt->err);
26610 }
26611 /*
26612 * SPEC (2.1) "If the {content type} is empty, then the
26613 * element information item has no character or element
26614 * information item [children]."
26615 */
26616 if (vctxt->inode->typeDef->contentType ==
26617 XML_SCHEMA_CONTENT_EMPTY) {
26618 VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, NULL,
26619 "Character content is not allowed, "
26620 "because the content type is empty");
26621 return (vctxt->err);
26622 }
26623
26624 if (vctxt->inode->typeDef->contentType ==
26625 XML_SCHEMA_CONTENT_ELEMENTS) {
26626 if ((nodeType != XML_TEXT_NODE) ||
26627 (! xmlSchemaIsBlank((xmlChar *) value, len))) {
26628 /*
26629 * SPEC cvc-complex-type (2.3)
26630 * "If the {content type} is element-only, then the
26631 * element information item has no character information
26632 * item [children] other than those whose [character
26633 * code] is defined as a white space in [XML 1.0 (Second
26634 * Edition)]."
26635 */
26636 VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, NULL,
26637 "Character content other than whitespace is not allowed "
26638 "because the content type is 'element-only'");
26639 return (vctxt->err);
26640 }
26641 return (0);

Callers 4

xmlSchemaVReaderWalkFunction · 0.85
xmlSchemaSAXHandleTextFunction · 0.85
xmlSchemaVDocWalkFunction · 0.85

Calls 6

xmlSchemaIsBlankFunction · 0.85
xmlStrndupFunction · 0.85
xmlStrdupFunction · 0.85
xmlStrlenFunction · 0.85
xmlStrncatFunction · 0.85
xmlStrncatNewFunction · 0.85

Tested by

no test coverage detected