<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">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 class=""><br class=""></div><div class="">(a) Use *:name in path expressions (which may over-select)</div><div class=""><br class=""></div><div class="">(b) Bind a prefix p to the input namespace and use p:name in path expressions (which is tedious)</div><div class=""><br class=""></div><div class="">(c) Use Q{}name in path expressions (which is 3.0 only, and tedious)</div><div class=""><br class=""></div><div class="">(d) Use computed element constructors, and binding the default namespace to the input namespace</div><div class=""><br class=""></div><div class="">(e) Use XSLT 2.0 with the default-xpath-namespace attribute.</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Michael Kay</div><div class="">Saxonica</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 1 Jun 2016, at 10:44, Ghislain Fourny <<a href="mailto:g@28.io" class="">g@28.io</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Leo,<div class=""><br class=""></div><div class="">I'm glad!</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><a href="https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-node-name" class="">https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-node-name</a></div><div class="">and</div><div class=""><a href="https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-namespace-uri-from-QName" class="">https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-namespace-uri-from-QName</a><br class=""></div><div class=""><br class=""></div><div class="">You can test for the absence of namespace easily.</div><div class=""><br class=""></div><div class="">There may be even shorter tricks, I wouldn't be surprised if Mike got something out of his magic hat :-)</div><div class=""><br class=""></div><div class="">Kind regards,</div><div class="">Ghislain</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jun 1, 2016 at 11:38 AM, Leo Studer <span dir="ltr" class=""><<a href="mailto:leo.studer@varioweb.ch" target="_blank" class="">leo.studer@varioweb.ch</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Ghislain<div class=""><br class=""></div><div class="">thank you for your input, which solves my problem.</div><div class=""><br class=""></div><div class="">However, if I have the same element name in two different namespaces, then the use of a wildcard namespace makes problems ;-).</div><div class=""><br class=""></div><div class="">Always</div><div class="">Leo</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On 01 Jun 2016, at 11:06, Ghislain Fourny <<a href="mailto:g@28.io" target="_blank" class="">g@28.io</a>> wrote:</div><br class=""></div></div><div class=""><div class=""><div class="h5"><div dir="ltr" class="">Hi Leo,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">I hope it helps?</div><div class=""><br class=""></div><div class="">Kind regards,</div><div class="">Ghislain</div><div class=""> </div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jun 1, 2016 at 10:20 AM, Leo Studer <span dir="ltr" class=""><<a href="mailto:leo.studer@varioweb.ch" target="_blank" class="">leo.studer@varioweb.ch</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Michael<br class="">
<span class=""><br class="">
><br class="">
><br class="">
> 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 class="">
><br class="">
> Michael Kay<br class="">
> Saxonica<br class="">
<br class="">
</span>this is exactly my problem. The XML file has no namespace and the output has a namespace.<br class="">
<br class="">
Fist I tried<br class="">
<br class="">
        declare namespace null=“”;<br class="">
<br class="">
and in the query I wrote something like<br class="">
<br class="">
        null:elementName<br class="">
<br class="">
Then I get the error that namespace null is not declared….<br class="">
<br class="">
The only solution I found is to put a namespace in the XML file (which is not really what I want).<br class="">
<br class="">
Is there another way?<br class="">
<br class="">
Cheers<br class="">
<div class=""><div class="">Leo<br class="">
_______________________________________________<br class="">
<a href="mailto:talk@x-query.com" target="_blank" class="">talk@x-query.com</a><br class="">
<a href="http://x-query.com/mailman/listinfo/talk" rel="noreferrer" target="_blank" class="">http://x-query.com/mailman/listinfo/talk</a></div></div></blockquote></div><br class=""></div></div></div>
_______________________________________________<br class=""><a href="mailto:talk@x-query.com" target="_blank" class="">talk@x-query.com</a><br class=""><a href="http://x-query.com/mailman/listinfo/talk" target="_blank" class="">http://x-query.com/mailman/listinfo/talk</a></div></blockquote></div><br class=""></div></div><br class="">_______________________________________________<br class="">
<a href="mailto:talk@x-query.com" class="">talk@x-query.com</a><br class="">
<a href="http://x-query.com/mailman/listinfo/talk" rel="noreferrer" target="_blank" class="">http://x-query.com/mailman/listinfo/talk</a><br class=""></blockquote></div><br class=""></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=""></body></html>