Page 1 of 1

Writing custom XML namespace to recipe

PostPosted: Sat Jul 05, 2014 2:51 pm
by doctorjames
I'm in the process of writing a simple python script to read the schedule information from a BeerTools recipe and use it to automatically control my HLT PID and RIMS PID via RS485/modbus. The BeerTools XML format is great and very easy to utilise for this purpose (thank you @jeff!).

What I would like to do is add annotations to the recipe XML using my own arbitrary XML namespace declared in my own node (in this case to record the actual measured temperature profile, heater performance, etc.) Could there be a <b:annotations /> node added to the XML format that is invisible in the BeerTools interface but loaded and saved (untouched) when a recipe is loaded into BeerTools?

I'd personally also use this to store water treatment information from Bru'n'water as well. (You could perhaps add an add attachment option in the interface to save arbitrary other documents in the recipe file — people might find it handy for adding photographs as well as spreadsheets, though that might quickly make the XML unwieldy and be better to suited to an XML in archive type format.)

At the present time the ability to store a small amount of my own valid XML in the file would be perfectly fine for my purposes, recognising of course that if I write invalid XML and BeerTools fails to load a recipe that's my fault!

Cheers,
James

Re: Writing custom XML namespace to recipe

PostPosted: Mon Jul 21, 2014 9:27 am
by jeff
Version 2.0.9 adds support for <b:Extra/> container elements inserted as the last child element of these complex types:

  • <b:Recipe/>
    • <b:Ingredients/>
      • <b:Grain/>
      • <b:Extract/>
      • <b:Adjunct/>
      • <b:Hop/>
      • <b:Special/>
      • <b:Yeast/>
    • <b:WaterChemistry/>
      • <b:MineralSalt/>
      • <b:Water/>
    • <b:Style/>
    • <b:BrewingSystem/>
      • <b:HeatSource/>
      • <b:Vessel/>
    • <b:Schedule/>
      • <b:MashIn/>
      • <b:Infusion/>
      • <b:Decoction/>
      • <b:DirectHeat/>
      • <b:Rest/>
      • <b:Transfer/>
      • <b:FlySparge/>
      • <b:BatchSparge/>
    • <b:VolumeAdjustments/>
      • <b:VolumeAdjustment/>
      • <b:PercentVolumeAdjustment/>
    • <b:Packaging/>
      • <b:Package/>

When inserting data in the <b:Extra/> container it is best to create your own namespace to avoid collisions with the work of other developers. For example, you can insert your own element this way:

Code: Select all
<b:Recipe xmlns:b="http://www.beertools.com/btp" version="2.0.9.26">
...
<b:Extra>
<mynamespace:ContestResults xmlns:mynamespace="http://mydomain.com/btpcontestresults">
<mynamespace:Contest>Southern Homebrew Fest 2014</mynamespace:Contest>
...
</mynamespace:ContestResults>
</b:Extra>
</b:Recipe>

Re: Writing custom XML namespace to recipe

PostPosted: Mon Jul 21, 2014 10:24 am
by doctorjames
That's perfect! Thanks a lot.

James