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

RDFa parse issue if vocab not defined with training slash #53

Open
davidcockbill opened this issue Sep 20, 2019 · 0 comments
Open

RDFa parse issue if vocab not defined with training slash #53

davidcockbill opened this issue Sep 20, 2019 · 0 comments

Comments

@davidcockbill
Copy link

Originally raised against ANY23: ANY23-428

If a RDFa vocab URL is missing a trailing forward slash, then properties and types are not expanded correctly.
For example:

<ol vocab="https://schema.org" typeof="BreadcrumbList">

rather than:

<ol vocab="https://schema.org/" typeof="BreadcrumbList">

produces properties and types that look as follows:

<http://schema.orgBreadcrumbList> .

The fix, I believe, needs to be in "rdfa/src/main/java/org/semarglproject/rdf/rdfa/Vocabulary.java".
I changed the resolveTerm() method as follows:

  String resolveTerm(final String term) {
   	final String separator = (url.endsWith("/") || url.endsWith("#")) ? "" : "/";
       final String termUri = url + separator + term;
       if (terms == null && RIUtils.isAbsoluteIri(termUri) || terms != null && terms.contains(termUri)) {
           return termUri;
       }
       return null;
   }

This seems to fix the issue; and the semarglproject unit tests pass. However, I'm not too sure if there are other issues with this, and whether we should use a URI library for creating the url rather than my crude string parsing.

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

No branches or pull requests

1 participant