[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
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 < and & and possibly also >. 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 " or '. 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. Thanks, Steve -- 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/ ***************************************************************************
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|