Carriage return in complex type


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Carriage return in complex type

  1. #1
    Join Date
    Sep 2005
    Posts
    3

    Question 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???

  2. #2
    Join Date
    Nov 2003
    Posts
    154
    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.
    A. Russell Jones,
    Executive Editor,
    Internet.com

Similar Threads

  1. Complex number
    By burung in forum Java
    Replies: 3
    Last Post: 08-01-2005, 06:59 AM
  2. Replies: 1
    Last Post: 03-27-2003, 11:49 AM
  3. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 06:23 AM
  4. App Object
    By Rob Teixeira in forum .NET
    Replies: 15
    Last Post: 05-31-2002, 04:30 PM
  5. Replies: 1
    Last Post: 04-23-2002, 04:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center