XSLT删除源的样式表

MJF*_*MJF 2 xml xslt

我有我的XSLT工作,除了我不能让它删除(不复制,删除)源文件的<?xsl-stylesheet...元素/指令.这是我对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
Run Code Online (Sandbox Code Playgroud)

我已经尝试了有和没有"?",有和没有"xsl:"匹配属性中的部分,没有运气.(所以,我一直在尝试,"匹配"是"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">
Run Code Online (Sandbox Code Playgroud)

TIA.

Ian*_*rts 8

任何启动<?(除了<?xml version=...?>声明之外)都是一个处理指令,您可以将其与processing-instruction('name')(特定的<?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
Run Code Online (Sandbox Code Playgroud)