Commit bd6c3f7d authored by Kasimier T. Buchcik's avatar Kasimier T. Buchcik

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).
parent 7cd517c2
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
......
./test/schemas/union2_1.xml fails to validate
./test/schemas/union2_1.xml:4: element ELEMENTS: Schemas validity error : Element 'ELEMENTS' [simple type]: The character content is not valid.
<?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>
\ No newline at end of file
<?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>
\ No newline at end of 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);
}
/************************************************************************
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment