Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: niklasl/clj-rdfa
base: 9ce2c122e3
head fork: niklasl/clj-rdfa
compare: 50e0b7dedd
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 31 additions and 18 deletions.
  1. +26 −16 src/rdfa/core.clj
  2. +5 −2 src/rdfa/profiles.clj
42 src/rdfa/core.clj
@@ -144,7 +144,7 @@
:property (attr "property")
:rel (attr "rel")
:rev (attr "rev")
- :resource (or (attr "resource") (attr "href") (attr "src"))
+ :resources (remove nil? [(attr "resource") (attr "href") (attr "src")])
:typeof (attr "typeof")
:inlist (attr "inlist")
:lang (or (attr "xml:lang") (attr "lang"))
@@ -168,20 +168,27 @@
+(defn get-resolved-resource [env candidates]
+ ; TODO: collect all errs?
+ (let [resolved (map #(to-curie-or-iri env %1) candidates)]
+ (or (first (filter #(first %1) resolved))
+ (first resolved))))
(defn get-subject [env data]
(let [new-pred (or (data :rel) (data :rev) (data :property))
- about (data :about)
- resource (data :resource)
- use-resource (and (not about)
+ about-and-err (if-let [about (data :about)]
+ (to-curie-or-iri env about))
+ resource-and-err (get-resolved-resource env (data :resources))
+ use-resource (and (not (first about-and-err))
(or (and (data :property)
(or (data :content) (data :datatype)))
(not new-pred)))
- subject (or (if use-resource resource about)
- (if (data :is-root) ""))]
+ subject (or (if use-resource resource-and-err about-and-err)
+ (if (data :is-root) [nil nil]))]
- subject (to-curie-or-iri env subject)
- (and (data :typeof) (not new-pred) (not resource))
- [(next-bnode) nil])))
+ subject subject
+ (and (data :typeof) (not new-pred)
+ (not (first resource-and-err))) [(next-bnode) nil])))
(defn get-literal [env data]
(let [el (data :element)
@@ -189,7 +196,8 @@
(and (data :datatype)
(not (or (data :rel) (data :rev))))
- (not (or (data :resource)
+ (or (data :rel) (data :rev))
+ (not (or (not-empty (data :resources))
(and (data :typeof)
(not (data :about)))))))
[datatype dt-err] (if-let [dt (not-empty (data :datatype))]
@@ -208,13 +216,15 @@
(let [link (or (data :rel) (data :rev))
prop (data :property)
typeof (data :typeof)
- resource (data :resource)]
+ resources (data :resources)]
(and (not link) prop
- (or (data :content) (data :datatype))) nil
- resource (to-curie-or-iri env resource)
- (or (and link (not (data :about)) typeof)
- (and prop typeof)) [(next-bnode) nil])))
+ (or (data :content) (data :datatype)))
+ nil
+ (not-empty resources)
+ (get-resolved-resource env resources)
+ (or (and link (not (data :about)) typeof) (and prop typeof))
+ [(next-bnode) nil])))
(defn get-props-rels-revs-lists [env data]
(let [inlist (data :inlist)
@@ -245,7 +255,7 @@
(defn get-hanging [data]
(if (and (or (data :rel) (data :rev))
- (not (data :resource))
+ (empty? (data :resources))
(or (data :about) (not (data :typeof)))
(not (data :inlist)))
7 src/rdfa/profiles.clj
@@ -115,6 +115,7 @@
(defn extended-data [env data]
(let [profile (env :profile)
+ resources (data :resources)
el (data :element)
tag (dom/get-name el)
datetime (or (dom/get-attr el "datetime")
@@ -124,7 +125,7 @@
:about (or (data :about)
(if (and (or (= tag "head") (= tag "body"))
- (not (data :resource)))
+ (empty? resources))
(:id (env :parent-object))))
:lang (or (data :lang) (dom/get-attr el "lang"))
:content (or datetime
@@ -132,5 +133,7 @@
(data :content))
:datatype (or (data :datatype)
(get-datetime-datatype datetime))
- :resource (or (data :resource) (dom/get-attr el "data")))))
+ :resources (if-let [data-res (dom/get-attr el "data")]
+ (conj resources data-res)
+ resources))))

No commit comments for this range

Something went wrong with that request. Please try again.