xml_ns doesn't retrieve the namespace of a single node

Abierto
#272 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
r
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
R
Estrellas
227
Forks
86
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de r-lib/xml2

Todos los issues de r-lib/xml2

Issues similares

Más issues de R

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.