This is a old draft but it points out that XML is a subset of SGML and the following rules applies:
The following list describes features which are available in SGML but not in XML.
1. Tag omission
....
11. Omission of quotes on attribute values
This is what w3 schools is saying about attribute values and quotes:
Attribute values must always be enclosed in quotes, but either single or double quotes can be used.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When TinyXML was written, not requiring quotes around attribute values was a feature. It was designed for tolerant input and correct output.
Lately there has been a push to make TinyXML conform more with the spec.
I don't really know what the correct direction is. Originally I wrote TinyXML to read config files for applications. It has been wildly successful in this domain, and compliance is more or less irrelevant. But there may be use cases coming up where compliance is more important.
Feedback is appeciated.
lee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My vote: leave the present tolerant behavior as the default, but allow the client code to select quote-compliance if it wants to.
One way is to use conditional compilation. A better way, in my opinion, is to provide a function to turn quote-compliance on or off at run time. Or maybe a pair of functions, one to turn it on and one to turn it off.
Rationale: a run time switch would allow an application to be quote-compliant sometimes and not other times, for whatever reason. Conditional compilation would not permit this kind of flexibility. Also, conditional compilation tends to make the code hard to read.
I haven't looked at the parsing code to determine how hard it would be to tweak the parsing at run time. However I once did this sort of thing in another context and it wasn't a big deal.
Things get more complicated if there are other respects in which TinyXml does not conform to the spec. I don't know whether it would be better to have a single boolean setting -- tolerant or compliant -- or a series of booleans, each controlling a different aspect of compliance. I think my instinct would be to go for a single boolean setting, but some people might prefer finer-grained control.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I started usage of tiny xml for my game 's levels yesterday, everything was working correctly.
But when I tried to open my level xml on IE , it told me I had errors, tinyxml didn't find those errors.
It seems that xml requires you to have quotes even for numeric attributes, I find that awfully unjustified, hazardous (too much unneeded quotes)
It seems that tinyxml agrees with me.
But shouldn't it spot them as errors in the xml since that goes against the standard no matter how lame the standard is?
Wow, I'm suprised that works.
Well, if you're only using tinyxml then you can leave the quotes out - although personally I'd put them in, because its the "right" thing to do.
If you want to have proper XML, and also guard against the possibility that tinyxml changes to be correct in the future, then put the quotes in :)
Lee & Yves, I think its a bug ... what do you think?
http://www.w3.org/TR/WD-xml-961114.html
This is a old draft but it points out that XML is a subset of SGML and the following rules applies:
The following list describes features which are available in SGML but not in XML.
1. Tag omission
....
11. Omission of quotes on attribute values
This is what w3 schools is saying about attribute values and quotes:
Attribute values must always be enclosed in quotes, but either single or double quotes can be used.
When TinyXML was written, not requiring quotes around attribute values was a feature. It was designed for tolerant input and correct output.
Lately there has been a push to make TinyXML conform more with the spec.
I don't really know what the correct direction is. Originally I wrote TinyXML to read config files for applications. It has been wildly successful in this domain, and compliance is more or less irrelevant. But there may be use cases coming up where compliance is more important.
Feedback is appeciated.
lee
My vote: leave the present tolerant behavior as the default, but allow the client code to select quote-compliance if it wants to.
One way is to use conditional compilation. A better way, in my opinion, is to provide a function to turn quote-compliance on or off at run time. Or maybe a pair of functions, one to turn it on and one to turn it off.
Rationale: a run time switch would allow an application to be quote-compliant sometimes and not other times, for whatever reason. Conditional compilation would not permit this kind of flexibility. Also, conditional compilation tends to make the code hard to read.
I haven't looked at the parsing code to determine how hard it would be to tweak the parsing at run time. However I once did this sort of thing in another context and it wasn't a big deal.
Things get more complicated if there are other respects in which TinyXml does not conform to the spec. I don't know whether it would be better to have a single boolean setting -- tolerant or compliant -- or a series of booleans, each controlling a different aspect of compliance. I think my instinct would be to go for a single boolean setting, but some people might prefer finer-grained control.