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

Re: whitespaces, need a help !

  • From: Rick Jelliffe <ricko@a...>
  • To: xml-dev@l...
  • Date: Wed, 23 May 2001 19:59:17 +0800

xml preserve whitespace
 From: Vladimir V. Popov <vladimir.popov@a...>

>  I have a xml data with elements which contain only whitespace(s).
>  Does anybody know how can I check and constrain these elements for
>  using, for example, only such chars (UTF-16): #x0020, "I", "E"?

There are several issues here. For a start, be warned that the regular
expression matching of XML Schema implementations may not be satisfactory
yet: it is too early to have confidence so you should test the particular
tools.

For the XML document, use xml:space="preserve" on the elements that must
preserve whitespace. This probably won't have any effect, but it is good
practise.
(Xml:space was developed because the default SGML system (remove first
leading and trailing newline) was violated by html:pre and a bit tricky for
people. )

In the XML Schema, use datatypes derived from "string" not from "token".
The token datatype (which include most string types) will strip leading and
trailing whitespace characters (following the rules in XML s. 3.3.3).  Check
whether "string" or "normalizedString" is appropriate: perhaps
"normalizedString" might be bad if newlines are changed to spaces.

Now for the particular datatypes. You have three choices, I think.
(I have not tried these: no flames please.)

The first is merely to make a regular expression such as
  ( '&#x20;' | 'I' | 'E' )
That is the preferred option.  If it doesn't work, try
  ( '\&#x20;' | 'I' | 'E' )
as a workaround. If it still doesn't work, you could settle for using
  ( '\s' | 'I' | 'E' )
which will allow any single whitespace.

The second choice is to make explicit types for "string containing single
space only", "string containing I only", etc. then defining a union.  I
would be surprised if current schema implementations have tested for this,
so good luck if you use it!

The third choice is to use a String, but then use enumerations. Again, I bet
this has not been tested by implementers.

Cheers
Rick Jelliffe






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.