In this case, the identity transforms is for no use. I would try:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg= "http://www.w3.org/2000/svg"
xmlns:xhtml= "http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:output method="xml" doctype-public="-//W3C//DTD SVG 1.1//EN" doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" />
<xsl:template match="/">
<xsl:copy-of select="/*/xhtml:body//svg:svg"/>
</xsl:template>
</xsl:stylesheet>
EDIT: If you want to beautify things a bit:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg= "http://www.w3.org/2000/svg"
version="1.0">
<xsl:output method="xml" doctype-public="-//W3C//DTD SVG 1.1//EN" doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" />
<xsl:template match="text()"/>
<xsl:template match="svg:svg">
<xsl:call-template name="svg"/>
</xsl:template>
<xsl:template match="svg:*" mode="svg" name="svg">
<xsl:element name="{substring-after(name(),':')}" namespace="http://www.w3.org/2000/svg">
<xsl:apply-templates select="@*|node()" mode="svg"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*" mode="svg">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
Edit 2: Dimitre brings us an interesting problem. What if the input structure isn't like the one that was provided?
One case: there are text nodes in head
or body
. I've edited both answer according.
Other case: SVG is inside some XHTML markup. I've edited both answer according.
Worst case: there are several svg
elements. In this case you would need to wrap every each svg
element into one.