Hi,

I am trying to navigate an XML structure using the 
clojure.contrib.zip-filter.xml library, but for some strange reason I 
receive the following exception:

ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IFn  
clojure.zip/node (zip.clj:67)

Here is an example which demonstrates the problem:

(require '[clojure.xml :as x]
         '[clojure.zip :as z]
         '[clojure.contrib.zip-filter.xml :as zf])

(def myxmlstr 
"<Root><Parent><Child><Value>1</Value></Child></Parent></Root>")

(defn parse-str [^String s]
  (z/xml-zip (x/parse (java.io.ByteArrayInputStream. (.getBytes s)))))

(zf/xml-> (parse-str myxmlstr) :Parent :Child :Value zf/text)              
; returns ("1")

(zf/xml-> (zf/xml-> (parse-str myxmlstr) :Parent :Child :Value) zf/text)   
; throws exception

As the exception message reveals the problem comes from the clojure.zip/node
:

(defn node
  "Returns the node at loc"
  {:added "1.0"}
  [loc] (loc 0))


Is there a reason why (loc 0) was used instead of (first loc)? Only 
performance? I also noticed that most of the zipper navigation functions in 
clojure.zip return PersistentVector, but the xml-> from contrib returns 
LazySeq.

I am not sure what could be the solution for this problem, but I definitely 
don't expect the above example to throw an exception.

Regards,
Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to