HRON-Path is a standard for accessing values within HRON documents.
("urn:isbn:978-1891024634") {
title: "Andy Warhol Prints: A Catalogue Raisonné 1962-1987",
edition: "4th Revised, Expanded Edition (April 2, 2003)",
publisher: <href: "https://www.wikidata.org/wiki/Q5283109",
type: "https://schema.org/Organization">,
dimensions: "9.8 x 1.5 x 11.8 inches",
weight: "5.4 pounds",
authors: [
<href: "https://www.wikidata.org/wiki/Q365129",
type: "https://schema.org/Person", value: "Jörg Schellmann">,
<href: "https://www.wikidata.org/wiki/Q18386358",
type: "https://schema.org/Person", value: "Arthur Danto">,
<href: "urn:person:Donna deSalvo">,
<href: "urn:person:Claudia Defendi">,
("https://www.wikidata.org/wiki/Q5603", type: "https://schema.org/Person") {
name: "Andy Warhol"
}
]
}
Loading the document with the JavaScript statement var book = Heron.load(doc)
results in an object that may be queried with a path language.
book('title') // "Andy Warhol Prints: A Catalogue Raisonné 1962-1987"
Note that a hyperlink with a value
parameter can evaluate to the specified value.
If a HRON path requests a property that is unknown for the hyperlink value,
a network lookup is triggered, returning a promise object.
book('author[0]') // "Jörg Schellmann"
book('author[0][birth_date]') // <href: "https://www.wikidata.org/wiki/Q365129">
Array path operations:
Operator | Description |
---|---|
* |
Wildcard; selects all elements of an array |
<int> |
Array offset; can be negative for reverse indexing |
<int>(,<int>)* |
Array index list; selects each of the indexed items in order |
<int>:<int> |
Array slice operator |
Object path operators:
Operator | Description |
---|---|
.. |
Deep search; scans each property of an object |
Examples:
Selector | Explanation |
---|---|
books('*[authors[..][name]="Liam Gillick"]') |
Returns the list of books whose author name equals "Liam Gillick" |
books('*[title,authors]') |
Returns a list of objects containing only the title and authors properties from each book |
books('authors[..]<*>') |
Returns a list of objects ... |
books('<type="https://schema.org/Person">') |
Returns a list of all hyperlinks that have the type specified by the semantic schema at https://schema.org/Person |