XSLT 删除源的样式表

XSLT remove source's stylesheet

我的 XSLT 正在工作,除了我无法删除(不是复制,删除)源文件的 <?xsl-stylesheet... element/directive.这是我的 XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
   <xsl:output method="xml" indent="yes"/>
   <xsl:template match="@* | node()">
      <xsl:copy>
         <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
   </xsl:template>

   <xsl:template match="xsl:stylesheet"/>

   <xsl:template match="TestCase">
    ... remainder of file

我试过有和没有 "?",有和没有匹配属性中的 "xsl:" 部分,没有运气。 (所以,我已经尝试将 "match" 设置为 "xsl:stylesheet""?xsl:stylesheet""stylesheet"。)xml 来源是这样开始的:

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <?xml-stylesheet type="text/xsl" href="../../testUtil testLogToHtmlDisplay.xsl" ?>
    <TestSuite Name="APIC2EChartAddRoute">

TIA。

任何以 <? 开头的东西(除了 <?xml version=...?> 声明)都是 处理指令 ,您可以将其与 [=13= 的模式匹配](对于特定的 <?name ...?>)或只是 processing-instruction()(对于任何 PI,无论名称如何,与对任何元素节点使用 * 的方式相同):

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
   <xsl:output method="xml" indent="yes"/>
   <xsl:template match="@* | node()">
      <xsl:copy>
         <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
   </xsl:template>

   <xsl:template match="processing-instruction('xml-stylesheet')"/>

   <xsl:template match="TestCase">
    ... remainder of file