使用支持模式的处理器(如Saxon 9 EE或Altova XMLSpy/Raptor),您可以使用
//element(*, Animal)
(
https://www.w3.org/TR/xpath-31/#doc-xpath31-ElementTest
)选择该类型的所有图元
Animal
,样式表如下所示
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
exclude-result-prefixes="xs math"
version="3.0">
<xsl:import-schema schema-location="Zoo.xsd"/>
<xsl:template match="/">
<xsl:copy-of select="//element(*, Animal)"/>
</xsl:template>
</xsl:stylesheet>