|
|
The XML formatted input files in OSR are often long and spread over several files, such that it is not easy to have an overview. In the scripts/XML folder XML transformation sheets (XSL) and html style sheets (css) are provided which can be used to transform XML into html and render it in a browser in much shorter form (as a nested list). For example see this [modelDump000.00.xhtml](modelDump000.00.xhtml). Modern browsers will do the transformation, as long as the xml and css files are in the same or a lower sub directory from the xml file.
|
|
|
The XML formatted input files in OSR are often long and spread over several files, such that it is not easy to have an overview. In the `scripts/XML` folder XML transformation sheets (XSL) and html style sheets (css) are provided which can be used to transform XML into html and render it in a browser in much shorter form (as a nested list). For example see this [modelDump000.00.xhtml](modelDump000.00.xhtml). Modern browsers will do the transformation, as long as the xml and css files are in the same or a lower sub directory from the xml file.
|
|
|
|
|
|
Since we would like all the XML to be in one file, and would prefer better formatting of names and units, we will first use the modeldump export function in OSR to create one file. Then we will open this file with a browser.
|
|
|
|
|
|
steps:
|
|
|
|
|
|
1. Enable model dump for day 0 in your simulation control parameter file.
|
|
|
2. Copy the scripts/XML folder into you folder with InputFiles
|
|
|
2. Copy the `scripts/XML` folder into you folder with `InputFiles`
|
|
|
3. Run model for 1 day or so
|
|
|
4. Open model dump with Firefox, and you should see a needly formatted list instead of XML
|
|
|
|
... | ... | @@ -31,4 +31,20 @@ note 2: 5. Deleted from the XML any tags that you do not need to shorten the who |
|
|
```
|
|
|
|
|
|
|
|
|
## Alternate approach: Generate a static HTML version
|
|
|
|
|
|
Some browsers treat XSL transformations as a potential security problem, and therefore require extra steps (different for each browser) before they will display the model summary correctly. If you aren't comfortable bypassing security features or just don't want to mess with your browser settings, one alternate approach is to apply the transformations in your programming language of choice, save the results as a single HTML file, then display that in your browser.
|
|
|
|
|
|
A simple example using R:
|
|
|
|
|
|
```
|
|
|
# install.packages("xslt”)
|
|
|
model_dump <- xml2::read_xml(“~/path/to/modelDump000.00.xml”)
|
|
|
stylesheet <- xml2::read_xml(“~/path/to/outlineview.xsl”)
|
|
|
transformed <- xslt::xml_xslt(model_dump, stylesheet)
|
|
|
xml2::write_xml(x = transformed, file = “~/path/to/modelSummary.html”))
|
|
|
```
|
|
|
|
|
|
You should now be able to open `modelSummary.html` in your browser and treat it identically to the version you would have gotten using the transform-in-browser approach.
|
|
|
|
|
|
One drawback of this method is that it generates an extra file which then needs to be updated whenever your model dump changes. If you plan to generate model summaries routinely, consider making one script that regenerates all the files so that none get forgotten. |