Fwd: [xquery-talk] querying attribute?

Ronald Bourret rpbourret at rpbourret.com
Wed Mar 18 20:34:10 PST 2009

Thomas R. Jones wrote:
>> So it is correct to declare and reference namespace prefixes within 
>> xquery even though they are not "explicitly" done so in source code?

I'm not sure what you mean by "source code". Do you mean the XML document?

What XQuery requires is that, after prefixes and the default namespace 
are resolved, the names in the query must be the same (namespace and 
element/attribute name) as the names in the XML document in order to 
have a successful match.

>> I'm guessing the parser is handling this natively. The XML source is 
>> located within an international database and it strips prefix 
>> declarations within the import triggers. :(

Stripping prefix declarations is almost certainly an error -- I'd be 
curious to hear the reason for it. There are two problems:

1) If the trigger leaves the prefixes in the element and attribute 
names, the resulting document is namespace invalid, as the prefixes are 
not declared.

2) If the prefixes are also stripped from the element and attribute 
names, the resulting document, although namespace valid, is not the same 
document. Namespaces are used to create two-part names for elements and 
attributes, and removing half the name (the namespace) is akin to 
changing the element and attribute names themselves.

-- Ron

More information about the talk mailing list