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

Implement property copying #33

Closed
csarven opened this issue Mar 4, 2024 · 6 comments
Closed

Implement property copying #33

csarven opened this issue Mar 4, 2024 · 6 comments

Comments

@csarven
Copy link

csarven commented Mar 4, 2024

https://www.w3.org/TR/rdfa-in-html/#property-copying

See also: https://www.w3.org/ns/rdfa

@gkellogg
Copy link
Member

gkellogg commented Mar 4, 2024

Property Copying is implemented as part of Vocabulary Expansion, see note in the README.

See the test for this

describe :copy_properties do
{
"simple" => {
default: %q(
<http://example/> rdfa:copy _:ref .
_:ref a rdfa:Pattern; rdf:value "Pattern" .
),
query: %q(<http://example/> rdf:value "Pattern" .)
},
"chaining ref" => {
default: %q(
<http://example/> rdfa:copy _:ref .
_:ref a rdfa:Pattern;
rdf:value "Pattern";
rdfa:copy _:ref2 .
_:ref2 a rdfa:Pattern;
rdf:value "Pattern2" .
),
query: %q(<http://example/> rdf:value "Pattern", "Pattern2" .)
}
}.each do |test, elements|
it test do
mt = ExpansionTester.new(test)
query = mt.load(elements)
mt.copy_properties(mt.repo)
expect(mt.graph).to pass_query(query, mt)
end
end
end

@csarven
Copy link
Author

csarven commented Mar 4, 2024

Ah pardon me. That's interesting. Great.

I think I was misled by the Ruby Distiller service. I'm noticing something slightly different output depending on output format. Perhaps you can have a look at what I may have missed. Take the RDFa from Example 7 at https://www.w3.org/TR/rdfa-in-html/#property-copying and compare the following:

  1. Output format: unselected (assuming defaulting to N-Triples)
  2. Output: Turtle

Option 1 gives result:

_:g463380 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/MusicEvent> .
_:g463380 <http://schema.org/name> "Muse" .
_:g463380 <http://schema.org/startDate> "2013-03-03"^^<http://www.w3.org/2001/XMLSchema#date> .
_:g463400 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/MusicEvent> .
_:g463400 <http://schema.org/name> "Muse" .
_:g463400 <http://schema.org/startDate> "2013-03-07"^^<http://www.w3.org/2001/XMLSchema#date> .

Option 2 gives result:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfa: <http://www.w3.org/ns/rdfa#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<> rdfa:usesVocabulary schema: .

 [
    a schema:MusicEvent;
    schema:image <Muse1.jpg>,
      <Muse2.jpg>,
      <Muse3.jpg>;
    schema:location <#united>;
    schema:name "Muse";
    schema:startDate "2013-03-03"^^xsd:date
  ] .

 [
    a schema:MusicEvent;
    schema:image <Muse1.jpg>,
      <Muse2.jpg>,
      <Muse3.jpg>;
    schema:location <#target>;
    schema:name "Muse";
    schema:startDate "2013-03-07"^^xsd:date
  ] .

Note in particular the image statements included in Option 2 but not Option 1.

@gkellogg
Copy link
Member

gkellogg commented Mar 4, 2024

The CLI has a --vocab-expansion option when the input format is set to rdfa. The CLI is used to implement the distiller, and an option such as "vocab expansion" (as well as "host language" and "rdfagraph") should show up in the distiller UI, but don't seem to be there, which I'll need to look into.

Running Example 6 using the command rdf serialize --input-format rdfa --vocab-expansion --output-format ttl example-files/property-copying.html gives the following output:

@prefix dcmitype: <http://purl.org/dc/dcmitype/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfa: <http://www.w3.org/ns/rdfa#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<example-files/property-copying.html> rdfa:usesVocabulary schema: .

 [
    a schema:MusicEvent,
      schema:Event,
      schema:Thing,
      dcmitype:Event;
    rdfs:label "Muse";
    dcterms:title "Muse";
    schema:image <example-files/Muse1.jpg>,
      <example-files/Muse2.jpg>,
      <example-files/Muse3.jpg>;
    schema:location <example-files/property-copying.html#united>;
    schema:name "Muse";
    schema:startDate "2013-03-03"^^xsd:date
  ] .

 [
    a schema:MusicEvent,
      schema:Event,
      schema:Thing,
      dcmitype:Event;
    rdfs:label "Muse";
    dcterms:title "Muse";
    schema:image <example-files/Muse1.jpg>,
      <example-files/Muse2.jpg>,
      <example-files/Muse3.jpg>;
    schema:location <example-files/property-copying.html#target>;
    schema:name "Muse";
    schema:startDate "2013-03-07"^^xsd:date
  ] .

@gkellogg
Copy link
Member

gkellogg commented Mar 5, 2024

@csarven let me know if the distillers working for you now.

@csarven
Copy link
Author

csarven commented Mar 5, 2024

When output format is unselected, those image properties are missing. Ditto when N-Triples or JSON-LD for example are selected for output, the properties are missing. For the Turtle output, the properties are present.

Aside: just noticing the host language option now. Is that very recent? Cool!

@gkellogg
Copy link
Member

gkellogg commented Mar 5, 2024

When the output format is unselected, it will typically use N-Triples. N-Triples cannot emit relative IRIs; to get the output, you need to add a base IRI to the Document URL field.

The "host language" option, as well as the "rdfagraph" options have always been available through the CLI, but didn't show because the option didn't provide a control to use for display.

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

2 participants