YAML

Ken Webb 2010-05-05T21:15:41Z

YAML Ain't Markup Language (YAML) is "a human friendly data serialization standard for all programming languages". According to the wikipedia page on YAML, "Although well-suited for hierarchical data representation, it also has a compact syntax for relational data".

Any Xholon application can write out a simple YAML (or XML) snapshot of itself at any time. This is possible because both Xholon and YAML focus on hierarchical structures. This snapshot is intended only as a human-readable tool for debugging and understanding a running Xholon application.

Most Xholon applications currently read their initial structure from a set of XML files. With the use of YAML parsers instead of XML parsers, the structure of Xholon applications could be specified using YAML, although this hasn't been done yet.

As a separate feature, any subtree in a Xholon application can write itself out in a basic YAML format. The resulting content can be validated by pasting it into the online InstantYAML tool. The following is an example of YAML content produced by a Xholon app at runtime:

---
JFrame: 
 Title: Xholon meTTTa
 DefaultCloseOperation: 3
 JPanel: 
  PreferredSize: Dimension,454,310
  Background: 0xeeeeee
  JPanel: 
   PreferredSize: Dimension,300,300
   Background: 0xf0f0f0
   GridLayout: 
    Rows: 3
    Columns: 3
   JButton: 
    Text: 
    ActionCommand: select0
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
   JButton: 
    Text: 
    ActionCommand: select1
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
   JButton: 
    Text: 
    ActionCommand: select2
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
   JButton: 
    Text: 
    ActionCommand: select3
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
   JButton: 
    Text: 
    ActionCommand: select4
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
   JButton: 
    Text: 
    ActionCommand: select5
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
   JButton: 
    Text: 
    ActionCommand: select6
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
   JButton: 
    Text: 
    ActionCommand: select7
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
   JButton: 
    Text: 
    ActionCommand: select8
    MinimumSize: Dimension,100,100
    PreferredSize: Dimension,100,100
    SetFont: Monospaced,0,60
    Background: 0xffc80
  VBox: 
   JButton: 
    Text: New Game
    ActionCommand: newgame
    MinimumSize: Dimension,109,25
    PreferredSize: Dimension,109,25
    SetFont: Dialog,1,12
    Background: 0xeeeeee
   JButton: 
    Text: 
    ActionCommand: 
    MinimumSize: Dimension,34,10
    PreferredSize: Dimension,34,10
    SetFont: Dialog,1,12
    Background: 0xeeeeee
   JButton: 
    Text: Computer First
    ActionCommand: computerfirst
    MinimumSize: Dimension,139,25
    PreferredSize: Dimension,139,25
    SetFont: Dialog,1,12
    Background: 0xeeeeee
...

The following is an example of the YAML generated by a non-GUI Xholon app.

# Automatically generated by Xholon version 0.8.1
# using Xholon2Yaml.java and YamlStaxWriter.
# Wed May 05 17:01:06 EDT 2010 1273093266217
# model: Cell - BioSystems paper
# www.primordion.com/Xholon

%YAML 1.1
---
ExtraCellularSpace: 
  ExtraCellularSolution: 
    Glucose: 
      pheneVal: 100000.0
  EukaryoticCell: 
    CellMembrane: 
      CellBilayer: 
    Cytoplasm: 
      Cytosol: 
        Glucose: 
          pheneVal: 51009.046417748184
        Glucose_6_Phosphate: 
          pheneVal: 144372.47394189303
        Fructose_6_Phosphate: 
          pheneVal: 86557.89410804509
        Fructose_1x6_Biphosphate: 
          pheneVal: 86454.9265126771
        DihydroxyacetonePhosphate: 
          pheneVal: 2046.7189671743902
        Glyceraldehyde_3_Phosphate: 
          pheneVal: 122313.54521161264
        X1x3_BisphosphoGlycerate: 
          pheneVal: 102333.91436162658
        X3_PhosphoGlycerate: 
          pheneVal: 26254.358373823332
        X2_PhosphoGlycerate: 
          pheneVal: 239562.20171948127
        PhosphoEnolPyruvate: 
          pheneVal: 89324.37425501985
        Pyruvate: 
          pheneVal: 181376.2051505348
      Hexokinase: 
        pheneVal: 1.0
      PhosphoGlucoIsomerase: 
        pheneVal: 1.0
      PhosphoFructokinase: 
        pheneVal: 1.0
      Aldolase: 
        pheneVal: 1.0
      TriosePhosphateIsomerase: 
        pheneVal: 1.0
      Glyceraldehyde_3_phosphateDehydrogenase: 
        pheneVal: 1.0
      PhosphoGlycerokinase: 
        pheneVal: 1.0
      PhosphoGlyceromutase: 
        pheneVal: 1.0
      Enolase: 
        pheneVal: 1.0
      PyruvateKinase: 
        pheneVal: 1.0
...

This content can be copied and pasted into an online InstantYAML window, after logging in with to a Google account. InstantYAML offers various options to reformat the YAML content.

return to main page