> I opt to store user-defined data in CDATA blocks:

> <root>
>      <mytag><![CDATA[#userDefinedStuff#]]></mytag>
> </root>

> Another route is to use the XMLFormat() function.

Unfortunately the XMLFormat() function doesn't handle non-printing
characters. I believe the character 0x1C or "1C" is ASCII character
27, with characters 1-30 being non-printing. All the non-printing
characters with the exception of carriage return (13) line feed (10)
and space (20?) are invalid in an XML document.

I'm not sure if the CDATA segment will allow you to use these
characters or if XML simply expects you to find your own method of
handling them that conforms to the standard of not including
non-printing characters. I'm reasonably certain that it rejects the
entities (&#7; for example would technically be the ASCII beep code)
and since that would prevent their use in attributes, my guess would
be they are also not allowed in CDATA segments.

This is all guess-work on my part, I haven't memorized the spec or
anything. :)

That being the case, when I found vertical tabs in some of my data
which needed to be embedded in XML documents, I created a wrapper
function for the native XMLFormat() function which removes all
non-printing characters except 13, 10 and the space.

Here is the code I used to accomplish this task (sorry for the
line-wrap):

function xmlstring(mystring) {
  // remove any non-printing characters
  // with the exception of tabs and line-breaks
  mystring = rereplace(mystring,"[#chr(1)#-#chr(8)##chr(11)#-#chr(12)#
#chr(14)#-#chr(31)#]","","ALL");
  // replace the single-quote character with
  // the character-code entity the xml parser
  // in early versions of ColdFusion MX doesn't
  // understand the &apos; entity
  return replacenocase(xmlformat(mystring),"&apos;","&##39;","ALL");
}

hth


s. isaac dealey     434.293.6201
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237311
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to