Skip to content

Support initiating patterns on rdfa:copy when attribute is rel #64

Open
@csarven

Description

@csarven

This part of the code supports RDFa property copying when property="rdfa:copy" on the link element:

// Instantiate patterns on rdfa:copy
if (attributes.property === 'rdfa:copy') {
const copyTargetPatternId: string = attributes.resource || attributes.href || attributes.src;
if (this.rdfaPatterns[copyTargetPatternId]) {
this.emitPatternCopy(parentTag, this.rdfaPatterns[copyTargetPatternId], copyTargetPatternId);
} else {
if (!this.pendingRdfaPatternCopies[copyTargetPatternId]) {
this.pendingRdfaPatternCopies[copyTargetPatternId] = [];
}
this.pendingRdfaPatternCopies[copyTargetPatternId].push(parentTag);
}
return;
}

// Emit all unreferenced copy links
for (const patternId in this.pendingRdfaPatternCopies) {
for (const parentTag of this.pendingRdfaPatternCopies[patternId]) {
this.activeTagStack.push(parentTag);
this.onTagOpen('link', { property: 'rdfa:copy', href: patternId });
this.onTagClose();
this.activeTagStack.pop();
}
}

The RDFa in HTML specification does not limit property copying ( https://www.w3.org/TR/rdfa-in-html/#implementing-property-copying ) to a particular element (HTML/SVG tag) or the property attribute, and so rel="rdfa:copy" on any element should also be possible.

(A simple usage is human-visible <a href="#foo" rel="rdfa:copy">foo</a> -- yes, it is possible to achieve the equivalent with <a href="" property="" but that's beside the point.)

I've also tested with http://rdf.greggkellogg.net/distiller and https://librdf.org/raptor/ , and they seem to give the expected result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions