[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

  • From: "Tolkin, Steve" <Steve.Tolkin@f...>
  • To: xml-dev@x...
  • 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@f...      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@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.