Christian,

unfortunately I cannot give the answers to your questions. My attempts to find answers in the spec rather quickly failed. Concerning the first case, the many ".."s, supposedly more of them than the base URI has path steps, my feeling is that there is no sensible alternative to resolving the URI to "file:///" (or "file:/" or "file://", I wonder...) - what else could possibly be the intention? Concerning the drive letters, I am not even sure that they are compatible with the spec, because drive letters amount to a multi-root hierarchy (there is nothing above, say, "c:"), and I have the impression that this violates the basic assumptions of the spec. HOWEVER ...

I feel that I shall need to read the spec from start to end very carefully in order to say anything with assurance, due to the subtlety of the subject matter. Now I have the problem that until mid February I am under severe time pressure so that I cannot tackle the task. I propose the following:  I leave the matter alone until then, after which I shall indeed analyze the spec and report the results to you. (In fact I have long since wished to understand URIs completely, so I commit myself to the task with pleasure.) Ok?

Cheers,
Hans-Jürgen




Christian Grün <christian.gruen@gmail.com> schrieb am 9:10 Samstag, 24.Januar 2015:


Hans-Jürgen,

Thanks for the report; I can confirm that the trailing slash is
missing in the result. I noticed it's quite a hassle to implement all
the XQuery URI resolutions in Java, because Java's default classes do
not comply 100% with RFC 3986.

I have added a new GitHub issue [1].

As you seem to have spent some time with the spec, can you possibly
tell me how the following URIs should correctly be resolved? I tried
some XQuery implementations, they all gave me different results...

  declare base-uri "../../../../../../../../../../../..";
  static-base-uri()

  declare base-uri "C:/";
  static-base-uri()

  declare base-uri "C:/..";
  static-base-uri()

Thanks in advance,
Christian

[1] https://github.com/BaseXdb/basex/issues/1062




On Fri, Jan 23, 2015 at 11:09 PM, Hans-Juergen Rennau <hrennau@yahoo.de> wrote:
> Dear BaseX team,
>
> I think there is a bug in the determination of the static base URI in the
> special case that a base URI declaration contains a relative URI equal to or
> starting with "..".
>
> Consider this declaration:
> declare base-uri "..";
>
> The effect should be that relative URIs are resolved against the PARENT
> directory of the directory containing the query.
>
> If the query is located at, say, file:///a/b/c/query.xq, I would expect the
> static base-uri to be /a/b/, so that a URI like "abc.xml" would be resolved
> to file:///a/b/abc.xml.
>
> However, the static base URI as determined by BaseX in this case misses the
> trailing /, it is: file:///a/b
> The effect is that a URI like "abc.xml" would be resolved to
> file:///a/abc.xml
> In other words: URIs are resolved against the "GRAND-PARENT" directory of
> the query.
>
> Final remark: the effect of resolving URIs against the parent directory of
> the query is achieved by the surprising base URI declaration:
>
> declare base-uri ".";
>
> which is not what I would expect.
>
> Conclusion: the way to achieve a resolving of relative URIs against the
> parent directory of the query should be achieved by the base URI declaration
> ".." - and no other value.
>
> Kind regards,
> Hans-Juergen
>
> Full example:
> Query ( file file:///projects/infospace/pcol/test.xq);
>
> declare base-uri "..";
> declare variable $uri external;
>
> string-join((
>          'query-file:      file:///projects/infospace/pcol/test.xq',
>    concat('static-base-uri: ', static-base-uri()),
>    concat('resolve-uri("try.xml")=', resolve-uri("try.xml"))
> ), '&#xA;')
>
> Output:
> query-file:                  file:///projects/infospace/pcol/test.xq
> static-base-uri:          file:///C:/projects/infospace
> resolve-uri("try.xml")=file:/C:/projects/try.xml
>
>