[MOBY-dev] whitespace in MOBY Objects

Mark Wilkinson markw at illuminae.com
Mon Feb 23 21:35:55 UTC 2004


Dave Waddell pointed out to me last week that the output from some of my
services doesn't parse "nicely" - in particular, when I am passing back
e.g. a genbank flat file, along with cross-references, the XML parsers
may (in some Perl parsers this is a switchable option) interpret
newlines and tabs as whitespace.  Thus my output:

<genbank-ff>
	<CrossRef>
		<Object>
	</CrossRef>
genbank flatfile here
_______
_______
_______
_______
</genbank-ff>

is actually parsed to the following string:

"




				genbank flatfile here
_________
_________
_________
_________
"

which is obviously not a valid genbank file format!

I have just updated my services to be less cavalier about whitespace,
but we should probably all look at our services and do the same.  This
is only important w.r.t. objects that inherit from one of the primitives
(String, Integer, etc), since other objects by definition are NOT
allowed to have literal content, but it is probably good practice to not
be thinking about human readability when constructing our output.

I will probably migrate all of my services to use an XML-DOM builder,
rather than writing out the XML by hand in the future to ensure that I
don't do this by accident.

Thanks for the heads-up Dave!

Mark

-- 
Mark Wilkinson <markw at illuminae.com>
Illuminae



More information about the MOBY-dev mailing list