我有下面的 XSLT 文件,我只想通过 SHELL 脚本运行它。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="test-method[@status = 'FAIL']"/>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
XML 示例:
<?xml version="1.0" encoding="UTF-8"?>
<test-result>
<test-method status="PASS" name="beforeTestSetup" is-config="true" duration-ms="705" started-at="2018-08-16T21:39:59Z" finished-at="2018-08-16T21:39:59Z">
<params>
<param index="0">
<value>
<![CDATA[org.testng.TestRunner@31c2affc]]>
</value>
</param>
</params>
</test-method>
<test-method status="FAIL" name="beforeTestSetup" is-config="true" duration-ms="805" started-at="2018-08-16T21:39:59Z" finished-at="2018-08-16T21:39:59Z">
<params>
<param index="0">
<value>
<![CDATA[org.testng.TestRunner@31c2affc]]>
</value>
</param>
</params>
</test-method>
<test-method status="PASS" name="TEST" is-config="true" duration-ms="905" started-at="2018-08-16T21:39:59Z" finished-at="2018-08-16T21:39:59Z">
<params>
<param index="0">
<value>
<![CDATA[org.testng.TestRunner@31c2affc]]>
</value>
</param>
</params>
</test-method>
</test-result>
Run Code Online (Sandbox Code Playgroud)
我只想通过 SHELL 脚本针对示例 XML 运行上述 xslt,并且我想在 JENKINS shell 脚本编辑器中使用它。
有什么办法可以实现这一点吗?
您需要一个 XSLT 处理器来将 XSLT 样式文件应用到 XML 输入文件。
我们xsltproc为此使用的 shell 命令是
xsltproc [other_options] --output output.xml style.xslt input.xml
Run Code Online (Sandbox Code Playgroud)
有关 other_options,请参阅 xsltproc 手册页。简而言之:
SYNOPSIS
xsltproc [[-V | --version] [-v | --verbose] [{-o | --output} {FILE | DIRECTORY}] |
--timing | --repeat | --debug | --novalid | --noout | --maxdepth VALUE | --html |
--encoding ENCODING | --param PARAMNAME PARAMVALUE |
--stringparam PARAMNAME PARAMVALUE | --nonet | --path "PATH(S)" | --load-trace |
--catalogs | --xinclude | [--profile | --norman] | --dumpextensions | --nowrite |
--nomkdir | --writesubtree PATH | --nodtdattr] [STYLESHEET] {XML-FILE | -}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4111 次 |
| 最近记录: |