mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-24 21:33:51 +03:00
xmllint: Return error code if XPath returns empty nodeset
Return an error code as before but make it possible to distinguish from real errors. Fixes #690.
This commit is contained in:
parent
a9e73f11c0
commit
87bebd25f1
@ -575,7 +575,7 @@
|
||||
result. In case of a nodeset result, each node in the
|
||||
node set is serialized in full in the output. In case
|
||||
of an empty node set the "XPath set is empty" result
|
||||
will be shown unless the <option>--quiet</option> is set.
|
||||
will be shown and exit code 11 will be returned..
|
||||
This feature is EXPERIMENTAL. Implementation details can
|
||||
change without futher notice.
|
||||
</para>
|
||||
@ -947,6 +947,13 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><errorcode>11</errorcode></term>
|
||||
<listitem>
|
||||
<para>XPath result is empty</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
24
xmllint.c
24
xmllint.c
@ -90,17 +90,18 @@
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
XMLLINT_RETURN_OK = 0, /* No error */
|
||||
XMLLINT_ERR_UNCLASS = 1, /* Unclassified */
|
||||
XMLLINT_ERR_DTD = 2, /* Error in DTD */
|
||||
XMLLINT_ERR_VALID = 3, /* Validation error */
|
||||
XMLLINT_ERR_RDFILE = 4, /* CtxtReadFile error */
|
||||
XMLLINT_ERR_SCHEMACOMP = 5, /* Schema compilation */
|
||||
XMLLINT_ERR_OUT = 6, /* Error writing output */
|
||||
XMLLINT_ERR_SCHEMAPAT = 7, /* Error in schema pattern */
|
||||
XMLLINT_ERR_RDREGIS = 8, /* Error in Reader registration */
|
||||
XMLLINT_ERR_MEM = 9, /* Out of memory error */
|
||||
XMLLINT_ERR_XPATH = 10 /* XPath evaluation error */
|
||||
XMLLINT_RETURN_OK = 0, /* No error */
|
||||
XMLLINT_ERR_UNCLASS = 1, /* Unclassified */
|
||||
XMLLINT_ERR_DTD = 2, /* Error in DTD */
|
||||
XMLLINT_ERR_VALID = 3, /* Validation error */
|
||||
XMLLINT_ERR_RDFILE = 4, /* CtxtReadFile error */
|
||||
XMLLINT_ERR_SCHEMACOMP = 5, /* Schema compilation */
|
||||
XMLLINT_ERR_OUT = 6, /* Error writing output */
|
||||
XMLLINT_ERR_SCHEMAPAT = 7, /* Error in schema pattern */
|
||||
XMLLINT_ERR_RDREGIS = 8, /* Error in Reader registration */
|
||||
XMLLINT_ERR_MEM = 9, /* Out of memory error */
|
||||
XMLLINT_ERR_XPATH = 10, /* XPath evaluation error */
|
||||
XMLLINT_ERR_XPATH_EMPTY = 11 /* XPath result is empty */
|
||||
} xmllintReturnCode;
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
static int shell = 0;
|
||||
@ -2031,6 +2032,7 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
|
||||
int i;
|
||||
|
||||
if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) {
|
||||
progresult = XMLLINT_ERR_XPATH_EMPTY;
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "XPath set is empty\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user