It must be added after the root element. (As an XML file must have only one root element)
This can be automated with a bash script like the following:
echo "fixing index.html's"
HTMLS=$(find photos -type f \( -iname "index.html" -not -iwholename "*svn*" \) )
for H in $HTMLS
do
sed ' /^<head>/ i\ <pathtoroot>../../</pathtoroot> ' "$OUTDIR/$H" > "$OUTDIR/$H"_tmp
mv "$OUTDIR/$H"_tmp "$OUTDIR/$H"
done
echo "fixing IMG_.. html's"
HTMLS=$(find photos -type f \( -iname "IMG_*.html" -not -iwholename "*svn*" \) )
for H in $HTMLS
do
sed ' /^<head>/ i\ <pathtoroot>../../../</pathtoroot> ' "$OUTDIR/$H" > "$OUTDIR/$H"_tmp
mv "$OUTDIR/$H"_tmp "$OUTDIR/$H"
done
<xsl:variable name="relPath"><xsl:value-of select="/html/pathtoroot"></xsl:value-of> </xsl:variable>