You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by abhishekhp <ab...@infy.com> on 2001/10/12 08:50:03 UTC

Error in Validating when element contains asingle space as a valid value

Hi,
I am using xerces 1.4.3 DOM parser to validate and parse elements
against Schemas.
In my Schema definition, I have defined an element as follows : 

<xs:element name="SeverityCode">
	<xs:simpleType>
		<xs:restriction base="xs:string">
			<xs:enumeration value=" "/>                   //
A single space
			<xs:enumeration value="W"/>
			<xs:enumeration value="E"/>
			<xs:enumeration value="S"/>
		</xs:restriction>
	</xs:simpleType>
</xs:element>

However, in the XML file, although the element <SeverityCode> has as
value, a blank space (which should be valid as per the schema), it gives
an error during parsing as follows:
Datatype error: In element 'SeverityCode' : Value '' must be one of [ ,
W, E, S].

The element as in the XML file is <SeverityCode> </SeverityCode>

It is imperitive that a single space is a valid value for this element.
Can anyone suggest a solution to the problem?

TIA,
abhishek.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Error in Validating when element contains asingle space as a valid value

Posted by Andreas Thönnessen <at...@philosys.de>.
abhishekhp schrieb:
:
> The element as in the XML file is <SeverityCode> </SeverityCode>
> 
> It is imperitive that a single space is a valid value for this element.
> Can anyone suggest a solution to the problem?
:
Hi abhishekhp (?),

I think your problem is not in the schema definition. XML normally
does not treat spaces (and tabs, and line breaks...) as part of the
content.

You either have to use
	<SeverityCode><![CDATA[ ]]</SeverityCode>
to tell the parser that the space really _is_ the content, or you
may change your schema and XML file to use a "real character" (e.g.
'-') to be the desired content.

Greetings,

Andi.
--

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org