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

Function xmlParserNsPush

ThirdParty/libxml2/vtklibxml2/parser.c:1715–1861  ·  view source on GitHub ↗

* xmlParserNsPush: * @ctxt: parser context * @prefix: prefix with hash value * @uri: uri with hash value * @saxData: extra data for SAX handler * @defAttr: whether the namespace comes from a default attribute * * Push a new namespace on the table. * * Returns 1 if the namespace was pushed, 0 if the namespace was ignored, * -1 if a memory allocation failed. */

Source from the content-addressed store, hash-verified

1713 * -1 if a memory allocation failed.
1714 */
1715static int
1716xmlParserNsPush(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
1717 const xmlHashedString *uri, void *saxData, int defAttr) {
1718 xmlParserNsBucket *bucket = NULL;
1719 xmlParserNsExtra *extra;
1720 const xmlChar **ns;
1721 unsigned hashValue, nsIndex, oldIndex;
1722
1723 if ((prefix != NULL) && (prefix->name == ctxt->str_xml))
1724 return(0);
1725
1726 if ((ctxt->nsNr >= ctxt->nsMax) && (xmlParserNsGrow(ctxt) < 0)) {
1727 xmlErrMemory(ctxt);
1728 return(-1);
1729 }
1730
1731 /*
1732 * Default namespace and 'xml' namespace
1733 */
1734 if ((prefix == NULL) || (prefix->name == NULL)) {
1735 oldIndex = ctxt->nsdb->defaultNsIndex;
1736
1737 if (oldIndex != INT_MAX) {
1738 extra = &ctxt->nsdb->extra[oldIndex];
1739
1740 if (extra->elementId == ctxt->nsdb->elementId) {
1741 if (defAttr == 0)
1742 xmlErrAttributeDup(ctxt, NULL, BAD_CAST "xmlns");
1743 return(0);
1744 }
1745
1746 if ((ctxt->options & XML_PARSE_NSCLEAN) &&
1747 (uri->name == ctxt->nsTab[oldIndex * 2 + 1]))
1748 return(0);
1749 }
1750
1751 ctxt->nsdb->defaultNsIndex = ctxt->nsNr;
1752 goto populate_entry;
1753 }
1754
1755 /*
1756 * Hash table lookup
1757 */
1758 oldIndex = xmlParserNsLookup(ctxt, prefix, &bucket);
1759 if (oldIndex != INT_MAX) {
1760 extra = &ctxt->nsdb->extra[oldIndex];
1761
1762 /*
1763 * Check for duplicate definitions on the same element.
1764 */
1765 if (extra->elementId == ctxt->nsdb->elementId) {
1766 if (defAttr == 0)
1767 xmlErrAttributeDup(ctxt, BAD_CAST "xmlns", prefix->name);
1768 return(0);
1769 }
1770
1771 if ((ctxt->options & XML_PARSE_NSCLEAN) &&
1772 (uri->name == ctxt->nsTab[bucket->index * 2 + 1]))

Callers 2

xmlParseStartTag2Function · 0.85
xmlParseInNodeContextFunction · 0.85

Calls 4

xmlParserNsGrowFunction · 0.85
xmlErrMemoryFunction · 0.85
xmlErrAttributeDupFunction · 0.85
xmlParserNsLookupFunction · 0.85

Tested by

no test coverage detected