So, there are basically 2 things people use XSLT for. You can use it to
extract data, or you can use it for
templating. The former is generally trivial (it's generally just a set of hard-coded output nodes + some xpath), so I'll only discuss the latter.
For templating, there's a simple rule: always start with the identity transform:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
(In particular note that `xsl:copy` is the only bit here that's largely interchangeable with non-xsl nodes in the stylesheet.)
Then, generally, you'll add `xsl:template`s that `match` some hard-coded node names (or the root) and add some other structure instead of `xsl:copy` before (if not switching to simple extraction) calling xsl:apply-templates at a deeper depth.
In my experience, attributes are likely to only ever be copied all at once or not at all (e.g. if only made available for extraction), whereas nodes are likely subject to more complicated logic.
For the specific case of a header-footer template, you'd match the root and hard-code the structure instead of using xsl-copy, then use apply-templates where you want to insert the main body from the file that's calling the template.
Also, remember you can test with `xsltproc` to avoid browser overhead. `xmllint --xpath` is useful for selectors as well.