[R] XML-2.8 not writing indented XML anymore

Steffen Neumann sneumann at ipb-halle.de
Thu Apr 8 13:41:02 CEST 2010


Hi,

just wanted to note this (mild) regression.
I tried saveXML(traml) with different compression= 
and indent= settings, but the output remained 
in a single line for XML-2.8-1

Without writing to a file the string representation 
after saveXML() looks quite similar, with the exception 
of a \n which seems to be at the end in XML-2.6 output
and at the beginning (just after the <?xml?>) in XML-2.8-1.

Nothing major, most annoying is the indentatino stuff,
but the \n issue might point to the difference ?
The code for my tests is at the end of this mail.

Yours,
Steffen

###################################################################
> saveXML(traml, file="bug.xml")

<?xml version="1.0"?>
 <TraML xmlns="http://psi.hupo.org/ms/traml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="0.9.4" xsi:schemaLocation="http://psi.hupo.org/ms/traml TraML0.9.4.xsd">   <cvList>     <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="2.29.0" URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"/>   </cvList> </TraML>sneumann at paddy:~/tex/papers/2009tandemms/

> sessionInfo()
R version 2.10.1 (2009-12-14) 
x86_64-pc-linux-gnu 
other attached packages:
[1] XML_2.8-1

saveXML(traml)
[1] "<?xml version=\"1.0\"?>\n\n<TraML xmlns=\"http://psi.hupo.org/ms/traml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"0.9.4\" xsi:schemaLocation=\"http://psi.hupo.org/ms/traml TraML0.9.4.xsd\">\n  <cvList>\n    <cv id=\"MS\" fullName=\"Proteomics Standards Initiative Mass Spectrometry Ontology\" version=\"2.29.0\" URI=\"http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo\"/>\n  </cvList>\n</TraML>  "

###################################################################

> saveXML(traml, file="bug.xml")

<?xml version="1.0"?>
<TraML xmlns="http://psi.hupo.org/ms/traml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="0.9.4" xsi:schemaLocation="http://psi.hupo.org/ms/traml TraML0.9.4.xsd">
  <cvList>
    <cv id="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="2.29.0" URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"/>
  </cvList>
</TraML>

> sessionInfo()
R version 2.10.0 (2009-10-26) 
x86_64-unknown-linux-gnu 
other attached packages:
[1] XML_2.6-0   

saveXML(traml)
[1] "<?xml version=\"1.0\"?>\n  <TraML xmlns=\"http://psi.hupo.org/ms/traml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"0.9.4\" xsi:schemaLocation=\"http://psi.hupo.org/ms/traml TraML0.9.4.xsd\">\n  <cvList>\n    <cv id=\"MS\" fullName=\"Proteomics Standards Initiative Mass Spectrometry Ontology\" version=\"2.29.0\" URI=\"http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo\"/>\n  </cvList>\n</TraML>\n"

###################################################################

library(XML)

tramlVersion="0.9.4"
schemaLocation="http://psi.hupo.org/ms/traml TraML0.9.4.xsd"
  
##
## TraML Root
##

traml = xmlTree(tag="TraML",
  attrs=c(
    version=tramlVersion,
    "xsi:schemaLocation"=schemaLocation),
  namespaces = c(
    "http://psi.hupo.org/ms/traml",
    xsi="http://www.w3.org/2001/XMLSchema-instance")
  )

  ##
  ## CV List
  ##

traml$addNode("cvList", close = FALSE)
traml$addNode("cv", attrs=c(
                      id="MS",
                      fullName="Proteomics Standards Initiative Mass Spectrometry Ontology",
                      version="2.29.0",
                      URI="http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo"))
traml$closeTag() ## cvList

saveXML(traml)
sessionInfo()



-- 
IPB Halle                    AG Massenspektrometrie & Bioinformatik
Dr. Steffen Neumann          http://www.IPB-Halle.DE
Weinberg 3                   http://msbi.bic-gh.de
06120 Halle                  Tel. +49 (0) 345 5582 - 1470
                                  +49 (0) 345 5582 - 0
sneumann(at)IPB-Halle.DE     Fax. +49 (0) 345 5582 - 1409



More information about the R-help mailing list