Skip to content

patch out xml code to fix dependency conflict issues #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(defproject clj-tagsoup "0.3.0"
;;; Hacked to run with more modern data.xml
(defproject clj-tagsoup "0.4.0"
:description "A HTML parser for Clojure."
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/data.xml "0.0.8"]
:dependencies [[org.clojure/clojure "1.12.0"]
#_ [org.clojure/data.xml "0.0.8"]
[org.clojars.nathell/tagsoup "1.2.1"]
[net.java.dev.stax-utils/stax-utils "20040917"]])
#_ [net.java.dev.stax-utils/stax-utils "20040917"]])
10 changes: 7 additions & 3 deletions src/pl/danieljanus/tagsoup.clj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
(ns pl.danieljanus.tagsoup
(:require [clojure.zip :as zip]
[clojure.xml :as xml]
[clojure.data.xml :as lazy-xml])
#_ [clojure.data.xml :as lazy-xml])
(:import (org.ccil.cowan.tagsoup Parser)
(java.net URI URL MalformedURLException Socket)
(java.io InputStream File FileInputStream ByteArrayInputStream BufferedInputStream InputStreamReader BufferedReader)
(javax.xml.stream XMLEventReader XMLStreamConstants)
#_ (javax.xml.stream XMLEventReader XMLStreamConstants)
(javax.xml.stream.events Attribute StartElement XMLEvent)
(javanet.staxutils ContentHandlerToXMLEventWriter XMLEventPipe)
#_ (javanet.staxutils ContentHandlerToXMLEventWriter XMLEventPipe)
(org.xml.sax Attributes InputSource)))

(defn- attributes-map
Expand Down Expand Up @@ -181,6 +181,7 @@ in the same format as clojure.xml/parse."
[^StartElement x]
(keyword (.getLocalPart (.getName x))))

#_
(defn eventize
"Convert a javax.xml.stream.events.XMLEvent to a clojure.data.xml.Event."
[^XMLEvent ev]
Expand All @@ -199,11 +200,13 @@ in the same format as clojure.xml/parse."
(lazy-xml/event :characters nil nil (.getData ev))
nil))

#_
(defn event-seq
"Like clojure.data.xml/pull-seq, but works on XMLEventReaders instead of stream readers."
[^XMLEventReader ereader]
(keep eventize (iterator-seq ereader)))

#_
(defn cancellable-lazy-parse-xml
[input]
(let [pipe (XMLEventPipe.)
Expand All @@ -217,6 +220,7 @@ in the same format as clojure.xml/parse."
(finally (.close ewriter))))
:data (event-seq ereader)}))

#_
(defn lazy-parse-xml
"Parses the XML using TagSoup and as result, returns a lazy
sequence of elements in the same format as
Expand Down