-
Notifications
You must be signed in to change notification settings - Fork 5
attributes
What make xml very powerful is not just custom datatypes (YAML can do that), but also attributes.
<step number="3">Connect A to B.</step>
<div class="inner greeting-box" >Hello!</div>
Is there any similar mechanism in YAML? If not, then this might be some approach to include such data
e: (!complex type=rad ) 123/_32 # use quotes for attribute values if not a single word or number attribute.
e: (!complex) 123/_32 {type:rad}
e: (!complex {type:rad} ) 123/_32 # Looks a bit messy.
I think the first option looks most practical. Less chance of confusion with the values.
Hmmm... This looks like it could actually work. Not sure if want more complicated than Key:value however
e: !complex{type:rad} 123/_32 # could work?
Otherwise you get something weird like:
e: !complex{type:rad,markup:{color:red,font:32}} 123/_32
Might end up getting rather messy, if people add weird metadata in type declaration. But then again, it might not matter if it lets this format become rather flexible without making the parser too complex (after all, its just inline "json" like syntax).
It would do us well to note what xml can do that YAML currently cannot do. Below is copied from https://en.wikipedia.org/wiki/YAML
XML and SDL[edit]
YAML lacks the notion of tag attributes that are found in XML and SDL.[13] For data structure serialization, tag attributes are, arguably, a feature of questionable utility, since the separation of data and meta-data adds complexity when represented by the natural data structures (associative arrays, lists) in common languages.[14] Instead YAML has extensible type declarations (including class types for objects). YAML itself does not have XML's language-defined document schema descriptors that allow, for example, a document to self-validate. However, there are several externally defined schema descriptor languages for YAML (e.g. Doctrine, Kwalify and Rx) that fulfill that role. Moreover, the semantics provided by YAML's language-defined type declarations in the YAML document itself frequently relaxes the need for a validator in simple, common situations. Additionally, YAXML, which represents YAML data structures in XML, allows XML schema importers and output mechanisms like XSLT to be applied to YAML.