mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2025-03-03 16:55:55 +00:00
new patch from Kasimier Buchcik for processContents of wildcards attribute
* xmlschemas.c: new patch from Kasimier Buchcik for processContents of wildcards attribute handling * test/schemas/anyAttr-* result/schemas/anyAttr-*: added specific regression tests Daniel
This commit is contained in:
parent
37fd307435
commit
8acdfbf53c
@ -1,3 +1,10 @@
|
||||
Thu Jun 3 17:58:25 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* xmlschemas.c: new patch from Kasimier Buchcik for processContents
|
||||
of wildcards attribute handling
|
||||
* test/schemas/anyAttr-* result/schemas/anyAttr-*: added specific
|
||||
regression tests
|
||||
|
||||
Thu Jun 3 13:20:36 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* parser.c: fixed a bug where invalid charrefs may not be detected
|
||||
|
1
result/schemas/anyAttr-processContents-err1_0_0
Normal file
1
result/schemas/anyAttr-processContents-err1_0_0
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/anyAttr-processContents-err1_0.xml fails to validate
|
3
result/schemas/anyAttr-processContents-err1_0_0.err
Normal file
3
result/schemas/anyAttr-processContents-err1_0_0.err
Normal file
@ -0,0 +1,3 @@
|
||||
./test/schemas/anyAttr-processContents-err1_0.xml:11: element elem.lax: Schemas validity error : Failed to validate basic type language
|
||||
./test/schemas/anyAttr-processContents-err1_0.xml:11: element elem.lax: Schemas validity error : Attribute bar on elem.lax does not match type
|
||||
./test/schemas/anyAttr-processContents-err1_0.xml:12: element elem.strict: Schemas validity error : Attribute barB on elem.strict is unknown
|
1
result/schemas/anyAttr-processContents1_0_0
Normal file
1
result/schemas/anyAttr-processContents1_0_0
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/anyAttr-processContents1_0.xml validates
|
0
result/schemas/anyAttr-processContents1_0_0.err
Normal file
0
result/schemas/anyAttr-processContents1_0_0.err
Normal file
11
test/schemas/anyAttr-processContents-err1_0.xml
Normal file
11
test/schemas/anyAttr-processContents-err1_0.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<foo
|
||||
xmlns="http://FOO"
|
||||
xmlns:foo="http://FOO"
|
||||
xmlns:bar="http://BAR"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://FOO anyAttr-processContents1_0.xsd">
|
||||
<elem.lax foo:bar="o o"/>
|
||||
<elem.strict foo:barB="GB"/>
|
||||
</foo>
|
||||
|
26
test/schemas/anyAttr-processContents-err1_0.xsd
Normal file
26
test/schemas/anyAttr-processContents-err1_0.xsd
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xsd:schema xmlns:foo="http://FOO"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
elementFormDefault="qualified"
|
||||
targetNamespace="http://FOO">
|
||||
|
||||
<xsd:element name="foo">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="elem.lax" type="foo:type.lax"/>
|
||||
<xsd:element name="elem.strict" type="foo:type.strict"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:attribute name="bar" type="xsd:language" />
|
||||
|
||||
<xsd:complexType name="type.lax">
|
||||
<xsd:anyAttribute namespace="##any" processContents="lax"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="type.strict">
|
||||
<xsd:anyAttribute namespace="##any" processContents="strict"/>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
|
13
test/schemas/anyAttr-processContents1_0.xml
Normal file
13
test/schemas/anyAttr-processContents1_0.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<foo
|
||||
xmlns="http://FOO"
|
||||
xmlns:foo="http://FOO"
|
||||
xmlns:bar="http://BAR"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://FOO anyAttr-processContents1_0.xsd">
|
||||
<elem.lax.A foo:barA_1="PL"/>
|
||||
<elem.lax.B foo:barA_2="o"/>
|
||||
<elem.strict foo:barB="FR"/>
|
||||
<elem.skip foo:barC="o"/>
|
||||
</foo>
|
||||
|
32
test/schemas/anyAttr-processContents1_0.xsd
Normal file
32
test/schemas/anyAttr-processContents1_0.xsd
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xsd:schema xmlns:foo="http://FOO"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
elementFormDefault="qualified"
|
||||
targetNamespace="http://FOO">
|
||||
|
||||
<xsd:element name="foo">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="elem.lax.A" type="foo:type.lax"/>
|
||||
<xsd:element name="elem.lax.B" type="foo:type.lax"/>
|
||||
<xsd:element name="elem.strict" type="foo:type.strict"/>
|
||||
<xsd:element name="elem.skip" type="foo:type.skip"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:attribute name="barA" type="xsd:language" />
|
||||
<xsd:attribute name="barB" type="xsd:language" />
|
||||
|
||||
<xsd:complexType name="type.lax">
|
||||
<xsd:anyAttribute namespace="##any" processContents="lax"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="type.strict">
|
||||
<xsd:anyAttribute namespace="##any"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="type.skip">
|
||||
<xsd:anyAttribute namespace="##any" processContents="skip"/>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
|
65
xmlschemas.c
65
xmlschemas.c
@ -8344,6 +8344,7 @@ xmlSchemaValidateAttributes(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr elem, xmlSche
|
||||
int ret;
|
||||
xmlAttrPtr attr; /* An attribute on the element. */
|
||||
xmlChar *value;
|
||||
const xmlChar *nsURI;
|
||||
xmlSchemaAttributeLinkPtr attrUse;
|
||||
xmlSchemaAttributePtr attrDecl;
|
||||
int found;
|
||||
@ -8430,7 +8431,7 @@ xmlSchemaValidateAttributes(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr elem, xmlSche
|
||||
printf("found\n");
|
||||
#endif
|
||||
found = 1;
|
||||
ctxt->cur = (xmlNodePtr) attr;
|
||||
ctxt->cur = (xmlNodePtr) attr;
|
||||
|
||||
if (attrDecl->subtypes == NULL) {
|
||||
curState->state = XML_SCHEMAS_ATTR_TYPE_NOT_RESOLVED;
|
||||
@ -8505,6 +8506,14 @@ xmlSchemaValidateAttributes(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr elem, xmlSche
|
||||
#ifdef DEBUG_ATTR_VALIDATION
|
||||
xmlSchemaWildcardNsPtr ns;
|
||||
printf("matching wildcard: [%d] of complexType: %s\n", type->attributeWildcard, type->name);
|
||||
if (type->attributeWildcard->processContents ==
|
||||
XML_SCHEMAS_ANY_LAX)
|
||||
printf("processContents: lax\n");
|
||||
else if (type->attributeWildcard->processContents ==
|
||||
XML_SCHEMAS_ANY_STRICT)
|
||||
printf("processContents: strict\n");
|
||||
else
|
||||
printf("processContents: skip\n");
|
||||
if (type->attributeWildcard->any)
|
||||
printf("type: any\n");
|
||||
else if (type->attributeWildcard->negNsSet != NULL) {
|
||||
@ -8526,26 +8535,52 @@ xmlSchemaValidateAttributes(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr elem, xmlSche
|
||||
} else
|
||||
printf("empty\n");
|
||||
|
||||
#endif
|
||||
/*
|
||||
* TODO: Implement processContents.
|
||||
*/
|
||||
|
||||
#endif
|
||||
curState = ctxt->attr;
|
||||
while (curState != NULL) {
|
||||
if ((curState->state == XML_SCHEMAS_ATTR_UNKNOWN) &&
|
||||
(curState->attr != NULL)) {
|
||||
if (curState->attr->ns != NULL) {
|
||||
if (xmlSchemaMatchesWildcardNs(type->attributeWildcard,
|
||||
curState->attr->ns->href))
|
||||
if (curState->state == XML_SCHEMAS_ATTR_UNKNOWN) {
|
||||
if (curState->attr->ns != NULL)
|
||||
nsURI = curState->attr->ns->href;
|
||||
else
|
||||
nsURI = NULL;
|
||||
if (xmlSchemaMatchesWildcardNs(type->attributeWildcard,
|
||||
nsURI)) {
|
||||
/*
|
||||
* Handle processContents.
|
||||
*/
|
||||
if ((type->attributeWildcard->processContents ==
|
||||
XML_SCHEMAS_ANY_LAX) ||
|
||||
(type->attributeWildcard->processContents ==
|
||||
XML_SCHEMAS_ANY_STRICT)) {
|
||||
|
||||
attr = curState->attr;
|
||||
attrDecl = xmlSchemaGetAttribute(ctxt->schema,
|
||||
attr->name, nsURI);
|
||||
if (attrDecl != NULL) {
|
||||
value = xmlNodeListGetString(elem->doc, attr->children, 1);
|
||||
ret = xmlSchemaValidateSimpleValue(ctxt, attrDecl->subtypes,
|
||||
value);
|
||||
if (ret != 0)
|
||||
curState->state = XML_SCHEMAS_ATTR_INVALID_VALUE;
|
||||
else
|
||||
curState->state = XML_SCHEMAS_ATTR_CHECKED;
|
||||
curState->decl = attrDecl;
|
||||
if (value != NULL) {
|
||||
xmlFree(value);
|
||||
}
|
||||
|
||||
} else if (type->attributeWildcard->processContents ==
|
||||
XML_SCHEMAS_ANY_LAX) {
|
||||
curState->state = XML_SCHEMAS_ATTR_CHECKED;
|
||||
}
|
||||
} else
|
||||
curState->state = XML_SCHEMAS_ATTR_CHECKED;
|
||||
} else if (xmlSchemaMatchesWildcardNs(type->attributeWildcard,
|
||||
NULL))
|
||||
curState->state = XML_SCHEMAS_ATTR_CHECKED;
|
||||
}
|
||||
}
|
||||
}
|
||||
curState = curState->next;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ATTR_VALIDATION
|
||||
if (redundant)
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
|
Loading…
x
Reference in New Issue
Block a user