Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles

Database News

Posted Jan 30, 2003

XML-illegal characters in database-legal field names?

By DatabaseJournal.com Staff

[From XML.com]

John Simpson describes a technique for database and XML integration.

Q: I have a database that contains "unconventional" field names (i.e., Book_&_Page, Grantee's_ID_#). These field names do not meet the requirements for element names, so I am forced to run them through a "sanitizing" function before naming the element nodes. The function replaces or removes the characters offensive to XML. So the Book_&_Page field might become the Book__Page element, and Grantee's_ID_ might become Grantees_ID_no because I've chosen to sanitize simply by removing the offending characters.

Unfortunately, this sanitizing process introduces the possibility that I could end up with elements with the same name, although in the database they are named differently. For example, if there were original fields named Book_&_Page and Book_:_Page, sanitizing by the rule of removing the character would result in Book__Page for both of these fields. (Changing the field names in the database is NOT an option.)

The initial dilemma is deciding what rules to apply to what characters in the sanitizing function. Coming up with a generic set of rules that could apply to multiple datasets over multiple systems seems risky. I am hoping that someone has come up with a way to "wrap" the element name so that these "illegal" characters can be included in the name. Maybe something along the lines of a CDATA section for the content of an element?

The article continues at http://www.xml.com/pub/a/2003/01/29/qa.html

Database News Archives

Latest Forum Threads
Database News Forum
Topic By Replies Updated
Efficient SQL Server Indexing by Design lcole 0 April 30th, 12:38 PM
Mine Oracle Database, SQL Server and Other Databases with Monarch Data Pump Pro V10.5 lcole 0 April 30th, 12:37 PM
Oracle Database and Oracle Fusion Middleware for Private Social Network Application lcole 0 April 30th, 12:31 PM
Oracle Database Maintains a Stronghold in the DBMS Market lcole 0 April 30th, 12:30 PM