rdfa / librdfa

SAX-based implementation of an RDFa Processor in C
http://rdfa.info/
Other
18 stars 6 forks source link

Why does typeof work only with CURIEs? #8

Open melvincarvalho opened 10 years ago

melvincarvalho commented 10 years ago

I'd like to be able to use full URLs

Tested with rapper

Code reference: https://github.com/rdfa/librdfa/blob/57ca93090fbecea0fea8ec034f1061c0798a4ac9/c/rdfa.c#L646

dlongley commented 10 years ago

If you look at the other code paths, they are all calling rdfa_resolve_curie or rdfa_resolve_curie_list; those functions handle full URLs or CURIEs.

But, regardless, if you drill down into the code you'll get to this bit:

https://github.com/rdfa/librdfa/blob/57ca93090fbecea0fea8ec034f1061c0798a4ac9/c/curie.c#L489

Which will generate a warning for a URL without "://" and an undefined prefix in the context -- but that's merely a warning. Then the code heads down here:

https://github.com/rdfa/librdfa/blob/57ca93090fbecea0fea8ec034f1061c0798a4ac9/c/curie.c#L544

Which will fail the first conditional if you have a colon -- and fall into the second one, which will fail because the parse mode for typeof (CURIE_PARSE_INSTANCEOF_DATATYPE) isn't supported there.

So -- if you're getting a failure with a full URL for typeof, it looks like that might be culprit. I would have expected a full URL to work for typeof as well, but I didn't check the spec.

cc: @msporny

dlongley commented 10 years ago

This should work now. I noticed that the xhtml1-rdfa1.1 test suite doesn't have a typeof example with a full URL -- so that needs updating.

msporny commented 10 years ago

Hey @melvincarvalho - great spot on that bug and @dlongley has added a fix for it.

That said, it's been difficult to keep that library up to date w/ the latest test suite (many more tests have been added to the test suite in a variety of different languages and librdfa doesn't do well with a few of those new tests). Granted, many of the new tests are corner cases, but a failed test is a failed test. I wouldn't depend on rapper to generate proper rdfa output - you will want to cross-check against a library that is more actively maintained (Gregg Kellogg's implementation, for example).

It's a matter of time and priorities. We could fix up librdfa, but it doesn't really buy our company anything since we're planning on dropping all support for RDFa (in favor of JSON-LD).

melvincarvalho commented 10 years ago

Awesome guys! I added a vocab term and rapper then passes. I was just using a standard rapper -g for testing. My normal (boring) way to mark things up is just to use full URLs. Great work on solving this so fast!

dlongley commented 10 years ago

It's a matter of time and priorities. We could fix up librdfa, but it doesn't really buy our company anything since we're planning on dropping all support for RDFa (in favor of JSON-LD).

That being said, it's open source: PRs FTW!