Hi Mukul,

As you've noted "http://www.w3.org/2001/XMLSchema"; can be bound to other
prefixes than "xs".  Also, "xs" could be bound to something other than
"http://www.w3.org/2001/XMLSchema"; or not be declared at all.

We should not be hard-coding the namespace bindings. For each XPath
expression they should be determined from the namespace context of the
schema we're processing and I believe also the and the
"xpathDefaultNamespace" attribute which might be on the "assertion" or
"schema" element if the assertion doesn't have one. Doing anything else is
incorrect.

Thanks.

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

Mukul Gandhi <[email protected]> wrote on 11/11/2009 04:44:12 AM:

> Hi all,
>    We specify XSD 1.1 Schema, and a sample assertions something like
below:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>    ...
>    <xs:assert test="xs:string(test) eq 'xxx'" />
>    ...
> </xs:schema>
>
> The current implementation of XSD 1.1 assertions within Xerces-J,
> while invoking the PsychoPath XPath 2.0 engine, constructs a namespace
> binding in a kind of map (actually Xerces-J adds all the needed
> namespace definitions for PsychoPath, in a XPath 2.0 "DynamicContext"
> object), that is passed to the PsychoPath engine, while doing an XPath
> 2 evaluation.
>
> One of the namespace bindings that Xerces-J initializes for PsychoPath
> is the XML Schema namespace. This is done as following, with an
> PsychoPath API:
>
> DynamicContext.add_namespace("xs", "http://www.w3.org/2001/XMLSchema";);
>
> This is an important namespace binding, that Xerces-J has to
> initialize for XPath 2 evaluation with PsychoPath.
>
> The prefix "xs" is presently hardcoded in Xerces-J, which means that
> presently only this particular prefix can be functionally used while
> evaluating XPath expressions, with PsychoPath. This has significance,
> when we use any constructs from the XML Schema namespace, like say
> xs:string in assertion XPath 2.0 expressions.
>
> For the above XSD 1.1 example, the assertion would evaluate fine as
> expected (because the prefix "xs" was used in XPath 2 expression. And
> ironically, Xerces-J currently does not enforce statically the binding
> between prefix "xs" in assertion XPath expressions and the Schema
> namespace URI that is defined on xs:schema element. Is this an
> important issue to look at?). But following assertions would fail (it
> would return false), if written in the XSD 1.1 schema:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
>   ...
>   <xsd:assert test="xsd:string(test) eq 'xxx'" />
>
> (because the XPath expression in assertions uses the prefix "xsd" for
> XML schema. But the whole XSD 1.1 schema looks correct.)
>
> Currently, Xerces-J plus PsychoPath engine cannot utilize any other
> XSD prefix (than, "xs") for assertion XPath 2 expressions. The problem
> happens for following expression, in above XSD 1.1 Schema:
>
> xsd:string(test) eq 'xxx'
>
> While rest of Schema would execute fine.
>
> So presently, a convention (i.e, prefix "xs" for namespace
> http://www.w3.org/2001/XMLSchema) controls the XPath expressions that
> are evaluated by PsychoPath engine.
>
> Ideally, I would wish that Xerces-J can create a XML Schema namespace
> binding for PsychoPath engine as following:
>
> DynamicContext.add_namespace("xx", "http://www.w3.org/2001/XMLSchema";);
>
> Where, the XSD prefix string "xx" would be read dynamically from the
> actual XSD Schema at runtime.
>
> Should something like this must be done, to support assertions? If
> yes, an advise on the design for this would be helpful.
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]

Reply via email to