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

Function xmlStreamPushInternal

ThirdParty/libxml2/vtklibxml2/pattern.c:1783–2105  ·  view source on GitHub ↗

* xmlStreamPushInternal: * @stream: the stream context * @name: the current name * @ns: the namespace name * @nodeType: the type of the node * * Push new data onto the stream. NOTE: if the call xmlPatterncompile() * indicated a dictionary, then strings for name and ns will be expected * to come from the dictionary. * Both @name and @ns being NULL means the / i.e. the root of the document.

Source from the content-addressed store, hash-verified

1781 * match and 0 otherwise.
1782 */
1783static int
1784xmlStreamPushInternal(xmlStreamCtxtPtr stream,
1785 const xmlChar *name, const xmlChar *ns,
1786 int nodeType) {
1787 int ret = 0, final = 0, tmp, i, m, match, stepNr, desc;
1788 xmlStreamCompPtr comp;
1789 xmlStreamStep step;
1790
1791 if ((stream == NULL) || (stream->nbState < 0))
1792 return(-1);
1793
1794 while (stream != NULL) {
1795 comp = stream->comp;
1796
1797 if ((nodeType == XML_ELEMENT_NODE) &&
1798 (name == NULL) && (ns == NULL)) {
1799 /* We have a document node here (or a reset). */
1800 stream->nbState = 0;
1801 stream->level = 0;
1802 stream->blockLevel = -1;
1803 if (comp->flags & XML_STREAM_FROM_ROOT) {
1804 if (comp->nbStep == 0) {
1805 /* TODO: We have a "/." here? */
1806 ret = 1;
1807 } else {
1808 if ((comp->nbStep == 1) &&
1809 (comp->steps[0].nodeType == XML_STREAM_ANY_NODE) &&
1810 (comp->steps[0].flags & XML_STREAM_STEP_DESC))
1811 {
1812 /*
1813 * In the case of "//." the document node will match
1814 * as well.
1815 */
1816 ret = 1;
1817 } else if (comp->steps[0].flags & XML_STREAM_STEP_ROOT) {
1818 if (xmlStreamCtxtAddState(stream, 0, 0) < 0)
1819 return(-1);
1820 }
1821 }
1822 }
1823 stream = stream->next;
1824 continue; /* while */
1825 }
1826
1827 /*
1828 * Fast check for ".".
1829 */
1830 if (comp->nbStep == 0) {
1831 /*
1832 * / and . are handled at the XPath node set creation
1833 * level by checking min depth
1834 */
1835 if (stream->flags & XML_PATTERN_XPATH) {
1836 stream = stream->next;
1837 continue; /* while */
1838 }
1839 /*
1840 * For non-pattern like evaluation like XML Schema IDCs

Callers 3

xmlStreamPushFunction · 0.85
xmlStreamPushNodeFunction · 0.85
xmlStreamPushAttrFunction · 0.85

Calls 2

xmlStreamCtxtAddStateFunction · 0.85
xmlStrEqualFunction · 0.85

Tested by

no test coverage detected