<div dir="ltr">Hi Michael,<div><br></div><div>Thank you for your reply.  It's interesting that until <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">XPath 3.0</span>, we could *construct* empty-namespace elements inside non-empty namespace elements (via the xmlns="" declaration), but we couldn't *query* them without resorting to the somewhat means of indirect wildcards (e.g., `/*:elem`) or use of the local-name function (e.g., `/*[local-name() eq 'elem']`).  Is that right?  If so, this drives home the importance to me of the URI-qualified names feature (e.g., `/Q{}elem`) released with XPath 3.0.</div><div><br></div><div>I'd be interested to know more about the history of the development of namespaces and efforts to bridge the world of namespaces (namespace axis-land) with the world of documents without this axis (namespace flat-land).  Is there any good published account of this?  <br></div><div><br></div><div>Joe</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Apr 2, 2018 at 3:19 PM Michael Kay <<a href="mailto:mike@saxonica.com">mike@saxonica.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">XML doesn't allow you to bind a prefix to the thing-that-is-not-a-namespace.<div><br></div><div>With XML namespaces 1.1, the declaration xmlns:x="" doesn't bind x to anything, it unbinds x. Within the scope of this (un)declaratiion, the prefix x cannot be used.</div><div><br></div><div>It makes sense for XQuery to do the same thing. The rules are in §<a href="http://3.9.1.2" target="_blank">3.9.1.2</a>:</div><div><br></div><div><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)">If the namespace URI is a zero-length string and the implementation supports </span><a href="https://www.w3.org/TR/xquery-31/#XMLNAMES11" style="color:rgb(3,69,117);text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(187,187,187);padding:0px 1px;font-family:sans-serif" target="_blank">[XML Names 1.1]</a><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)">, any existing namespace binding for the given prefix is removed from the </span><a title="in-scope namespaces" href="https://www.w3.org/TR/xquery-31/#dt-in-scope-namespaces" style="color:rgb(3,69,117);text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(187,187,187);padding:0px 1px;font-family:sans-serif" target="_blank">in-scope namespaces</a><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)"> of the constructed element and from the</span><a title="statically known namespaces" href="https://www.w3.org/TR/xquery-31/#dt-static-namespaces" style="color:rgb(3,69,117);text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(187,187,187);padding:0px 1px;font-family:sans-serif" target="_blank">statically known namespaces</a><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)"> of the constructor expression. If the namespace URI is a zero-length string and the implementation does not support </span><a href="https://www.w3.org/TR/xquery-31/#XMLNAMES11" style="color:rgb(3,69,117);text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(187,187,187);padding:0px 1px;font-family:sans-serif" target="_blank">[XML Names 1.1]</a><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)">, a static error is raised [</span><a href="https://www.w3.org/TR/xquery-31/#ERRXQST0085" title="err:XQST0085" style="color:rgb(3,69,117);text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(187,187,187);padding:0px 1px;font-family:sans-serif" target="_blank">err:XQST0085</a><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)">]. It is</span><a title="implementation defined" href="https://www.w3.org/TR/xquery-31/#dt-implementation-defined" style="color:rgb(3,69,117);text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(187,187,187);padding:0px 1px;font-family:sans-serif" target="_blank">implementation-defined</a><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)"> whether an implementation supports </span><a href="https://www.w3.org/TR/xquery-31/#XMLNAMES" style="color:rgb(3,69,117);text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(187,187,187);padding:0px 1px;font-family:sans-serif" target="_blank">[XML Names]</a><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)"> or </span><a href="https://www.w3.org/TR/xquery-31/#XMLNAMES11" style="color:rgb(3,69,117);text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(187,187,187);padding:0px 1px;font-family:sans-serif" target="_blank">[XML Names 1.1]</a><span style="font-family:sans-serif;font-size:medium;background-color:rgb(255,255,255)">.</span></div><div><div><font face="sans-serif" size="3"><span style="background-color:rgb(255,255,255)"><br></span></font></div><div><font face="sans-serif" size="3"><span style="background-color:rgb(255,255,255)">Michael Kay</span></font></div><div><font face="sans-serif" size="3"><span style="background-color:rgb(255,255,255)">Saxonica</span></font></div><div><br><blockquote type="cite"><div>On 2 Apr 2018, at 20:00, Joe Wicentowski <<a href="mailto:joewiz@gmail.com" target="_blank">joewiz@gmail.com</a>> wrote:</div><br class="m_3945699292844880506Apple-interchange-newline"><div><div dir="ltr">Hi all,<div><br></div><div>A common question for beginners is how to access empty namespaced elements in non-empty contexts.  The easiest answer is to use a wildcard.  For example, we use one here inside the curly braces:</div><div><br></div><div>  let $x := <x><y/></x><br></div><div>  return</div><div>    <z xmlns="foo">{ $x/*:y }</z></div><div><br></div><div>As expected, this query returns:</div><div><br></div><div>  <z xmlns="foo"><y xmlns=""/></z></div><div><br></div><div>The other method I know of is to use the URI-qualified name:</div><div><br></div><div><div>  let $x := <x><y/></x><br></div><div>  return</div><div>    <z xmlns="foo">{ $x/Q{}y }</z></div><div><br></div></div><div>A third method occurred to me, but it does not work, and I haven't been able to pin down the reason despite reading the spec.  The idea is to bind the empty namespace URI to a namespace prefix, e.g., "my":</div><div><br></div><div>  declare namespace my="";<br></div><div>  </div><div><div>  let $x := <x><y/></x></div><div>  return</div><div>    <z xmlns="foo">{ $x/my:y }</z></div></div><div><br></div><div>In BaseX, eXist, and Saxon, this returns err:XPST0081 (<a href="https://www.w3.org/TR/xquery-31/#ERRXPST0081" target="_blank">https://www.w3.org/TR/xquery-31/#ERRXPST0081</a>).  The location of the error points to the step, "my:y" on the final line.</div><div><br></div><div>Can anyone enlighten me on the reason this 3rd method is invalid?  Bonus points for an explanation that includes why I cannot bind a namespace prefix to the empty namespace, but I can access it via *: and Q{}?</div><div><br></div><div>Thanks,</div><div>Joe</div></div>
_______________________________________________<br><a href="mailto:talk@x-query.com" target="_blank">talk@x-query.com</a><br><a href="http://x-query.com/mailman/listinfo/talk" target="_blank">http://x-query.com/mailman/listinfo/talk</a></div></blockquote></div><br></div></div></blockquote></div>