You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Jeff Lansing <je...@polexis.com> on 2000/10/12 02:39:46 UTC

Schema validation error reporting

Hi,

There is a subtle bug in XMLContentSpec.toString(...) that results in
error messages like these:

[Error] :8:24: The content of element type "gml:outerBoundaryIs" is
incomplete, it must match "(##any:uri=http://www.opengis.net/gml)".

The bug is in the logic that looks like this (and is repeated 3 times in
the code) :

                    if (contentSpec.value == -1 &&
contentSpec.otherValue == -1) {
                        str.append("#PCDATA");
                    }
                    else if (contentSpec.otherValue != -1) {

str.append("##any:uri="+stringPool.toString(contentSpec.otherValue));
                    }
                    else if (contentSpec.value == -1) {
                        str.append("##any");
                    }
                    else {

str.append(stringPool.toString(contentSpec.value));
                    }

If you think about it you see that the third case has been preempted by
the first two. Also it looks like what is really meant is something like
this:

                    if (neither()) {
                        str.append("#PCDATA");
                    }
                    if (both()) {
                        //this is broken here:

str.append("##any:uri="+stringPool.toString(contentSpec.otherValue));
                    }
                     if (other()) {
                        str.append("##any");
                    }
                    if(value()) {

str.append(stringPool.toString(contentSpec.value));
                    }

where:
        public boolean neither() {
            return  value == -1 && otherValue == -1;
        }
        public boolean value() {
            return value == -1 && otherValue != -1;
        }
        public boolean other() {
            return value == -1 && otherValue != -1;
        }
        public boolean both() {
            return value != -1 && otherValue != -1;
        }

Jeff


Re: Schema validation error reporting

Posted by Eric Ye <er...@locus.apache.org>.
Thanks, Jeff. Then  I'll fix this in the CVS.

And yes, it won't know anything about the actual prefix that the namespace
URI was bound to, because it can be different in different xml files.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "Jeff Lansing" <je...@polexis.com>
To: "Eric Ye" <er...@locus.apache.org>
Cc: <xe...@xml.apache.org>
Sent: Thursday, October 12, 2000 11:28 AM
Subject: Re: Schema validation error reporting


> Eric,
> Duh. Now I get it.
> I take out the 2nd ad 3rd brances in the 3 places in the method, and it
works:
> [Error] :10:19: The content of element type "gml:LinearRing" is
incomplete, it
> must match "(coordinates)".
>
> I guess I would like it to say "gml:coordinates", but I don't think it
can. I
> don't think it knows that "gml" is the code for the namespace
> "http://www.opengis.net/gml".
>
> Thanks,
> Jeff
>
> Eric Ye wrote:
>
> > > Eric,
> > > No, the second branch is reached all the time (oops, I mean the
condition
> > when
> > > value != -1 && otherValue != -1) and the problem is that value is
being
> > ignored
> > > there.
> >
> > Then that is the branch in the "else" branch, what I meant was to change
it
> > to:
> >
> >                      if ( contentSpec.value == -1 &&
> >                           contentSpec.otherValue == -1) {
> >                           str.append("#PCDATA");
> >                      }
> >                      else {
> >
> > str.append(stringPool.toString(contentSpec.value));
> >                       }
> >
> > _____
> >
> > Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>


Re: Schema validation error reporting

Posted by Jeff Lansing <je...@polexis.com>.
Eric,
Duh. Now I get it.
I take out the 2nd ad 3rd brances in the 3 places in the method, and it works:
[Error] :10:19: The content of element type "gml:LinearRing" is incomplete, it
must match "(coordinates)".

I guess I would like it to say "gml:coordinates", but I don't think it can. I
don't think it knows that "gml" is the code for the namespace
"http://www.opengis.net/gml".

Thanks,
Jeff

Eric Ye wrote:

> > Eric,
> > No, the second branch is reached all the time (oops, I mean the condition
> when
> > value != -1 && otherValue != -1) and the problem is that value is being
> ignored
> > there.
>
> Then that is the branch in the "else" branch, what I meant was to change it
> to:
>
>                      if ( contentSpec.value == -1 &&
>                           contentSpec.otherValue == -1) {
>                           str.append("#PCDATA");
>                      }
>                      else {
>
> str.append(stringPool.toString(contentSpec.value));
>                       }
>
> _____
>
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org


Re: Schema validation error reporting

Posted by Eric Ye <er...@locus.apache.org>.
> Eric,
> No, the second branch is reached all the time (oops, I mean the condition
when
> value != -1 && otherValue != -1) and the problem is that value is being
ignored
> there.

Then that is the branch in the "else" branch, what I meant was to change it
to:

                     if ( contentSpec.value == -1 &&
                          contentSpec.otherValue == -1) {
                          str.append("#PCDATA");
                     }
                     else {


str.append(stringPool.toString(contentSpec.value));
                      }

_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org




Re: Schema validation error reporting

