Page MenuHomeWildfire Games

Apply stylesheet to template files
AbandonedPublic

Authored by Langbart on Tue, Aug 2, 2:57 PM.

Details

Reviewers
None
Summary
issue

Some xml attributes are incorrectly sorted and indented.

solution

make them pretty again.

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
removal of the standalone tag
  • I don't understand the purpose of the standalone="no" tag, below some related IRC conversations about it. Can I remove them?

The XML standalone element defines the existence of an externally-defined DTD. In the message tree it is represented by a syntax element with field type XML.standalone.

Source: XML.standalone

  • No .dtd files, no need for standalone="no" !
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
    • 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.
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.

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
Test Plan

Event Timeline

Langbart created this revision.Tue, Aug 2, 2:57 PM
Owners added a subscriber: Restricted Owners Package.Tue, Aug 2, 2:57 PM
Vulcan added a comment.Tue, Aug 2, 3:02 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/7376/display/redirect

Langbart edited the summary of this revision. (Show Details)Tue, Aug 2, 3:10 PM
Vulcan added a comment.Tue, Aug 2, 3:13 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/6286/display/redirect

Langbart requested review of this revision.Tue, Aug 2, 3:15 PM
lyv added a subscriber: lyv.Tue, Aug 2, 4:12 PM

I don't understand the purpose of the standalone="no" tag, below some related IRC conversations about it. Can I remove them?

Yes you can remove it, its only relevant when DTD is used to make sure its only used for validation. standalone is by default considered as no, so its doubly unnecessary.

Langbart edited the summary of this revision. (Show Details)Wed, Aug 3, 7:49 AM
Langbart removed a subscriber: s0600204.
Stan added a comment.EditedWed, Aug 3, 11:11 AM

Note there is also a sorter in https://code.wildfiregames.com/P238 . This one also sorts subcomponents which might not be wanted though. It was useful for hyrule since they have/had many duplicate subnodes.

At some point it would be nice to have a tool that removes duplicated component nodes from parents.