YAML vs JSON vs XML?

Started by
21 comments, last by Ravyne 10 years, 7 months ago


<components>
<component wieldable="true" />
</components>

That's a little weird. Why is wieldable a property of component? Isn't wieldable the component? Would you want to define multiple component properties on the same component like <component wieldable="true" throwable="true" />? Are you meant to enumerate all components of the item in a single component? If so, what's the purpose of the <components> parent element? Can a component property ever be false? What does that mean? Why not just leave it out in the first place? Is it more than a binary state?

throw table_exception("(? ???)? ? ???");

Advertisement

Well isn't wieldable just a boolean state? And item can have components, so having a component element can't be that strange? As an (Final Fantasy 7) example, an item would be a sword with name: DragonFang. It can have components such as: spells and materia. Spells are castable and Materia are wieldable or equippable.

Or maybe I've just completely misunderstood the XML schema.

Beginner in Game Development?  Read here. And read here.

 

Sure, what you posted succeeds at encoding the information, I just think there are better ways to encode it. Like you said, whether something is "wieldable" or not is a Boolean state, but there's many ways to encode that -- as a property on an element as you've done is one way, the presence of an element named <wieldable> is another. In the former, one has to modify the component element schema every time a new component ability is added (component is going to keep growing too!), in the latter, you just define a new element type and add it to the list of acceptable child elements of <componenents>. In the former, its difficult to add any information about the wieldable-ness of the object -- perhaps its only wieldable by a certain class of character, or requires a certain amount of strength to wield-- in the latter, because wieldable is its own element, it can have its own properties and child elements that further describe it, and everything is neatly organized -- Wieldable might have an entirely different set of properties and children that describe it than Equipable does.

This goes back to one of the things I said early on, which is that unlike JSON or YAML, XML is as much a language for describing the data format as it is for exchanging data using said format. Its a truly structured document, rather than a list of information loosely organized by convention alone. Because of this, the way you structure your format has a big impact not only on your data interchange, but also on the effectiveness of other very useful tools in the XML ecosystem, like validators, XSLT, and XPath.

throw table_exception("(? ???)? ? ???");

This topic is closed to new replies.

Advertisement