==== issue
Some xml attributes are incorrectly sorted and indented.
==== solution
make them pretty again.
```lang=zsh, name=templatessorter
# Transform all template XML files with a specific XSL stylesheet:
find ~/0ad/binaries/data/mods/public/simulation/templates -name '*.xml' -print0 | while IFS= read -r -d '' file; do xsltproc -o "$file" ~/0ad/source/tools/templatessorter/templatessorter.xsl "$file"; done
```
==== question
- I don't understand the purpose of the `standalone="no"` tag, below some related IRC conversations about it. Can I remove them?
- [[ https://irclogs.wildfiregames.com/%230ad-dev/2017-01-06-QuakeNet-%230ad-dev.log | Stan ]]
- the mentioned wiki article by @Stan contained some `standalone` tags for GUI files but they were all removed by @s0600204 (17/Dec/21 - [[ https://trac.wildfiregames.com/wiki/GUI_-_XML_Files?version=2 | wiki/GUI_-_XML_Files?version=2 ]] )
```lang=log, name="IRC #0ad-dev 6/Jan/17"
15:09 < Stan`> Does anyone knows what standalone="no" stands for in XML files ?
[...]
15:09 < Stan`> @wiki:GUI_-_XML_Files
```
- [[ https://irclogs.wildfiregames.com/%230ad-dev/2022-05-06-QuakeNet-%230ad-dev.log | Freagarach/ wraitii ]]
```lang=log, name="IRC #0ad-dev 6/May/22"
11:05 < Freagarach_afk> You had some "standalone" tags in mixins?
[...]
11:19 < wraitii> @tell freagarach: yes, don't remember if the standalone tag is actually used. But this root-level "template_" thing is definitely very bad™
[...]
12:15 < Freagarach_afk> wraitii: The standalone tag isn't used, indeed.
```
==== {icon exclamation-triangle, color=yellow} note
- This patch does not touch any template xml files that have comments in them, see #4550 for more details.
- the order demands **all** comments to be listed below `<Entity parent=...` rather than leaving the comments near the component
- [[ https://code.wildfiregames.com/source/0ad/browse/ps/trunk/binaries/data/mods/public/simulation/templates/special/filter/corpse.xml | corpse.xml ]] is such a candidate with lots of comments
- No changes are made to some files, but all their contents are listed, e.g. `tent_mace.xml`. I suspect that it is just the line terminators.
```lang=zsh, name=tent_mace.xml
# this patch being applied
file --brief tent_mace.xml
XML 1.0 document text, ASCII text
#without the patch (rP27025)
file --brief tent_mace.xml
XML 1.0 document text, ASCII text, with CRLF line terminators
```
===== mods
Mods like Delenda Est (@wowgetoffyourcellphone ) can also apply the Template Sorter to their files.
```lang=zsh,name=Delenda Est
# 1st file path to the template folder
# 2nd file path to the templatessorter.xsl file
find ~/Library/Application\ Support/0ad/mods/delenda_est/simulation/templates -name '*.xml' -print0 | while IFS= read -r -d '' file; do xsltproc -o "$file" ~/0ad/source/tools/templatessorter/templatessorter.xsl "$file"; done
# Number of affected files
git diff --stat | tail -1
242 files changed, 942 insertions(+), 942 deletions(-)
# 1 error
./skirmish/units/default_support_slave_female.xml:1: parser error : Start tag expected, '<' not found
5<?xml version="1.0" encoding="utf-8"?>
^
unable to parse ./skirmish/units/default_support_slave_female.xml
```