#323 ✓resolved

dm-serializer generates invalid xml

Reported by Postmodern | May 29th, 2008 @ 07:12 AM

Since to_xml uses DataMapper::Inflector.underscore, which replaces /::/ with '/', to convert class names to xml element names the resulting XML string cannot be parsed by REXML. XML element names should probably never contain '/'.

  require 'data_mapper'
  require 'dm-serializer'
  module Ronin
    class Platform
      include DataMapper::Resource
      property :os, String
      property :version, String
  >> xml = Ronin::Platform.new(:os => 'Linux', :version => '2.4.24').to_xml
  => "<ronin/platform id=''><os>Linux</os><version>2.4.24</version></ronin/platform>"
  >> REXML::Document.new(xml)
  REXML::ParseException: #<REXML::ParseException: 
  malformed XML: missing tag start
  Last 80 unconsumed characters:
  >> xml.gsub!(/ronin\/platform/,'ronin-platform')
  >> REXML::Document.new(xml).root
  => <ronin-platform id=''> ... </>

It should also be noted that to_xml does not add the standard XML declaration to the output.

  <?xml version="1.0"?>

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket