OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   wanted: utility functions e.g. fixData and fixName to generate XML

[ Lists Home | Date Index | Thread Index ]
  • From: "Tolkin, Steve" <Steve.Tolkin@fmr.com>
  • To: xml-dev@xml.org
  • Date: Thu, 6 Apr 2000 10:28:13 -0400

There are two utility functions that will be very useful
when generating XML from a database.
I do not know if there are standard names for these, so
I'll call them fixData() and fixName().

The fixData(string) function will return a string
that is the result of replacing certain characters 
in the input with their entities.
This will be include at least &lt; and &amp;
and possibly also &gt;.
If the output is intended for use as an
attribute value, then fixData must also do white space
normalization, as well as replacing at least one
of &quot; or &apos;.  

The fixName(string) will return a string that is 
a legal element or attribute name.  
In certain database systems column names can contain 
any character, including white space.
So this function could replace each illegal
character with an underscore, or delete them all,
or use some other strategy.

I would like to find functions like this 
in Visual Basic, and also in Java.  
(A Perl version is available in DBIx::XML_RDB.pm.)

Other issues:
The fixData function might also need to encode 
characters outside of ASCII, e.g. as UTF-8.
It might need to use another type of encoding for
the ASCII control characters that are in Unicode
but not legal in XML, e.g. control-A aka 0x01 etc.  
But what encoding should be used?
Ideally fixData comes with an inverse function
that can reconstitute the original data exactly.

It would be great if the output of fixName could
be run through a "uniquefy" phase to ensure that
distinct database column names were assigned
unique xml names.

There are undoubtedly even hairier corner cases.

Steven Tolkin          steve.tolkin@fmr.com      617-563-0516 
Fidelity Investments   82 Devonshire St. R24D    Boston MA 02109
There is nothing so practical as a good theory.  Comments are by me, 
not Fidelity Investments, its subsidiaries or affiliates.

This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@xml.org&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS