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

Function xmlSchemaSAXPlug

ThirdParty/libxml2/vtklibxml2/xmlschemas.c:28461–28592  ·  view source on GitHub ↗

* xmlSchemaSAXPlug: * @ctxt: a schema validation context * @sax: a pointer to the original xmlSAXHandlerPtr * @user_data: a pointer to the original SAX user data pointer * * Plug a SAX based validation layer in a SAX parsing event flow. * The original @saxptr and @dataptr data are replaced by new pointers * but the calls to the original will be maintained. * * Returns a pointer to a da

Source from the content-addressed store, hash-verified

28459 * or NULL in case of errors.
28460 */
28461xmlSchemaSAXPlugPtr
28462xmlSchemaSAXPlug(xmlSchemaValidCtxtPtr ctxt,
28463 xmlSAXHandlerPtr *sax, void **user_data)
28464{
28465 xmlSchemaSAXPlugPtr ret;
28466 xmlSAXHandlerPtr old_sax;
28467
28468 if ((ctxt == NULL) || (sax == NULL) || (user_data == NULL))
28469 return(NULL);
28470
28471 /*
28472 * We only allow to plug into SAX2 event streams
28473 */
28474 old_sax = *sax;
28475 if ((old_sax != NULL) && (old_sax->initialized != XML_SAX2_MAGIC))
28476 return(NULL);
28477 if ((old_sax != NULL) &&
28478 (old_sax->startElementNs == NULL) && (old_sax->endElementNs == NULL) &&
28479 ((old_sax->startElement != NULL) || (old_sax->endElement != NULL)))
28480 return(NULL);
28481
28482 /*
28483 * everything seems right allocate the local data needed for that layer
28484 */
28485 ret = (xmlSchemaSAXPlugPtr) xmlMalloc(sizeof(xmlSchemaSAXPlugStruct));
28486 if (ret == NULL) {
28487 return(NULL);
28488 }
28489 memset(ret, 0, sizeof(xmlSchemaSAXPlugStruct));
28490 ret->magic = XML_SAX_PLUG_MAGIC;
28491 ret->schemas_sax.initialized = XML_SAX2_MAGIC;
28492 ret->ctxt = ctxt;
28493 ret->user_sax_ptr = sax;
28494 ret->user_sax = old_sax;
28495 if (old_sax == NULL) {
28496 /*
28497 * go direct, no need for the split block and functions.
28498 */
28499 ret->schemas_sax.startElementNs = xmlSchemaSAXHandleStartElementNs;
28500 ret->schemas_sax.endElementNs = xmlSchemaSAXHandleEndElementNs;
28501 /*
28502 * Note that we use the same text-function for both, to prevent
28503 * the parser from testing for ignorable whitespace.
28504 */
28505 ret->schemas_sax.ignorableWhitespace = xmlSchemaSAXHandleText;
28506 ret->schemas_sax.characters = xmlSchemaSAXHandleText;
28507
28508 ret->schemas_sax.cdataBlock = xmlSchemaSAXHandleCDataSection;
28509 ret->schemas_sax.reference = xmlSchemaSAXHandleReference;
28510
28511 ret->user_data = ctxt;
28512 *user_data = ctxt;
28513 } else {
28514 /*
28515 * for each callback unused by Schemas initialize it to the Split
28516 * routine only if non NULL in the user block, this can speed up
28517 * things at the SAX level.
28518 */

Calls 1

xmlSchemaPreRunFunction · 0.85

Tested by

no test coverage detected