Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Carriage return in complex type

I have a complex type like this

<xsd:element name="Work" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="Option" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="add"/>
<xsd:enumeration value="change"/>
<xsd:enumeration value="delete"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="Name" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="Number" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>

The above schema validates the following two options correctly

<Work Option="add" Name="Raul" Number="7" />
<Work Option="add" Name="Raul" Number="7"></Work>

But if there is space or carriage return (Enter key) between the start and end tags, the schema returns an error

(ie) for

<Work Option="add" Name="Raul" Number="7"> </Work>
(&)
<Work Option="add" Name="Raul" Number="7">
</Work>

I get the following error message
(The content of element type "Work" must match "EMPTY".)

I tried using <xsd:whitespace> but I think it can be used only for simple types...

Can somebody help me out with this?
[1687 byte] By [Raul3182] at [2007-11-11 6:49:28]
# 1 Re: Carriage return in complex type
Validation will fail if the Work element contains any content. Change the declaration of the Work element so that it allows ANY or #PCDATA. That will let the element contain content, which is the cause of your problem right now. If in fact you don't want to allow the element to contain content, then the validation is working correctly as is.
arjonesiii at 2007-11-11 23:28:46 >