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

Re: Best Practice: Use a character or its escaped form?

  • From: Michael Kay <mike@saxonica.com>
  • To: xml-dev@lists.xml.org
  • Date: Thu, 28 Feb 2013 11:24:56 +0000

Re:  Best Practice: Use a character or its escaped form?

Use the escaped form (a) when it's easier to generate than the "true" 
character, e.g. to cope with input device limitations, or (b) when you 
don't trust the transmission/storage services you are using to preserve 
the integrity of your character encoding.

Michael Kay
Saxonica

On 28/02/2013 10:29, Costello, Roger L. wrote:
> Hi Folks,
>
> When should Á be used versus when should its escaped form be used (&xC1;)?
>
> Which is Best Practice, this:
>
> 	<Name>Ándre</Name>
>
> or this:
>
> 	<Name>&xC1;ndre</Name>
>
> Which do you think is Best Practice?
>
> Scroll down to see the answer ...
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> The following answer is from Martin J. Dürst. It is fantastic.
>
> In HTML and XML (and many other formats), escapes such as character entity references are what their name says, escape hatches. That means that you should only use them in "emergency situations".
>
> In the example at hand, most people will be able to read Ándre without problems. But &xC1;ndre requires table lookup in Unicode or some other mental gymnastics.
>
> The preference for using characters directly, rather than escapes, is formally put down at http://www.w3.org/TR/charmod/#C047.
>
> C047 says:
>
>   >>>>>>>>
> C047  [I]  [C]  Escapes SHOULD only be used when the characters to be expressed are not directly representable in the format or the character encoding of the document, or when the visual representation of the character is unclear.
>   >>>>>>>>
>
> The [I] says that this applies to implementers, the [C] says that this applies to content. The "are not directly representable" would apply if e.g. your document is encoded in Shift_JIS (which doesn't have 'Á'). The "the visual representation of the character is unclear" applies e.g. for &nbsp; because it may be desirable when looking at the source that there's a non-breaking space there rather than a plain space. It may also apply if you don't have an editor that can show that character, if you e.g. can't input it, or if you are not familiar enough with the character/script to make sure you get the right one. But the former two are rare these days, and the latter should better be avoided, because the person inputting/checking may have the same problem when looking at an Unicode table.
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>



[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.