CellML Discussion List

Text archives Help


[cellml-discussion] API with relative URLs


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-discussion] API with relative URLs
  • Date: Mon, 09 Oct 2006 16:55:18 +1300

David Nickerson wrote:
>> What is your xml:base URL on the importing model (this is set
>> automatically to the absolute URI being loaded by the API if you do a
>> synchronous load, and it isn't already set)? Obviously the process of
>> resolving a relative URL by an absolute URI is getting the wrong
>> final result.
>
> now I'm confused. I have no xml:base explicitly set anywhere. Should
> I? I just tried running it again but specifying
> file:///home/biendp/data/cellml/models/1962_noble/experiments/free-running.xml
>
> as the input model and it all worked fine...I guess thats starting to
> make sense.
>
> If I've got this right, I don't put any xml:base inside my models to
> keep them independent of the file system and then when I want to load
> the model I need to specify the full absolute URL for the top level
> model so that all the relative URLs get resolved correctly.
Thats right. The xml:base gets put in by the CellML API, to the absolute
URL of the model it is loading. However, it treats all input URLs as if
they were absolute (that is, it was never supposed to support relative
URIs into the API, because that doesn't really make sense, as it isn't
clear what it should be relative to). The current implementation just
passes the URL to libxml2, which will treat relative URLs as relative to
the Unix current working directory of the process in which the API is
running. However, the CellML API code which sets xml:base doesn't
support this, and ends up putting the relative URL into xml:base (this
is bad, since only absolute URLs are supposed to go in there, and so it
causes the problems you are seeing).

It is arguable as to whether this is a bug or a problem in the invocation:
1) The CellML API is supposed to be able to work transparently as either
a server or locally. Allowing process state such as the current working
directory to affect the behaviour seems wrong under this paradigm (e.g.
you could write code which called chdir between calls, but this would
stop working if you switched to using CORBA). Since this may be the
first model loaded through the API, we have no other way to know what
the caller intends if they give a relative path.
2) The current API interface doesn't address the possibility that the
loaded URL might be relative, although it doesn't rule it out either.
When I documentation for the url parameter, I intended 'The absolute URL
from which to load', and so I think it should probably be updated to say
that.
3) It would make sense for the command line tools like CellML2C and
RunCellML to take relative URLs, but it would probably be better for
them to translate to an absolute URL before passing to the CellML API,
since they know what absolute URL they would like to resolve against.
4) Perhaps the CellML API should throw an exception if it receives a
relative URL, so that these problems get caught sooner?

Best regards,
Andrew





Archive powered by MHonArc 2.6.18.

Top of page