xml_ns doesn't retrieve the namespace of a single node

Aperta
#272 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
r
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
R
Stelle
227
Fork
86
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di r-lib/xml2

Tutte le issue di r-lib/xml2

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.