SteveMurphy Posted March 19, 2007 Share Posted March 19, 2007 I'm designing an XML file and one of the elements will have a true/false attribute. In terms of style, which of the following would be the best way to implement the attribute? IsBullet="true"/IsBullet="false" IsBullet="yes"/IsBullet="no" IsBullet="1"/IsBullet="0" Each item in the preceding list represents one possible way to implement my attribute. Each item shows my suggested way to represent the two possible values for the attribute.Thanks. Link to comment Share on other sites More sharing options...
jesh Posted March 20, 2007 Share Posted March 20, 2007 If you ever plan on moving the data over to a database rather than an XML file, it might be best to stick with the true = 1 and false = 0 because of the way databases store booleans. Also, "1" uses less memory than "yes" or "true". I'd choose this one: IsBullet="1"/IsBullet="0" Link to comment Share on other sites More sharing options...
boen_robot Posted March 20, 2007 Share Posted March 20, 2007 jesh has a good point (two infact).One thing I could add is that if you plan to use XML Schema, you should check out which of the three models validates as the xs:boolean type. It's not critical if the third doesn't though. You can always force a node to be valid only on certain set of values (obviosly 0 and 1 in this case). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now