Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml:base is ignored during getUri() #157

Closed
jimsafley opened this issue Nov 1, 2013 · 6 comments
Closed

xml:base is ignored during getUri() #157

jimsafley opened this issue Nov 1, 2013 · 6 comments
Assignees
Labels

Comments

@jimsafley
Copy link

After parsing the SKOS graph using parseFile(), xml:base in the root element is being ignored, so when I use getUri() on a resource, it returns the local path to the file. For example:

echo $resource->getUri();
// returns: file:///path/to/skos.rdf#Concept
// instead of: http://www.w3.org/2004/02/skos/core#Concept

The same goes for BIBO.

@njh
Copy link
Collaborator

njh commented Nov 4, 2013

This is a bug with the RDF/XML parser, rather than with the getUri() method.

@indeyets indeyets added the bug label May 19, 2014
@indeyets
Copy link
Contributor

@njh it's a bit more complicated, actually. It looks like we don't have a way to change graph's baseUri from the parser. So, either we need to introduce setUri method on EasyRdf_Graph or we need to change parsers protocol so that they create a new graph object instead of using the one given to them as parameter.

I think that second option is better. And even more: it should return object of new EasyRdf_Dataset class, which will give us access to one or several EasyRdf_Graph objects. This way it will be possible to properly handle formats which store several graphs in one document (JsonLD, TriG, …)

@indeyets
Copy link
Contributor

sorry… I wrote some nonsense

base-uri is not related to the URI of graph, so, yup, this is a bug in parser

@zerocrates
Copy link
Contributor

Am I right in reading the XML parser code in startState0 as it basically skipping over the root node (as long as it's an <rdf:RDF>), so an xml:base there never really gets looked at?

The other "levels" all try to account for parent XML base settings, but as far as I can tell the one from the root node never gets saved. A simple hack to try to save that data in startState0 doesn't work, as other parts of the code assume everything in the $sStack has a type/value.

@zerocrates
Copy link
Contributor

My second stab at a simple solution had better results.

This is the cleanest way I could think of to accomplish this in the existing code, and should respect the root-level xml:base when present while also still using the passed-in base if the root xml:base is absent or a relative URI.

I'm not sure the strategy of modifying $this->xBase is a way you'd like to go, so I didn't make a pull request.

@indeyets indeyets self-assigned this Jul 22, 2014
indeyets added a commit that referenced this issue Jul 22, 2014
indeyets pushed a commit that referenced this issue Jul 22, 2014
@indeyets
Copy link
Contributor

@zerocrates applied your fix. thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants