I think it is important to recognise that there are three sets of
namespace prefixes in play here:
- prefixes for the namespaces used in the xsds for the targetNamespace and
other imported namespaces.
- prefixes for the namespaces used in the XML instance documents
- prefixes for the namespaces used in the XPath expression
Each set of prefixes is defined entirely separately, and the prefixes may
be completely different.
In the case of an XPath expression, the prefixes must be defined
externally and given to the XPath processor in some kind of 'context'. How
this is done depends on the XPath processor.
I think the answers to the questions below follow from these facts. The
XPath is querying an XML info set. Each item in that info set has a name
and a namespace. It may also have a 'preferred' namespace prefix inherited
from the XML document that created the info set, but that prefix is never
consulted when evaluating an XPath expression. So the algorithm goes like
this:
- expand every namespace prefix in the XPath to a full URL using the
mappings given to the XPath processor
- match each namespace:name to the namespace:name in the XML info set.
and note that the xsd's namespace prefixes are not in play at all.
regards,
Tim Kimber,
Technical Lead for IBM Integration Bus Healthcare Pack
Hursley, UK
Internet: kimbert@uk.ibm.com
Tel. 01962-816742
Internal tel. 37246742
From: Mike Beckerle
To: "dfdl-wg@ogf.org" , "Costello, Roger L."
Date: 17/09/2014 09:37
Subject: [DFDL-WG] referencing local element declarations from path
expressions between two schema documents
Sent by: dfdl-wg-bounces@ogf.org
I am looking for clarification about how path steps are to be interpreted
with respect to the issue of qualified/unqualified element names, and
default or no-default namespaces.
If there is a precedent we can follow set by other tools which embed paths
into XSD (e.g., schematron?) or even just the selector/paths things in XSD
key/uniqueness constraints then I'd like to understand it.
These are some of the conundrums:
Two Schema Files: A, and B
Schema file A has target namespace AA, and binds the AA namespace to
prefix aa, and the BB namespace to prefix bb
Schema file B has target namespace BB, and the same prefix bindings.
Schema B has an element named b1 which has two local element declarations
inside it named c1 and c2.
Schema A has an element named a1 which contains an element reference to
bb:b1.
a1 has a DFDL annotation (e.g., dfdl:assert) which has a path expression
in it. this path contains bb:b1/c1
When is the path correct?
1a) when schema B has elementFormDefault='unqualified' (that's the
default), and schema A does NOT have a default namespace. Why? the default
namespace - if it existed for schema A - would implicitly qualify the c1
step of the path, but since c1 is a local element in schema B with element
form unqualified, it does not require (and cannot have) a namespace
specified in path steps for c1.
1b) when schema B has elementFormDefault='qualified', and schema A has
xmlns='BB'. Why? Because in this case the path bb:b1/c1 is equivalent to
bb:b1/bb:c1, and since c1 will have a namespace-qualified name in schema
B, that path will properly describe the path to the c1 element.
1c) Variation: when schema B has no target namespace (which I believe
makes elementFormDefault irrelevant), and schema A has no default
namespace. Because then c1 can't be qualfied as it lives in no namespace,
and schema A has no implied qualifiers.
When is the path incorrect?
2a) when schema A has xmlns="BB". Why? Because the default namespace means
the bb:b1/c1 is equivalent to {BB}b1/{BB}c1, but there is no {BB}/c1 since
c1 is just a local element declaration, and B has elementFormDefault
unqualified.
2b) when schema B has elementFormDefault='qualified', and schema A has no
default namespace. In that case the step c1 needs a namespace qualifier
either by default, or explicitly via a prefix, but it doesn't have one.
So I am interested in opinions on whether the above analysis is correct or
not, and especially in precedent for how this stuff works in other tools.
I have made a big assumption above which is that if xmlns="BB", then any
path step inside something carrying that default binding is interpreted as
qualified by that namespace. I picked this because it seemed reasonable,
and it seems one can always modify one's schema to properly address
something in another schema without having to change that other schema.
I.e., it seems to have good composition properties.
Thanks for any thoughts.
Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology |
www.tresys.com
Please note: Contributions to the DFDL Workgroup's email discussions are
subject to the OGF Intellectual Property Policy
--
dfdl-wg mailing list
dfdl-wg@ogf.org
https://www.ogf.org/mailman/listinfo/dfdl-wg
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU