简体   繁体   English

为什么clojure.data.xml在解析RDF文件时不返回xml命名空间?

[英]Why doesn't clojure.data.xml return xml namespaces when parsing a RDF file?

I'm working on a semantic web library for clojure and I wanted to check if data.xml returns XML namespaces for the document being parsed, so I threw together a quick program that parsed this RDF document from W3Schools RDF tutorial 我正在开发一个用于clojure的语义Web库,我想检查data.xml是否为正在解析的文档返回XML命名空间,所以我把一个快速程序放在一起,从W3Schools RDF教程解析这个RDF文档

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Empire Burlesque">
  <cd:artist>Bob Dylan</cd:artist>
  <cd:country>USA</cd:country>
  <cd:company>Columbia</cd:company>
  <cd:price>10.90</cd:price>
  <cd:year>1985</cd:year>
</rdf:Description>

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Hide your heart">
  <cd:artist>Bonnie Tyler</cd:artist>
  <cd:country>UK</cd:country>
  <cd:company>CBS Records</cd:company>
  <cd:price>9.90</cd:price>
  <cd:year>1988</cd:year>
</rdf:Description>
</rdf:RDF>

And I got this. 而我得到了这个。 (Formatted for easier reading.) (格式化以便于阅读。)

{:tag :RDF, 
 :attrs {},
 :content ({:tag :Description, 
            :attrs {:rdf/about "http://www.recshop.fake/cd/Empire Burlesque"},
            :content ({:tag :artist,
                       :attrs {},
                       :content ("Bob Dylan")}
                      {:tag :country, 
                       :attrs {},
                       :content ("USA")}
                      {:tag :company,
                       :attrs {},
                       :content ("Columbia")}
                      {:tag :price, 
                       :attrs {},
                       :content ("10.90")}
                      {:tag :year,
                       :attrs {},
                       :content ("1985")})}
           {:tag :Description, 
            :attrs {:rdf/about "http://www.recshop.fake/cd/Hide your heart"},
            :content ({:tag :artist,
                       :attrs {},
                       :content ("Bonnie Tyler")}
                      {:tag :country,
                       :attrs {},
                       :content ("UK")}
                      {:tag :company,
                       :attrs {},
                       :content ("CBS Records")}
                      {:tag :price,
                       :attrs {},
                       :content ("9.90")}
                      {:tag :year,
                      :attrs {},
                      :content ("1988")})})}

So if I wanted to create triples from the parsed document, I couldn't, because the parsers in data.xml don't don't return namespaces from the root of a document. 因此,如果我想从解析的文档创建三元组,我不能,因为data.xml中的解析器不会从文档的根目录返回名称空间。 Why is that? 这是为什么?

clojure.data.xml now supports this, but at the time this question was asked it did not. clojure.data.xml现在支持这个,但当时问这个问题却没有。

Support for namespaces was introduced in 0.1.0-beta1 (January 2016), and as we are now up to 0.2.0-beta5 it is safe to say that it is fairly established and battle-tested. 0.1.0-beta1 (2016年1月)中引入了对名称空间的支持,并且由于我们现在高达0.2.0-beta5因此可以肯定地说它是相当成熟且经过0.2.0-beta5测试的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM