Friday, January 18, 2008

Adding XSL stylesheet info line on second line of XML document

Solution for #1:
Clip the ?xml...? first line from the XML document, and copy the rest of the XML file into a temporary file. Then insert XSL tag-sheet info as well as the XML document header (which you clipped) into the original file (overwrite the file). Finally, append the temp file's contents to the original file and voila! You've inserted the XML stylesheet info on the 2nd line of your file!

num_of_lines=`cat OGCEJMeterResults.xml | wc -l`

tail -n $[$num_of_lines - 1] OGCEJMeterResults.xml > OGCEJMeterResults-temp.xml

echo (THE XML AND XSL HEAD TAGS HERE) > OGCEJMeterResults.xml

cat OGCEJMeterResults-temp.xml >> OGCEJMeterResults.xml

rm OGCEJMeterResults-temp.xml



No comments: