File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to allow empty values in XML Schema elements

 
vamshidhar nimbagiri
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In the following XML Schema the elements RID and BID it should allow empty values.

<xs:element name="CustomerCode">
<xs:complexType>
<xs:sequence>
<xs:element name="RID">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z0-9]{15}" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="BID">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z0-9]{15}" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

Could any body please tell me how to do that

Thanks
Vamshi
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to include "minOccurs" attribute in the element tag with "0" as the value.

<xs:element name="RID" minOccurs="0">
 
vamshidhar nimbagiri
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Purushotham,

Thanks for the reply,

If i include minOccurs="0" the element RID may be ommitted
but here in my case the content of the RID may be empty so i have to handle even if
the content in RID element is empty value.
could you please tell me how to handle this?

Thanks
Vamshi
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I didn't get right in the first reply. You need to use nillable="true" attribute as well for the respective elements.
 
vamshidhar nimbagiri
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Purushotham!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic