1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

Fixed facet errors to be channelled back for union type members;

* xmlschemas.c: Fixed facet errors to be channelled back for
  union type members; facet-validation will stop now on the
  first error. Reported by GUY Fabrice to the mailing-list.
* xmlschemastypes.c: Changed to ignore lengh-related facet
  validation for QNames and NOTATIONs as proposed by the
  schema people.
* test/schemas/union2* result/schemas/union2*: Added
  regression tests for union types (by GUY Fabrice).
This commit is contained in:
Kasimier T. Buchcik 2005-05-25 17:29:36 +00:00
parent 7cd517c262
commit bd6c3f7df8
7 changed files with 72 additions and 17 deletions

View File

@ -1,3 +1,14 @@
Wed May 25 18:59:53 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c: Fixed facet errors to be channelled back for
union type members; facet-validation will stop now on the
first error. Reported by GUY Fabrice to the mailing-list.
* xmlschemastypes.c: Changed to ignore lengh-related facet
validation for QNames and NOTATIONs as proposed by the
schema people.
* test/schemas/union2* result/schemas/union2*: Added
regression tests for union types (by GUY Fabrice).
Fri May 20 20:48:08 CEST 2005 Daniel Veillard <daniel@veillard.com>
* xmlsave.c: applied patch from Mark Vakoc fixing saving of

View File

@ -0,0 +1 @@
./test/schemas/union2_1.xml fails to validate

View File

@ -0,0 +1 @@
./test/schemas/union2_1.xml:4: element ELEMENTS: Schemas validity error : Element 'ELEMENTS' [simple type]: The character content is not valid.

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<ELEMENTS xmlns="urn:test:foo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:test:foo union_1.xsd">
5
</ELEMENTS>

21
test/schemas/union2_1.xsd Normal file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:test:foo">
<xsd:element name="ELEMENTS">
<xsd:simpleType>
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:int">
<xsd:minInclusive value="10"/>
<xsd:maxInclusive value="20"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:int">
<xsd:minInclusive value="30"/>
<xsd:maxInclusive value="40"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
</xsd:element>
</xsd:schema>

View File

@ -18076,7 +18076,7 @@ xmlSchemaValidateFacetsInternal(xmlSchemaValidCtxtPtr ctxt,
unsigned long length,
int fireErrors)
{
int ret = 0;
int ret = 0, error = 0;
xmlNodePtr node;
xmlSchemaTypePtr biType; /* The build-in type. */
xmlSchemaTypePtr tmpType;
@ -18149,10 +18149,15 @@ xmlSchemaValidateFacetsInternal(xmlSchemaValidCtxtPtr ctxt,
"Internal error: xmlSchemaValidateFacetsInternal, "
"validating facet of type '%s'.\n",
type->name, NULL);
break;
} else if ((ret > 0) && (fireErrors)) {
xmlSchemaVFacetErr(ctxt, ret, node, value, len,
type, facet, NULL, NULL, NULL, NULL);
return (-1);
} else if (ret > 0) {
if (fireErrors) {
xmlSchemaVFacetErr(ctxt, ret, node, value, len,
type, facet, NULL, NULL, NULL, NULL);
} else
return (ret);
if (error == 0)
error = ret;
}
facetLink = facetLink->next;
@ -18160,7 +18165,7 @@ xmlSchemaValidateFacetsInternal(xmlSchemaValidCtxtPtr ctxt,
}
if (ret >= 0) {
if (error >= 0) {
xmlSchemaWhitespaceValueType fws;
int found = 0;
/*
@ -18191,8 +18196,7 @@ xmlSchemaValidateFacetsInternal(xmlSchemaValidCtxtPtr ctxt,
"Internal error: xmlSchemaValidateFacetsInternal, "
"validating enumeration facet '%s' of type '%s'.\n",
facet->value, tmpType->name);
ret = -1;
break;
return (-1);
}
}
if (retFacet <= 0)
@ -18205,11 +18209,14 @@ xmlSchemaValidateFacetsInternal(xmlSchemaValidCtxtPtr ctxt,
if (fireErrors) {
xmlSchemaVFacetErr(ctxt, ret, node, value, 0, type, NULL,
NULL, NULL, NULL, NULL);
}
} else
return (ret);
if (error == 0)
error = ret;
}
}
if (ret >= 0) {
if (error >= 0) {
/*
* Process patters. Pattern facets are ORed at type level
* and ANDed if derived. Walk the base type axis.
@ -18231,8 +18238,7 @@ xmlSchemaValidateFacetsInternal(xmlSchemaValidCtxtPtr ctxt,
"Internal error: xmlSchemaValidateFacetsInternal, "
"validating 'pattern' facet '%s' of type '%s'.\n",
facetLink->facet->value, tmpType->name);
ret = -1;
break;
return (-1);
} else
/* Save the last non-validating facet. */
facet = facetLink->facet;
@ -18246,11 +18252,14 @@ xmlSchemaValidateFacetsInternal(xmlSchemaValidCtxtPtr ctxt,
if (fireErrors) {
xmlSchemaVFacetErr(ctxt, ret, node, value, 0, type, facet,
NULL, NULL, NULL, NULL);
}
} else
return (ret);
if (error == 0)
error = ret;
}
}
return (ret);
return (error);
}
/************************************************************************

View File

@ -4671,14 +4671,20 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
case XML_SCHEMAS_NMTOKEN:
case XML_SCHEMAS_NAME:
case XML_SCHEMAS_NCNAME:
case XML_SCHEMAS_ID:
/*
* FIXME: What exactly to do with anyURI?
case XML_SCHEMAS_ID:
/*
* FIXME: What exactly to do with anyURI?
*/
case XML_SCHEMAS_ANYURI:
if (value != NULL)
len = xmlSchemaNormLen(value);
break;
case XML_SCHEMAS_QNAME:
case XML_SCHEMAS_NOTATION:
/*
* Ignore validation against QName and NOTATION.
*/
return (0);
default:
TODO
}