473,394 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

schemas and empty elements

Hi,

Another silly question - by default if I define a specific element as a
string (xsd:string) in a schema, if I validate a document against that
schema and the element is empty, should it, or should it not pass through
successfully??

Basically, I know there is an <empty> tag to put in the schema if you
require a field to be empty, but if you want it to be either containing a
string or be empty, will it pass through validation if you do nothing but
declare the element as as string??

Cheers

Chris
Nov 11 '05 #1
2 2532
ch***@yahoo.com wrote:
Another silly question - by default if I define a specific element as a
string (xsd:string) in a schema, if I validate a document against that
schema and the element is empty, should it, or should it not pass through
successfully??


Should pass. Empty string is still valid xsd:string value. You can
constrain value to be at least 1 character lenght by restricting
xsd:string type:
<xs:element name="d">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
Thanks, that's what I thought.

Cheers

Chris

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
ch***@yahoo.com wrote:
Another silly question - by default if I define a specific element as a
string (xsd:string) in a schema, if I validate a document against that
schema and the element is empty, should it, or should it not pass through successfully??


Should pass. Empty string is still valid xsd:string value. You can
constrain value to be at least 1 character lenght by restricting
xsd:string type:
<xs:element name="d">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Victor | last post by:
I have a Schema with some elements which are "types" or objects, and some elements which correspond to instances of the types. How can I specify that a <locationInstance> must have an attribute...
0
by: Zombie | last post by:
Hi, I am looking for an XML schema design which provides version compatiblity between schemas. My schema has to evolve over time. Newer versions of the schema would be created by the addition of...
0
by: kyancy | last post by:
Hello All. We have several XML schemas to describe common component document parts. We then create new XML schemas as necessary that use "xsd:import schemaLocation=whateverLocation.." to include...
1
by: Steve George | last post by:
Hi, I have a scenario where I have a master schema that defines a number of complex and simple types. I then have a number of other schemas (with different namespaces) where I would like to reuse...
23
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
3
by: Matt Frame | last post by:
I am just starting to work with Schemas and VB.Net. I created a simple schema with a structure of a top level group, then inside that group I have sub-groups and elements and within the sub-groups...
4
by: anonymous | last post by:
When I use the schema collection to apply many schemas to one XML instance document, I get an error if I do not qualify every element with the appropriate namespace. Both the W3C site and this...
2
by: Darrell Plank | last post by:
I'm a real XML novice, but my ultimate goal here is to get a workable schema for the GEDCOM XML format as spec'ed out here: http://www.familysearch.org/GEDCOM/GedXML60.pdf It's a proposed XML...
5
by: Arndt Jonasson | last post by:
I have a schema defining the input of a particular application. Let's refer to the namespace for my schema by the prefix "my:". Now the need has arisen to annotate such input documents with foreign...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.