-
Notifications
You must be signed in to change notification settings - Fork 6
Description
This part of the code supports RDFa property copying when property="rdfa:copy" on the link element:
rdfa-streaming-parser.js/lib/RdfaParser.ts
Lines 187 to 199 in cea018b
| // 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; | |
| } |
rdfa-streaming-parser.js/lib/RdfaParser.ts
Lines 743 to 751 in cea018b
| // 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.