0
我試圖使用XSLT從HTML文件中消除某些標記(腳本&標題)。XSL:從HTML代碼中消除標記
這是我的源文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript" src=
"popup_html.js">
</script>
<!-- Redirect browser to frame page if page is not in the content frame. -->
<script type="text/javascript">
//<![CDATA[
<!--
if(top.frames.length==0) { top.location.href="index.html?3_plus_4.htm"; }
else { parent.lazysync('3_plus_4.html'); }
//-->
//]]>
</script>
<script type="text/javascript" src="highlight.js">
</script>
<title>3+4</title>
<body></body>
</html>
這是我的XSLT文件:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="" >
<xsl:output method="html" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match = "script"/>
<xsl:template match = "title"/>
</xsl:stylesheet>
而這(與http://www.freeformatter.com/xsl-transformer.html產生)輸出文件:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript" src="popup_html.js" />
<!-- Redirect browser to frame page if page is not in the content frame. -->
<script type="text/javascript">//
<!--
if(top.frames.length==0) { top.location.href="index.html?3_plus_4.htm"; }
else { parent.lazysync('3_plus_4.html'); }
//-->
//</script>
<script type="text/javascript" src="highlight.js" />
<title>3+4</title>
<body />
</html>
正如你所看到的輸出仍然有標題和腳本標籤。我需要在我的XSLT文件中更改以擺脫它們?