Fwd: [xquery-talk] querying attribute?

G. Ken Holman gkholman at CraneSoftwrights.com
Thu Mar 19 07:54:49 PST 2009


At 2009-03-18 17:06 -0500, 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?

Absolutely ... in fact it is required.  Prefixes are ephemeral and 
should be irrelevant in queries.  They are only a proxy to the URI 
string associated with the prefix.  The data model happens to contain 
the prefixes used, but the name matching is based on the URI string 
and the local part.

Your transform references URI/local-part names using your choice of prefixes.

Your users' XML documents reference URI/local-part names using their 
choices of prefixes.

The URI/local-part names match regardless of the prefixes used in both.

After all, you still want your transform to work even if the users 
change their minds about their use of namespace prefixes or the 
default namespace.

>>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. :(

This is not a sad thing.  Provided that they have not lost the fully 
qualified names by stripping the URI strings, they can choose to use 
any prefix they want (for elements and attributes) or no prefix (for 
elements).  Your transform doesn't have to change.

I hope this helps.

. . . . . . . . Ken

--
XQuery/XSLT/XSL-FO training in Los Angeles (New dates!) 2009-06-08
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman at CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal



More information about the talk mailing list