   (apply str (map (fn [child]
                     (str
                      (if (:rev (first child))
-                       (str "?a"
+                       (str "?"
                             (:id (first child)) " "
-                            "<"(:pred (first child)) "> ?a"
-                            (:id node) " .\n" )
-                       (str "?a"
-                            (:id node) " "
-                            "<"(:pred (first child)) "> ?a"
+                            "<"(:pred (first child)) "> ?"
+                            (if (:path node) "p" "") (:id node) " .\n" )
+                       (str "?"
+                            (if (:path node) "p" "") (:id node) " "
+                            "<"(:pred (first child)) "> ?"
                             (:id (first child)) " .\n" ))
                      (render-graph child) "\n"))
                   children)))
 
-
+(defn query-map [query]
+  (let [vals (q-map query)
+        qm (new QuerySolutionMap)]
+    (doall (map (fn [key] (.add qm (str key) (res (get vals key)))) (keys vals)))
+    qm))
 (defn build-query [inf uri]
-  (let [query  [{:id "root"} (qbuild inf uri)]]
-    (.execConstruct
-     (. QueryExecutionFactory sparqlService
-        "http://localhost:8000/sparql/"
-        (str "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+  (let [query  (qbuild inf (parse-uri uri))
+        qm (query-map query)
+        s (str "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 PREFIX ont: <http://logangilmour.com/example-ontology#>
 


(def broadcast-channel (permanent-channel))
(def edit (editor (to-model example-view)))

(defn store [message]
  (edit (:uri message) (res (:binding message)) (:data message)))

(defn chat-handler [ch handshake]
  (receive ch
           (fn [input]
             ;;(let jc [(map* decode-json ch)])
             (siphon (map* encode-json->string (map* store (map* decode-json ch))) broadcast-channel)
             (siphon broadcast-channel ch)
             )))


(defroutes main-routes
  (GET "/async/" [] (wrap-aleph-handler chat-handler))
  (GET "/" []
       (page ((serializer (to-model example-view)) (build-query (to-model example-view) nil) (res "http://logangilmour.com/example-ontology#person"))))
  (route/resources "/")
  (route/not-found "Page not found"))


                relation-getter (fn [data resource] (relator statement data resource))
                child-func (:value bindable)
                parent-func (:resource bindable)] ;; extraneous function getting]
            (fn [data child resource url built-url]

              (let [related (if child   ;; get sub-resources (a single one if partial rendering)
                              (seq [child])
