<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">XML doesn't allow you to bind a prefix to the thing-that-is-not-a-namespace.<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">It makes sense for XQuery to do the same thing. The rules are in ยง3.9.1.2:</div><div class=""><br class=""></div><div class=""><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">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; margin: 0px -1px; font-family: sans-serif; orphans: 2; widows: 2;" class="">[XML Names 1.1]</a><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">, 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; margin: 0px -1px; font-family: sans-serif; orphans: 2; widows: 2;" class="">in-scope namespaces</a><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> 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; margin: 0px -1px; font-family: sans-serif; orphans: 2; widows: 2;" class="">statically known namespaces</a><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> 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; margin: 0px -1px; font-family: sans-serif; orphans: 2; widows: 2;" class="">[XML Names 1.1]</a><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">, 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; margin: 0px -1px; font-family: sans-serif; orphans: 2; widows: 2;" class="">err:XQST0085</a><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">]. 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; margin: 0px -1px; font-family: sans-serif; orphans: 2; widows: 2;" class="">implementation-defined</a><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> 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; margin: 0px -1px; font-family: sans-serif; orphans: 2; widows: 2;" class="">[XML Names]</a><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> 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; margin: 0px -1px; font-family: sans-serif; orphans: 2; widows: 2;" class="">[XML Names 1.1]</a><span style="font-family: sans-serif; font-size: medium; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class="">.</span></div><div class=""><div style="orphans: 2; widows: 2;" class=""><font face="sans-serif" size="3" class=""><span style="background-color: rgb(255, 255, 255);" class=""><br class=""></span></font></div><div style="orphans: 2; widows: 2;" class=""><font face="sans-serif" size="3" class=""><span style="background-color: rgb(255, 255, 255);" class="">Michael Kay</span></font></div><div style="orphans: 2; widows: 2;" class=""><font face="sans-serif" size="3" class=""><span style="background-color: rgb(255, 255, 255);" class="">Saxonica</span></font></div><div><br class=""><blockquote type="cite" class=""><div class="">On 2 Apr 2018, at 20:00, Joe Wicentowski <<a href="mailto:joewiz@gmail.com" class="">joewiz@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi all,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">  let $x := <x><y/></x><br class=""></div><div class="">  return</div><div class="">    <z xmlns="foo">{ $x/*:y }</z></div><div class=""><br class=""></div><div class="">As expected, this query returns:</div><div class=""><br class=""></div><div class="">  <z xmlns="foo"><y xmlns=""/></z></div><div class=""><br class=""></div><div class="">The other method I know of is to use the URI-qualified name:</div><div class=""><br class=""></div><div class=""><div class="">  let $x := <x><y/></x><br class=""></div><div class="">  return</div><div class="">    <z xmlns="foo">{ $x/Q{}y }</z></div><div class=""><br class=""></div></div><div class="">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 class=""><br class=""></div><div class="">  declare namespace my="";<br class=""></div><div class="">  </div><div class=""><div class="">  let $x := <x><y/></x></div><div class="">  return</div><div class="">    <z xmlns="foo">{ $x/my:y }</z></div></div><div class=""><br class=""></div><div class="">In BaseX, eXist, and Saxon, this returns err:XPST0081 (<a href="https://www.w3.org/TR/xquery-31/#ERRXPST0081" class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Thanks,</div><div class="">Joe</div></div>
_______________________________________________<br class=""><a href="mailto:talk@x-query.com" class="">talk@x-query.com</a><br class="">http://x-query.com/mailman/listinfo/talk</div></blockquote></div><br class=""></div></body></html>