#! /bin/csh

#
# Put JMRI decoder file(s) in normal form.
#
#*) If there's no item attribute, create from the label attribute
#*) Create a label element with default language if none present.
#*) Removing redundant label attributes from variable elements:   
#*) Standardize layout of the content
#
# Output is sent to a (created, if need be) tmp subdirectory in the wd, using the
# same file names.
#
# Known to work on Mac OS X, expected to work on Linux, Windows situation not clear.
#
# See also i18nDecoder for internationalization transform
#
#  Bob Jacobsen 3/2014
# 
mkdir tmp >& /dev/null
foreach x ( $* )
 cat $x |\
    xsltproc decoderLabelToItem.xsl - |\
    xsltproc decoderAddLabelElement.xsl - |\
    xsltproc decoderPaneAddNameElement.xsl - |\
    xsltproc decoderPaneLabelToText.xsl - |\
    xsltproc decoderAddPaneLabelTextElement.xsl - |\
    xsltproc decoderSuppressRedundantLabel.xsl - |\
    xsltproc decoderPaneSuppressLabelAttribute.xsl - |\
    xsltproc decoderPaneSuppressNameAttribute.xsl - |\
    xmllint -format - > tmp/$x:t
end


# just formatting
# cat $x | tr -d '\r' | xmllint -format - > tmp/$x:t
