[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: whitespaces, need a help !
- From: Rick Jelliffe <ricko@allette.com.au>
- To: xml-dev@lists.xml.org
- Date: Wed, 23 May 2001 21:49:30 +0800
From: Saxena, Saurabh <saurabh.saxena@intel.com>
>Even i am facing the same problem.Actually i have a tag in XML file as
><NAME>ABCD></NAME>
>Later i am storing this in the database.Now the maximum length for this is
>8.(As defined in the schema file)
>What is happening if there is a TAG value like
><NAME>ABCD </NAME>
>Then also the validator validates this file successfully and this got
>bounced when it goes to the database.Is there any way to trim these
>leading/trailing whitespaces.
>I can't add anything(extra code) in my XML file as they are
>autogenerated.Can something be done at the schema file or in the code where
>i am validating the file
An XML Schema will let you declare what the significance of that whitespace
is:
you can declare that NAME is type "token" in particular. However, then you
would need some schema-aware system to make use of that information: these
animals don't really exist yet. For this next year, vendors will be mainly
getting together their validators before any transformation systems based on
the PSVI (post-schema validation infoset) are developed.
So XML Schemas systems do not currently help you do what you need. You are
better off to write a simple filter yourself. If you are using UNIX, you
can probably use the following sed script (or the perl equiv if you are on
some other system)
1,$s/\ *<\/NAME>/<\/NAME>/
which means, for each line from 1 to the end ($) substitute an occurrence of
spaces "\ *" followed by </NAME> with </NAME>.
But I would complain to the database vendor that they need to provide more
options (actually, I would have expected most DBMS to fail in the opposite
way, that they silently truncate without warning anyone.)
Cheers
Rick Jelliffe