Re: [xml] Schema validity failure for valid document


Daniel Veillard wrote:
On Mon, Jan 10, 2005 at 04:47:33PM +0100, Kasimier Buchcik wrote:


Daniel Veillard wrote:

Well, there is only one string in the regexp automata.
xmlRegExecPushString2() coalesce pairs. I'm not sure duplicating
the API is a good thing, either the info function expand coalesced
sctrings or not, but having 2 function calls sounds a bit messy to me.

OK, so I'll format the local name and the namespace on the schema side.
The problem I saw was that the regex engine formats the local name
and the namespace name, to squeeze it into one string using
xmlAutomataNewTransition2; extracting those values on the schema side
would mean that the format is no longer encapsulated in the regex
code. But if this is OK with you, I'll do it.

   yeah, if needed we can provide a public splitting function. I though
about this a bit more and I think the current API is better because one
doesn't need to make deallocation of object as the result of calling this
function, all string returned are comming directly from the regexp. If
we split one will need to deallocate the chunks produced because they
possibly don't exist in the regexp.

I tried an initial implementation.
There is a problem with negated namespaces in wildcards:

(the "##other" namespace indicator in <any> is of importance here):

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="";
  <xsd:element name="foo">
        <xsd:element name="a"/>
        <xsd:element name="b" minOccurs="0" maxOccurs="unbounded"/>
<xsd:any minOccurs="0" maxOccurs="1" namespace="##other" processContents="lax"/>
        <xsd:element name="c"/>

<?xml version="1.0"?>
<foo xmlns="http://FOO";
  xsi:schemaLocation="http://FOO errRep1.xsd">

P:\libxml2-lab\tests\2005-01-10>xmllint --noout --schema errRep1.xsd errRep1_0.xml
DEBUG terminal: 0
DEBUG nbval: 0
Element 'c': This element is not expected. Expected is .
errRep1_0.xml fails to validate

Note that nbval is zero here.
Changing the negated namespace (##other) to "http://BAR";, I get:

P:\libxml2-lab\tests\2005-01-10>xmllint --noout --schema errRep1.xsd errRep1_0.xml
DEBUG terminal: 0
DEBUG nbval: 3
Element 'x': This element is not expected. Expected is one of { ("http://FOO";, "b"), ("http://BAR";, any), ("http://FOO";, "c") }.
errRep1_0.xml fails to validate

This is due to the fact that negated namespaces are build using
an automaton approach in xmlSchemaBuildAContentModel:

  deadEnd = xmlAutomataNewState(ctxt->am);
  ctxt->state = xmlAutomataNewTransition2(ctxt->am,
    start, deadEnd, BAD_CAST "*", wild->negNsSet->value, type);
  ctxt->state = xmlAutomataNewTransition2(ctxt->am,
    start, NULL, BAD_CAST "*", BAD_CAST "*", type);
  xmlAutomataNewEpsilon(ctxt->am, ctxt->state, end);

The namespace is let through and then caught with a dead-end.

Any ideas?

One workaround I see, would be to add a special negating character to
the namespace name if calling xmlAutomataNewTransition2, and augment
xmlRegStrEqualWildcard to handle negations:
  "*|~http://FOO"; - the tilde indicates a negation

But this would be a non-automaton approach, plus I don't know if it's
too hackish.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]