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

Re: Tool converts records to XML

  • From: Roger L Costello <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Tue, 15 Nov 2022 20:14:36 +0000

Re:  Tool converts records to XML
Michael Kay wrote:

> the "Barnes & Noble" problem. The number #1 blunder 
> when writing XML is not to bother escaping `<` and `&` 
> if they happen to occur in your input.

Ouch!

You are right Michael.

Upon reflection, I realized that there is an even nastier problem lurking than the problem of converting & and < in the input record data into &amp; and &lt; in the output XML. 

My actual record data is encoded in Windows 1252. The records contain many occurrences of the degree symbol. In Windows 1252 the degree symbol is a single byte (hex B0) but in UTF-8 the degree symbol is two bytes (hex C2 B0). My AWK program doesn't convert the one byte Windows 1252 degree symbol to the two byte UTF-8 degree symbol. In fact, to be correct every Windows 1252 character with an encoding above hex 0F must be converted to two bytes, and my AWK program doesn't do any of that.

Eeeeeeek!

For fun, I also wrote an XSLT program to convert the records to XML. My program uses the unparsed-text() function, which does all character conversions behind-the-scene (i.e., you have no idea that all the Windows 1252 characters above hex 0F are being converted to two byte UTF-8 characters).

To implement the character conversions in AWK would be a monumental task.

Eeeeeeek!

Lesson Learned: Don't use AWK to convert records to XML.

Bummer!

/Roger


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.