Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allowing blank values for xs:integer, xs:boolean?

Status
Not open for further replies.

forozco

Programmer
Feb 14, 2003
4
US
Hello,

I design schemas using XMLSPY, a great program. Often, I do not want to make an element optional, but do need to allow blank values. For strings this is easy, I simply set the minlength = 0.

My question is, how can I accomplish this with other datatypes(integer, decimal, boolean, etc..)? If i set MinOccurs =0, then the element becomes optional, which I do not want. Can I define a pattern or facet for this? Any help is greatly appreciated. Thank you!

Frank Orozco
 
it would supprise me since those types would not be valid without a value. kant u just give em a default value? -There are only 10 types of people in the world, those who understand binary and those who don't-

-pete
 
'Fraid not. If you specify a datatype (such as an Integer), then you are restricted to the range of valid values for that datatype, and "empty" isn't valid for things such as integers.

Same thing applies for DateTime, Double, etc.

You'll either need to go back to using a xs:String and pray the users give you correctly formatted data, or maybe add a boolean attribute named something like "IsEmpty". You'd still have to have a valid value in the element, but you'd look at the attribute first to see whether or not to pay attention to it. Or make the element optional (like you said).

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top