how do I debug a cryptic XML error?

Skip to first unread message


Feb 15, 2022, 7:50:12 PMFeb 15
to Clojure
So, I went to the government NVD website:

I downloaded the CPE Dictionary and unpacked it. It looks like standard XML. 

I copy and paste the standard XML example given on the Clojure XML documentation page:

 cpe-dictionary (-> "official-cpe-dictionary_v2.3.xml" io/resource io/file clj-xml/parse zip/xml-zip)

I get:

clojure.xml/startparse-sax                            xml.clj:  76                                                            ...  

       jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke  43

           jdk.internal.reflect.NativeMethodAccessorImpl.invoke  77

          jdk.internal.reflect.NativeMethodAccessorImpl.invoke0        317


I'm wondering, how do I figure out what is wrong here? I'm going to assume the government is offering reasonably standard XML, so where would the problem arise? How do I figure out a way around this? 

The CPE dictionary is 386 megabytes so I can't share the hold file here, but when I run "head" on it, the beginning looks like this:

<?xml version='1.0' encoding='UTF-8'?>

<cpe-list xmlns:config="" xmlns="" xmlns:xsi="" xmlns:scap-core="" xmlns:cpe-23="" xmlns:ns6="" xmlns:meta="" xsi:schemaLocation="">


    <product_name>National Vulnerability Database (NVD)</product_name>





  <cpe-item name="cpe:/a:%240.99_kindle_books_project:%240.99_kindle_books:6::~~~android~~">

    <title xml:lang="en-US">$0.99 Kindle Books project $0.99 Kindle Books (aka for android 6.0</title>


Feb 15, 2022, 10:44:13 PMFeb 15
to Clojure

I changed the code a bit:

    cpe-dictionary (-> "official-cpe-dictionary_v2.3.xml"

        xmlzipper ( cpe-dictionary)

Now I get this:

                                                   xml.clj:  84

                                                   xml.clj: 109

                                        tree.clj:  70

                                             clojure.core/ffirst                  core.clj: 105

                                              clojure.core/first                  core.clj:  55


                                       tree.clj:  39

                                                clojure.core/seq                  core.clj: 139


                                 parse.clj:  78 652 ParseError at [row,col]:[1,1]

                                     Message: Content is not allowed in prolog.

    location: #object[$1 0x296bfddb "Line number = 1\nColumn number = 1\nSystem Id = null\nPublic Id = null\nLocation Uri= null\nCharacterOffset = 0\n"]


Feb 15, 2022, 11:10:12 PMFeb 15
to Clojure
Okay, this seemed to fix the problem:

        cpe-dictionary (-> "official-cpe-dictionary_v2.3.xml"

        xmlzipper ( cpe-dictionary)

        xmlnode (-> xmlzipper

Reply all
Reply to author
0 new messages