<html><body bgcolor="#FFFFFF"><div>The following message was mistakingly only sent to ken. I'm forwarding it to the list at his request so that other users may benefit from his insight. :)</div><div><br></div><div>Thomas&nbsp;<br><br>Sent from my iPhone</div><div><br>Begin forwarded message:<br><br></div><blockquote type="cite"><div><b>From:</b> "Thomas R. Jones" &lt;<a href="mailto:thomas.jones@maitreyasecurity.com">thomas.jones@maitreyasecurity.com</a>><br><b>Date:</b> March 18, 2009 2:42:49 PM CDT<br><b>To:</b> "G. Ken Holman" &lt;<a href="mailto:gkholman@cranesoftwrights.com">gkholman@cranesoftwrights.com</a>><br><b>Subject:</b> <b>Re: [xquery-talk] querying attribute?</b><br><br></div></blockquote><div></div><blockquote type="cite"><div><span>Thanks so much for your response ken.</span><br><span></span><br><span>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 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. :(</span><br><span></span><br><span>I'll try this as soon as I get home. Thanks again</span><br><span></span><br><span>Sent from my iPhone</span><br><span></span><br><span>On Mar 18, 2009, at 2:05 PM, "G. Ken Holman" &lt;<a href="mailto:gkholman@cranesoftwrights.com">gkholman@cranesoftwrights.com</a>> wrote:</span><br><span></span><br><blockquote type="cite"><span>At 2009-03-18 13:06 -0400, Thomas R. Jones wrote:</span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>Hello all, I have the following code:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>&lt;tests xmlns="<a href="http://oval.mitre.org/XMLSchema/oval-definitions-5">http://oval.mitre.org/XMLSchema/oval-definitions-5</a>"></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>&lt;rpminfo_test</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>xmlns="<a href="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux">http://oval.mitre.org/XMLSchema/oval-definitions-5#linux</a>"</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>check="all" comment="apache2 is installed"</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>id="oval:com.maitreyasecurity:tst:674" version="1"></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> &lt;object object_ref="oval:com.maitreyasecurity:obj:674"/></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> &lt;state state_ref="oval:com.maitreyasecurity:ste:500"/></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>&lt;/rpminfo_test></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>&lt;/tests></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>I am trying everything i can think of to return the attribute value but</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>am hanging up on the namespace(i think). I believe because the attribute</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>is not prefixed that it is located within a NULL namespace and not the</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>element default namespace declared----correct?</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Yes, that is correct. *All* unprefixed attributes are in no namespace, never the default namespace.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>Here is my xquery:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>declare default element namespace</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>"<a href="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux">http://oval.mitre.org/XMLSchema/oval-definitions-5#linux</a>"; for $attr in</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>document("apache2.package.novell.maitreyasecurity.en_US.xml","inventory.a")/tests/rpminfo_test/@id return string($attr)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Ideas?</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>You declare the "#linux" namespace as your default element namespace, so it is being applied to *every* element (after all, it is the default) which includes the &lt;tests> element. &nbsp;Your &lt;tests> element is in not in the "#linux" namespace, so your problem is it isn't finding the element with the attribute, not that it isn't finding the attribute.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I tell my students that using the default namespace can be awkward when dealing with an instance of numerous namespaces (as I learned the hard way when working with UBL). &nbsp;I believe it will make maintenance easier if you explicitly use prefixes when there is more than one namespace in your source tree.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>A running example is below ... I hope this helps.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>. . . . . . . . . Ken</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>t:\ftemp>type thomas.xml</span><br></blockquote><blockquote type="cite"><span>&lt;tests xmlns="<a href="http://oval.mitre.org/XMLSchema/oval-definitions-5">http://oval.mitre.org/XMLSchema/oval-definitions-5</a>"></span><br></blockquote><blockquote type="cite"><span>&lt;rpminfo_test</span><br></blockquote><blockquote type="cite"><span>xmlns="<a href="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux">http://oval.mitre.org/XMLSchema/oval-definitions-5#linux</a>"</span><br></blockquote><blockquote type="cite"><span>check="all" comment="apache2 is installed"</span><br></blockquote><blockquote type="cite"><span>id="oval:com.maitreyasecurity:tst:674" version="1"></span><br></blockquote><blockquote type="cite"><span> &lt;object object_ref="oval:com.maitreyasecurity:obj:674"/></span><br></blockquote><blockquote type="cite"><span> &lt;state state_ref="oval:com.maitreyasecurity:ste:500"/></span><br></blockquote><blockquote type="cite"><span>&lt;/rpminfo_test></span><br></blockquote><blockquote type="cite"><span>&lt;/tests></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>t:\ftemp>call xquery thomas.xml thomas.xq</span><br></blockquote><blockquote type="cite"><span>&lt;?xml version="1.0" encoding="UTF-8"?>oval:com.maitreyasecurity:tst:674</span><br></blockquote><blockquote type="cite"><span>t:\ftemp>type thomas.xq</span><br></blockquote><blockquote type="cite"><span>declare namespace o =</span><br></blockquote><blockquote type="cite"><span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"<a href="http://oval.mitre.org/XMLSchema/oval-definitions-5">http://oval.mitre.org/XMLSchema/oval-definitions-5</a>";</span><br></blockquote><blockquote type="cite"><span>declare namespace l =</span><br></blockquote><blockquote type="cite"><span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"<a href="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux">http://oval.mitre.org/XMLSchema/oval-definitions-5#linux</a>";</span><br></blockquote><blockquote type="cite"><span>for $attr in</span><br></blockquote><blockquote type="cite"><span>/o:tests/l:rpminfo_test/@id return string($attr)</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>t:\ftemp></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>--</span><br></blockquote><blockquote type="cite"><span>XQuery/XSLT/XSL-FO training in Los Angeles (New dates!) 2009-06-08</span><br></blockquote><blockquote type="cite"><span>Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video</span><br></blockquote><blockquote type="cite"><span>Video lesson: &nbsp;&nbsp;&nbsp;<a href="http://www.youtube.com/watch?v=PrNjJCh7Ppg&amp;fmt=18"><a href="http://www.youtube.com/watch?v=PrNjJCh7Ppg&amp;fmt=18">http://www.youtube.com/watch?v=PrNjJCh7Ppg&amp;fmt=18</a></a></span><br></blockquote><blockquote type="cite"><span>Video overview: &nbsp;<a href="http://www.youtube.com/watch?v=VTiodiij6gE&amp;fmt=18"><a href="http://www.youtube.com/watch?v=VTiodiij6gE&amp;fmt=18">http://www.youtube.com/watch?v=VTiodiij6gE&amp;fmt=18</a></a></span><br></blockquote><blockquote type="cite"><span>G. Ken Holman &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:gkholman@CraneSoftwrights.com"><a href="mailto:gkholman@CraneSoftwrights.com">mailto:gkholman@CraneSoftwrights.com</a></a></span><br></blockquote><blockquote type="cite"><span>Crane Softwrights Ltd. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.CraneSoftwrights.com/q/"><a href="http://www.CraneSoftwrights.com/q/">http://www.CraneSoftwrights.com/q/</a></a></span><br></blockquote><blockquote type="cite"><span>Male Cancer Awareness Nov'07 &nbsp;<a href="http://www.CraneSoftwrights.com/q/bc"><a href="http://www.CraneSoftwrights.com/q/bc">http://www.CraneSoftwrights.com/q/bc</a></a></span><br></blockquote><blockquote type="cite"><span>Legal business disclaimers: &nbsp;<a href="http://www.CraneSoftwrights.com/legal"><a href="http://www.CraneSoftwrights.com/legal">http://www.CraneSoftwrights.com/legal</a></a></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>_______________________________________________</span><br></blockquote><blockquote type="cite"><span><a href="mailto:talk@x-query.com">talk@x-query.com</a></span><br></blockquote><blockquote type="cite"><span><a href="http://x-query.com/mailman/listinfo/talk">http://x-query.com/mailman/listinfo/talk</a></span><br></blockquote></div></blockquote></body></html>