Hi Hiranya,

"Hiranya Jayathilaka" <[email protected]> wrote on 12/27/2008 01:59:03
AM:

> Hi Folks,
>
> First of all I would like to wish a merry Christmas to you all. Hope
> everyone is having a great time. :)
>
> And now to the business. I have encountered a couple of issues in
> the XPath 2.0 grammar for type alternatives specified in the XML
> Schema 1.1 Structures specification. I would like to have some
> comments regarding them.
>
> 1. According to the grammar '<' is a valid character in the subset
> of allowed XPath expressions. But it seems to violate a restriction
> in the XML 1.0 specification. The XML 1.0 spec says;
>
> [10]
>
> AttValue
>
>    ::=
>
> '"' ([^<&"] | Reference)* '"'
>
> |  "'" ([^<&'] | Reference)* "'"
>
>
> So it seems '<' is not a valid character for an attribute value. But
> in type alternatives, test expressions are specified as attribute
> values. Because of this restriction when a type alternative is
> specified with the '<' character (eg: @attr < 5) the parser throws a
> fatal error.

If you want to include '<' in an attribute value it needs to be escaped.
Using your example the expression should be written as "@attr &lt; 5". You
don't need to do anything special to handle this in the XPath code. The
value the XPath parser receives will already have been normalized [1] (i.e.
"@attr &lt; 5" --> "@attr < 5") by the XML parser.

> 2. The grammar defines a lexical unit called the ValueExpr.
>
> [14]
>
> ValueExpr
>
>    ::=
>
> SimpleValue | ConstructorFunction
>
>
> But none of the other productions refer it. Hence there is no real
> meaning in having this production. This was pointed out to me by
> Khaled a few months back as well.
>
> WDYT?

That's odd. It also means "ConstructorFunction" isn't linked to the rest of
the grammar either. Though I'm not sure what the Schema Working Group's
intention was it's definitely an issue with the spec. There's already a bug
[2] open for it in the W3C's Bugzilla database. You might want to add a
comment to this bug report saying that you're working on an implementation
of type alternatives in Xerces and interested in how the Working Group
might resolve the issue.

> Thanks
>
> Best Regards,
> Hiranya

Thanks.

[1] http://www.w3.org/TR/REC-xml/#AVNormalize
[2] http://www.w3.org/Bugs/Public/show_bug.cgi?id=5907

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [email protected]
E-mail: [email protected]

Reply via email to