pyLODE icon indicating copy to clipboard operation
pyLODE copied to clipboard

Creating HTML id based on entity itself and not the rdfs:label

Open Pzangeneh opened this issue 5 years ago • 8 comments

Is it possible to somehow create HTML id as the actual entity IRI instead of the rdfs:label.

For example, here requesting the actual the term IRI is "hasPrerequisiteDecisionEvent" but it returns nothing since the HTML id is created after the rdfs:label as "#prerequisiteDecisionEvent"

https://raw.githack.com/agldwg/agrif-ont/master/agrif.html#prerequisiteDecisionEvent

Also, Thanks for the great tool!

Pzangeneh avatar Jul 06 '20 22:07 Pzangeneh

This has always been a tricky issue. I think pyLODE should generate fragment URIs from the data objects but I've just not quite worked out how to do this faithfully in cases when classes and properties might have clashing fragment parts (e.g. an ontology that has a property and a class with the same token when converted to lowercase, as PROV does with class Activity & property activity but PROV solves it manually: https://www.w3.org/TR/prov-o/#Activity v. https://www.w3.org/TR/prov-o/#p_activity.

I've seen duplicate class/property names where an ontology imports, and then refines, class/property names, e.g. using something like GeoSPARQL's Feature class and then declaring a sub-class also called Feature. The clash is unavoidable since the fragment URIs aren't context-aware (i.e. don't know the rest of the namespace URIs that distinguish geo:Feature from my:Feature.

I may try and solve this, having written the above, by adding a namespace prefix to any imported duplicates (e.g. #feature & #geo:feature for the Feature example above) and by prefixing a property with p_ as PROV does, if there's a clash.

nicholascar avatar Aug 24 '20 11:08 nicholascar

Fragment identifiers should not be used as ‘Real’ identifiers by themselves, for the reasons you identify. If you’re going to show them in some functional role, all the identifiers that have a different namespace should be prefaced by a ‘prefix:`string.

graybeal avatar Aug 24 '20 17:08 graybeal

Hey, I just want to check the status of this. This is particularly relevant for use cases where the IRI use numeric identifiers. But generally, there often is a discrepancy between the label and the IRI - right now many of my redirects to pylode generated docs don't work because of it!

matentzn avatar Oct 19 '22 09:10 matentzn

It would be great, if this could be solved.

Some comments on the intended solution:

  • Fragments are case sensitive: Having #Activity and #activity in one document should be fine.
  • But there will be an issue with punning (resource has two or more types (class, instance, property, …) at the same time). In this case browsers would always jump to the first occurrence. This is especially a problem for the TOC. One could work around this by additionally adding a second anchor with a type prefix or suffix which would be used in the TOC (if necessary) and could also be used at the type-specific presentations itself to link the other type-specific presentations. But note that e.g. #p_activity might also be a used fragment in the ontology. It is not possible to completely exclude this case, but it might be more unlikely, if you use something like the percent encoded full URL of the resource + prefix or suffix.
  • The same problem could occur with the resources of other namespaces. E.g. '#geo:Feature' could be a valid fragment used in the ontology. Also in this case, it might be safer to use the percent-encoded full URL.

For reference: RFC3986 Appendix A: Collected ABNF for URI

jmkeil avatar Jun 29 '23 21:06 jmkeil

The current WIDOCO generates fragments like

<li>
    <a href="#https://w3id.org/example/voc_00092" title="https://w3id.org/example/voc_00092"> my concept's pref. label</a>
</li>
....
<div id="https://w3id.org/example/voc_00092">
      <h3> my concept's pref. label </h3>
</div>

which solves the ambiguity by using the PID. Wouldn't this work for pyLODE, too? - But maybe I am misunderstanding the issue.

dalito avatar Jul 01 '23 21:07 dalito

The current WIDOCO generates fragments like

<li>
    <a href="#https://w3id.org/example/voc_00092" title="https://w3id.org/example/voc_00092"> my concept's pref. label</a>
</li>
....
<div id="https://w3id.org/example/voc_00092">
      <h3> my concept's pref. label </h3>
</div>

which solves the ambiguity by using the PID. Wouldn't this work for pyLODE, too? - But maybe I am misunderstanding the issue.

This example is about Slash-Namespaces, other posts here were concerned with Hash-Namespaces.

In my point of view the requirements are:

  1. The documentation must be compatible with content negotiation, dereferencing and versioning for the own namespace. (see Cool URIs for the Semantic Web.
  2. Resources from other namespaces (if included) must be interlinkable (e.g. in the TOC) without id collision.
  3. Resources from own namespace affected by punning must be dereferencable from outside the documentation and unambiguous (regarding type) interlinkabel from inside the documentation (e.g. in the TOC).

For Hash-Namespaces @dalito example fulfills 1., as one can configure a sufficient redirecting, like https://w3id.org/example/voc_00092 --303--> https://w3id.org/example/doc#https://w3id.org/example/voc_00092. But for Slash-Namespaces, @dalito example would not be sufficient, as one would need an unnecessary redirect. E.g. https://w3id.org/example#voc_00092 --302--> https://w3id.org/example#https://w3id.org/example%23voc_00092 instead of just using the given anchor voc_00092.

jmkeil avatar Jul 03 '23 07:07 jmkeil

@jmkeil - Thanks for the explanation and for pointing me to the cool URI document. It was helpful to read it again. What could a solution look like? Do you think that pyLODE needs an option to generate two styles of ids in html?

dalito avatar Jul 04 '23 06:07 dalito

Do you think that pyLODE needs an option to generate two styles of ids in html?

I don't see need for manual configuration here. Given an IRI and the OntologyIRI, one can automatically generate the proper id (anchor name). It just needs a tiny case decision (examples assume OntologyIRI http://example.org/ontology):

  • IRI starts with OntologyIRI?
    • Yes: IRI contains #?
      • Yes: ID is fragment of IRI
        • e.g. IRI: http://example.org/ontology#voc_00092, ID: voc_00092, Link: http://example.org/ontology#voc_00092
      • No: ID starts with first path segment after OntologyIRI (note: OntologyIRI might or might not contain the /)
        • e.g. for IRI: http://example.org/ontology/voc_00092, ID: voc_00092, Link: http://example.org/ontology#voc_00092
        • Note: an HTTP redirect is needed for proper dereferencing: http://example.org/ontology/voc_00092 --303--> http://example.org/ontology#voc_00092)
    • No: ID is full IRI with escaped #
      • e.g. for IRI: http://example.org/other#voc_00092, ID: http://example.org/other%23voc_00092, Link: http://example.org/ontology#http://example.org/other%23voc_00092
      • e.g. for IRI: http://example.org/other/voc_00092, ID: http://example.org/other/voc_00092, Link: http://example.org/ontology#http://example.org/other/voc_00092

jmkeil avatar Jul 04 '23 07:07 jmkeil