Posted by Jeff Lansing <je...@polexis.com>.
Eric,
No, the second branch is reached all the time (oops, I mean the condition when
value != -1 && otherValue != -1) and the problem is that value is being ignored
there.
Jeff

Eric Ye wrote:

> You are right that the 3rd 'if' condition is preempted by the first  2, but
> the 2nd and 3rd  branches will never be reached since "any" leaf does not
> share the same type with regular leaf any more. So the 2nd and 3rd branches
> should be removed completely. Would you mind do some testing to see if my
> speculation is correct?
> _____
>
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
>
> ----- Original Message -----
> From: "Jeff Lansing" <je...@polexis.com>
> To: "Eric Ye" <er...@locus.apache.org>
> Cc: <xe...@xml.apache.org>
> Sent: Wednesday, October 11, 2000 5:39 PM
> Subject: Schema validation error reporting
>
> > Hi,
> >
> > There is a subtle bug in XMLContentSpec.toString(...) that results in
> > error messages like these:
> >
> > [Error] :8:24: The content of element type "gml:outerBoundaryIs" is
> > incomplete, it must match "(##any:uri=http://www.opengis.net/gml)".
> >
> > The bug is in the logic that looks like this (and is repeated 3 times in
> > the code) :
> >
> >                     if (contentSpec.value == -1 &&
> > contentSpec.otherValue == -1) {
> >                         str.append("#PCDATA");
> >                     }
> >                     else if (contentSpec.otherValue != -1) {
> >
> > str.append("##any:uri="+stringPool.toString(contentSpec.otherValue));
> >                     }
> >                     else if (contentSpec.value == -1) {
> >                         str.append("##any");
> >                     }
> >                     else {
> >
> > str.append(stringPool.toString(contentSpec.value));
> >                     }
> >
> > If you think about it you see that the third case has been preempted by
> > the first two. Also it looks like what is really meant is something like
> > this:
> >
> >                     if (neither()) {
> >                         str.append("#PCDATA");
> >                     }
> >                     if (both()) {
> >                         file://this is broken here:
> >
> > str.append("##any:uri="+stringPool.toString(contentSpec.otherValue));
> >                     }
> >                      if (other()) {
> >                         str.append("##any");
> >                     }
> >                     if(value()) {
> >
> > str.append(stringPool.toString(contentSpec.value));
> >                     }
> >
> > where:
> >         public boolean neither() {
> >             return  value == -1 && otherValue == -1;
> >         }
> >         public boolean value() {
> >             return value == -1 && otherValue != -1;
> >         }
> >         public boolean other() {
> >             return value == -1 && otherValue != -1;
> >         }
> >         public boolean both() {
> >             return value != -1 && otherValue != -1;
> >         }
> >
> > Jeff
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Schema validation error reporting

Posted by Eric Ye <er...@locus.apache.org>.
You are right that the 3rd 'if' condition is preempted by the first  2, but
the 2nd and 3rd  branches will never be reached since "any" leaf does not
share the same type with regular leaf any more. So the 2nd and 3rd branches
should be removed completely. Would you mind do some testing to see if my
speculation is correct?
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "Jeff Lansing" <je...@polexis.com>
To: "Eric Ye" <er...@locus.apache.org>
Cc: <xe...@xml.apache.org>
Sent: Wednesday, October 11, 2000 5:39 PM
Subject: Schema validation error reporting


> Hi,
>
> There is a subtle bug in XMLContentSpec.toString(...) that results in
> error messages like these:
>
> [Error] :8:24: The content of element type "gml:outerBoundaryIs" is
> incomplete, it must match "(##any:uri=http://www.opengis.net/gml)".
>
> The bug is in the logic that looks like this (and is repeated 3 times in
> the code) :
>
>                     if (contentSpec.value == -1 &&
> contentSpec.otherValue == -1) {
>                         str.append("#PCDATA");
>                     }
>                     else if (contentSpec.otherValue != -1) {
>
> str.append("##any:uri="+stringPool.toString(contentSpec.otherValue));
>                     }
>                     else if (contentSpec.value == -1) {
>                         str.append("##any");
>                     }
>                     else {
>
> str.append(stringPool.toString(contentSpec.value));
>                     }
>
> If you think about it you see that the third case has been preempted by
> the first two. Also it looks like what is really meant is something like
> this:
>
>                     if (neither()) {
>                         str.append("#PCDATA");
>                     }
>                     if (both()) {
>                         file://this is broken here:
>
> str.append("##any:uri="+stringPool.toString(contentSpec.otherValue));
>                     }
>                      if (other()) {
>                         str.append("##any");
>                     }
>                     if(value()) {
>
> str.append(stringPool.toString(contentSpec.value));
>                     }
>
> where:
>         public boolean neither() {
>             return  value == -1 && otherValue == -1;
>         }
>         public boolean value() {
>             return value == -1 && otherValue != -1;
>         }
>         public boolean other() {
>             return value == -1 && otherValue != -1;
>         }
>         public boolean both() {
>             return value != -1 && otherValue != -1;
>         }
>
> Jeff
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>