From: Ian Macdonald Date: 2003-06-24T10:05:05+09:00 Subject: Re: REXML and double, rather than single quotes On Tue 24 Jun 2003 at 10:02:02 +0900, Sean Russell wrote: > Ian Macdonald wrote in message news:<20030622205120.GE3769@caliban.org>... > > I have to format output for an application that requires its XML to > > have attributes quoted using double, not single quotes. > > > > Is there any way to coerce REXML into producing double-quotes? > > Soon, young Jedi. I'm adding some more configurable XML writers to > REXML 3.0. > > FYI, the application is not XML conformant if it doesn't accept single > quotes around attributes. Yes, I know. I couldn't believe it when I finally discovered why my files weren't being accepted. > In the meantime, if you really need this and are willing to hack the > sources, override REXML::Attribute::to_string(). Do something like > this in the application that generates the XML: > > REXML::Attribute.class_eval( %q^ > def to_string > %Q[#@expanded_name="#{to_s().gsub(/"/, '"')}"] > end > ^ ) > > This will rewrite the method that is used to produce the XML fragment > for an Attribute. Thanks very much, Sean. Ian -- Ian Macdonald | Time sharing: The use of many people by the System Administrator | computer. ian@caliban.org | http://www.caliban.org | |