<p dir="ltr">And just possibly some way to flush the haze of unwanted namespaces clinging to the query result, too.</p>
<p dir="ltr">-- Graydon</p>
<br><div class="gmail_quote"><div dir="ltr">On Sun, Jun 5, 2016, 17:17 Leo Studer <<a href="mailto:leo.studer@varioweb.ch">leo.studer@varioweb.ch</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">Thank you Mike And Ghislain<div><br></div><div>may be  xPath/xQuery 3.2 will have the possibility of different default namespaces for input and output elements ;-)</div><div>and also the possibility to bind a prefix to the null namespace (“”) ...</div><div><br></div><div>Always</div><div>Leo</div></div><div style="word-wrap:break-word"><div><br></div><div><br></div><div><br><div><blockquote type="cite"><div>On 01 Jun 2016, at 13:15, Michael Kay <<a href="mailto:mike@saxonica.com" target="_blank">mike@saxonica.com</a>> wrote:</div><br><div><div style="word-wrap:break-word"><div>If the input and output are both in a namespace, and you want the output to be in a namespace but with no namespace prefix, then I think your options are:</div><div><br></div><div>(a) Use *:name in path expressions (which may over-select)</div><div><br></div><div>(b) Bind a prefix p to the input namespace and use p:name in path expressions (which is tedious)</div><div><br></div><div>(c) Use Q{}name in path expressions (which is 3.0 only, and tedious)</div><div><br></div><div>(d) Use computed element constructors, and binding the default namespace to the input namespace</div><div><br></div><div>(e) Use XSLT 2.0 with the default-xpath-namespace attribute.</div><div><br></div><div>Sadly, I remember trying to persuade the XQuery WG to allow different default namespaces for input and output element names, and the general reaction was "Mike, why do you keep trying to make namespaces even more complicated than they are already?". So XQuery repeated the mistake of XSLT 1.0, only in a slightly different form.</div><div><br></div><div>Handling input documents with a default namespace remains by a good measure the #1 xpath usability problem, a new StackOverflow user falls into the trap nearly every day.</div><div><br></div><div>Michael Kay</div><div>Saxonica</div><div><br></div><div><br></div><div><br></div><br><div><blockquote type="cite"><div>On 1 Jun 2016, at 10:44, Ghislain Fourny <<a href="mailto:g@28.io" target="_blank">g@28.io</a>> wrote:</div><br><div><div dir="ltr">Hi Leo,<div><br></div><div>I'm glad!</div><div><br></div><div>Should this happen, I guess you could add a filter using an XPath function to test for the namespace of the name of the selected element.</div><div><br></div><div><a href="https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-node-name" target="_blank">https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-node-name</a></div><div>and</div><div><a href="https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-namespace-uri-from-QName" target="_blank">https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-namespace-uri-from-QName</a><br></div><div><br></div><div>You can test for the absence of namespace easily.</div><div><br></div><div>There may be even shorter tricks, I wouldn't be surprised if Mike got something out of his magic hat :-)</div><div><br></div><div>Kind regards,</div><div>Ghislain</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 1, 2016 at 11:38 AM, Leo Studer <span dir="ltr"><<a href="mailto:leo.studer@varioweb.ch" target="_blank">leo.studer@varioweb.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Ghislain<div><br></div><div>thank you for your input, which solves my problem.</div><div><br></div><div>However, if I have the same element name in two different namespaces, then the use of a wildcard namespace makes problems ;-).</div><div><br></div><div>Always</div><div>Leo</div><div><br><div><blockquote type="cite"><div><div><div>On 01 Jun 2016, at 11:06, Ghislain Fourny <<a href="mailto:g@28.io" target="_blank">g@28.io</a>> wrote:</div><br></div></div><div><div><div><div dir="ltr">Hi Leo,<div><br></div><div>If the input has no namespace, then I think you can declare the default namespace according to your output (if it is important to you that your output uses it as a default namespace).</div><div><br></div><div>Then there is a workaround to navigate the input with /*:foo/*:bar expressions, where the joker prefix should catch the absence of namespace.</div><div><br></div><div>I hope it helps?</div><div><br></div><div>Kind regards,</div><div>Ghislain</div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 1, 2016 at 10:20 AM, Leo Studer <span dir="ltr"><<a href="mailto:leo.studer@varioweb.ch" target="_blank">leo.studer@varioweb.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Michael<br>
<span><br>
><br>
><br>
> The main difference from the XSLT xpath-default-namespace is that this default applies both to names in path expressions and to names in element constructors, which is inconvenient when the input and output documents are in different namespaces.<br>
><br>
> Michael Kay<br>
> Saxonica<br>
<br>
</span>this is exactly my problem. The XML file has no namespace and the output has a namespace.<br>
<br>
Fist I tried<br>
<br>
        declare namespace null=“”;<br>
<br>
and in the query I wrote something like<br>
<br>
        null:elementName<br>
<br>
Then I get the error that namespace null is not declared….<br>
<br>
The only solution I found is to put a namespace in the XML file (which is not really what I want).<br>
<br>
Is there another way?<br>
<br>
Cheers<br>
<div><div>Leo<br>
_______________________________________________<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" rel="noreferrer" target="_blank">http://x-query.com/mailman/listinfo/talk</a></div></div></blockquote></div><br></div></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><br>_______________________________________________<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" rel="noreferrer" target="_blank">http://x-query.com/mailman/listinfo/talk</a><br></blockquote></div><br></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>_______________________________________________<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><div style="word-wrap:break-word"></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" rel="noreferrer" target="_blank">http://x-query.com/mailman/listinfo/talk</a></blockquote></div>