xml_ns doesn't retrieve the namespace of a single node

Đang mở
#272 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
r
Lĩnh vực
backend

Hướng nghiên cứu

Start with xml_ns(), using the read_xml() and xml_find_first() example to trace how namespaces are currently returned for a selected node. Done means calls on x1:element and x2:element return the namespace associated with the current node rather than both document namespaces.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

breaking change :skull_and_crossbones: feature
Issue Description and Expected Result

I think the implementation of xml_ns is non-intuitive. When called on a node xml_ns retrieves all namespacess of the root document. What I think it should do is to return the namespace of the current node.

Reproducible Example
library(xml2)
     x <- read_xml('
      <root>
        <doc xmlns:x1 = "http://foo.com" xmlns:x2 = "http://bar.com">
            <x1:element/>
            <x2:element/>
         </doc>
      </root>
     ')

xml_ns(xml_find_first(x, "//x1:element"))
# x1 <-> http://foo.com
# x2 <-> http://bar.com
xml_ns(xml_find_first(x, "//x2:element"))
# x1 <-> http://foo.com
# x2 <-> http://bar.com
> 

Session Info
devtools::session_info() # Paste output below
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                                             
 version  R Under development (unstable) (2019-08-06 r76924)
 os       Ubuntu 18.04.2 LTS                                
 system   x86_64, linux-gnu                                 
 ui       X11                                               
 language (EN)                                              
 collate  en_US.UTF-8                                       
 ctype    en_US.UTF-8                                       
 tz       Europe/Berlin                                     
 date     2019-08-16                                        

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version    date       lib source                            
 assertthat    0.2.1      2019-03-21 [2] CRAN (R 3.7.0)                    
 backports     1.1.4      2019-04-10 [2] CRAN (R 3.7.0)                    
 bit           1.1-14     2018-05-29 [1] CRAN (R 3.7.0)                    
 bit64         0.9-7      2017-05-08 [1] CRAN (R 3.7.0)                    
 blob          1.2.0      2019-07-09 [1] CRAN (R 3.7.0)                    
 callr         3.3.1      2019-07-18 [2] CRAN (R 3.7.0)                    
 cli           1.1.0      2019-03-19 [2] CRAN (R 3.7.0)                    
 crayon        1.3.4      2017-09-16 [2] CRAN (R 3.7.0)                    
 data.table  * 1.12.2     2019-04-07 [2] CRAN (R 3.7.0)                    
 DBI         * 1.0.0      2018-05-02 [1] CRAN (R 3.7.0)                    
 desc          1.2.0      2018-05-01 [2] CRAN (R 3.7.0)                    
 devtools      2.1.0      2019-07-06 [2] CRAN (R 3.7.0)                    
 digest        0.6.20     2019-07-04 [2] CRAN (R 3.7.0)                    
 dplyr       * 0.8.3      2019-07-04 [2] CRAN (R 3.7.0)                    
 fs            1.3.1      2019-05-06 [2] CRAN (R 3.7.0)                    
 glue          1.3.1      2019-03-12 [2] CRAN (R 3.7.0)                    
 hms           0.5.0      2019-07-09 [1] CRAN (R 3.7.0)                    
 htmltidy    * 0.5.0      2019-08-14 [1] Github (hrbrmstr/htmltidy@a9a0cf8)
 htmltools     0.3.6      2017-04-28 [1] CRAN (R 3.7.0)                    
 htmlwidgets   1.3        2018-09-30 [1] CRAN (R 3.7.0)                    
 lubridate   * 1.7.4.9000 2019-08-14 [1] local                             
 magrittr      1.5        2014-11-22 [2] CRAN (R 3.7.0)                    
 memoise       1.1.0      2017-04-21 [2] CRAN (R 3.7.0)                    
 odbc        * 1.1.6      2018-06-09 [1] CRAN (R 3.7.0)                    
 pillar        1.4.2      2019-06-29 [2] CRAN (R 3.7.0)                    
 pkgbuild      1.0.4      2019-08-05 [2] CRAN (R 3.7.0)                    
 pkgconfig     2.0.2      2018-08-16 [2] CRAN (R 3.7.0)                    
 pkgload       1.0.2      2018-10-29 [2] CRAN (R 3.7.0)                    
 prettyunits   1.0.2      2015-07-13 [2] CRAN (R 3.7.0)                    
 processx      3.4.1      2019-07-18 [2] CRAN (R 3.7.0)                    
 ps            1.3.0      2018-12-21 [2] CRAN (R 3.7.0)                    
 purrr         0.3.2      2019-03-15 [2] CRAN (R 3.7.0)                    
 R6            2.4.0      2019-02-14 [2] CRAN (R 3.7.0)                    
 Rcpp          1.0.2      2019-07-25 [2] CRAN (R 3.7.0)                    
 remotes       2.1.0      2019-06-24 [2] CRAN (R 3.7.0)                    
 rlang       * 0.4.0      2019-06-25 [2] CRAN (R 3.7.0)                    
 rprojroot     1.3-2      2018-01-03 [2] CRAN (R 3.7.0)                    
 sessioninfo   1.1.1      2018-11-05 [2] CRAN (R 3.7.0)                    
 testthat      2.2.1      2019-07-25 [2] CRAN (R 3.7.0)                    
 tibble        2.1.3      2019-06-06 [2] CRAN (R 3.7.0)                    
 tidyselect    0.2.5      2018-10-11 [2] CRAN (R 3.7.0)                    
 usethis       1.5.1      2019-07-04 [2] CRAN (R 3.7.0)                    
 vctrs         0.2.0      2019-07-05 [2] CRAN (R 3.7.0)                    
 VSR         * 0.0.0.9000 2019-08-07 [2] local                             
 withr         2.1.2      2018-03-15 [2] CRAN (R 3.7.0)                    
 XML         * 3.98-1.20  2019-06-06 [1] CRAN (R 3.7.0)                    
 xml2        * 1.2.2      2019-08-09 [1] CRAN (R 3.7.0)                    
 zeallot       0.1.0      2018-01-28 [2] CRAN (R 3.7.0)                    

[1] /home/vspinu/.lib/3.7.0
[2] /home/vspinu/bin/R-latest/library
> 
#> output
Ngôn ngữ chính
R
Star
227
Fork
86
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của r-lib/xml2

Tất cả issue của r-lib/xml2

Issue tương tự

Thêm issue về R

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.