[Home] [By Thread] [By Date] [Recent Entries]
Hey there, This is out of the MSXML docs. "XSL Transformations (XSLT) provides a built-in function, normalize-space(), that strips leading and trailing white space from a string and normalizes multiple successive white space characters to a single space. It takes one argument, a string or node-set (the latter being converted to a string as necessary); if the argument is omitted, normalize-space() assumes the context node." samples: ------------- in your xml doc ------------- <generouswhitespace> There is a l o t of white space here! </generouswhitespace> ------------- in your xsl doc ------------- <xsl:template match="generouswhitespace"> [<xsl:value-of select="normalize-space(.)" />] </xsl:template> hth., Serdar ----- Original Message ----- From: "Saxena, Saurabh" <saurabh.saxena@i...> To: "'Rick Jelliffe'" <ricko@a...>; <xml-dev@l...> Sent: Wednesday, May 23, 2001 8:36 PM Subject: RE: whitespaces, need a help ! > HI > 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 > regards > saurabh > > > -----Original Message----- > From: Rick Jelliffe [mailto:ricko@a...] > Sent: Wednesday, May 23, 2001 5:29 PM > To: xml-dev@l... > Subject: Re: whitespaces, need a help ! > > > 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 > ( ' ' | 'I' | 'E' ) > That is the preferred option. If it doesn't work, try > ( '\ ' | '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 > > > > > > > ------------------------------------------------------------------ > The xml-dev list is sponsored by XML.org, an initiative of OASIS > <http://www.oasis-open.org> > > The list archives are at http://lists.xml.org/archives/xml-dev/ > > To unsubscribe from this elist send a message with the single word > "unsubscribe" in the body to: xml-dev-request@l... > > > ------------------------------------------------------------------ > The xml-dev list is sponsored by XML.org, an initiative of OASIS > <http://www.oasis-open.org> > > The list archives are at http://lists.xml.org/archives/xml-dev/ > > To unsubscribe from this elist send a message with the single word > "unsubscribe" in the body to: xml-dev-request@l... >
|

Cart



