Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:02:54

0001 #!/bin/bash
0002 
0003 #included files
0004 detector_file="./epic.xml"
0005 
0006 #filelist=$(xmllint --format --xpath '//include/@ref' ${detector_file}   | sed 's/ref=\"//g' | sed 's/\"/\n/g' )
0007 #echo $filelist
0008 
0009 # Searches for included files two levels down
0010 get_includes() {
0011   local input_file="${1}"
0012   #echo ${1}
0013   local filelist=$(xmllint --format --xpath '//include/@ref' ${input_file}   | sed 's/ref=\"//g' | sed 's/\"//g' )
0014   for afile in $filelist ; do
0015     xmllint --format --xpath '//include/@ref' ${input_file}  &> /dev/null
0016     local res="$?"
0017     if [ "${res}" == "0" ]  ; then
0018       local subincluded=$(xmllint --format --xpath '//include/@ref' ${input_file}  2> /dev/null | sed 's/ref=\"//g' | sed 's/\"//g' )
0019       filelist="${filelist} ${subincluded}"
0020       #echo "sub include $afile"
0021     fi
0022   done
0023   # <includes > <gdmlFile > <file>
0024   local otherfiles=$(xmllint --format --xpath '//includes/file/@ref | //includes/gdmlFile/@ref' ${input_file}   | sed 's/ref=\"//g' | sed 's/\"/\n/g' )
0025   #echo $otherfiles
0026   filelist=$(echo "${filelist} ${otherfiles}" | sed 's/ /\n/g' | sort | uniq )
0027   echo "$input_file $filelist"
0028 }
0029 
0030 
0031 xml_files=$(get_includes ${detector_file})
0032 #echo $xml_files
0033 
0034 get_doc_levels() {
0035   # levels
0036   local levels=0
0037   for afile in $xml_files ; do
0038     xmllint --format --xpath '//documentation/@level' $afile  &> /dev/null
0039     local res="$?"
0040     if [ "${res}" == "0" ]  ; then
0041       local new_levels=$(xmllint --format --xpath '//documentation/@level' $afile  2> /dev/null  | sed 's/level=\"/ /g' | sed 's/\"//g' )
0042       levels="${levels} ${new_levels}"
0043     fi
0044     # see if there are tags without level attribute
0045     xmllint --format --xpath '//documentation[not(@level)]' $afile  &> /dev/null
0046     if [ "${?}" == "0" ] ; then
0047       #echo "DERP"
0048       levels="${levels} 100"
0049     fi
0050   done
0051   echo "$levels" | sed 's/ /\n/g' | sort  | uniq
0052 }
0053 
0054 all_levels=$(get_doc_levels ${xml_file_array})
0055 #echo " levels: "
0056 #echo $all_levels
0057 
0058 for alevel in $(echo ${all_levels} | sed 's/ /\n/g' | sort -n  | uniq ) ; do
0059   #echo " doing level $alevel ..."
0060   for afile in $(echo $xml_files | sed 's/ / \n/g') ; do
0061     #echo $afile
0062     #xmllint --format --xpath '//documentation[@level="'"$alevel"'"]/text()' $afile
0063     level_doc=$(xmllint --format --xpath '//documentation[@level="'$alevel'"]' ${afile} 2> /dev/null )
0064     if [ "$?" -eq "0" ] ;  then
0065       xmllint --format --xpath '//documentation[@level="'$alevel'"]/text()' ${afile} | sed -re 's/<\/?\w+>//g' | sed 's/^[[:space:]]*#/#/g'
0066     fi
0067     # sets the tags without attribute level to 100
0068     xmllint --format --xpath '//documentation[not(@level)]/text()' ${afile} &> /dev/null
0069     if [ "$?" -eq "0" ] ;  then
0070       if [ "$alevel" -eq "100" ] ; then
0071         xmllint --format --xpath '//documentation[not(@level)]/text()' ${afile} | sed -re 's/<\/?\w+>//g' | sed 's/^[[:space:]]*#/#/g'
0072       fi
0073     fi
0074   done
0075 done
0076 
0077 
0078 
0079 #${DETECTOR_PATH}=.
0080 #
0081 #
0082 #xmllint --format --xpath '//
0083 #
0084 #xmllint --format --xpath '//documentation/text()' ${DETECTOR_PATH}/epic.xml | sed -re 's/<\/?\w+>//g' | sed 's/^[[:space:]]*#/#/' | tee  doc/detector.md
0085 #xmllint --format --xpath '//documentation/text()' ${DETECTOR_PATH}/ip6/ip6_defs.xml | sed -re 's/<\/?\w+>//g' | sed 's/^[[:space:]]*#/#/' | tee -a doc/detector.md || true
0086 #for afile in ${DETECTOR_PATH}/compact/*.xml ; do
0087 #  xmllint --format --xpath '//documentation/text()' ${afile} | sed -re 's/<\/?\w+>//g' | sed 's/^[[:space:]]*#/#/' | tee -a doc/detector.md || true
0088 #done
0089 #