简体   繁体   English

是否可以通过SHELL脚本运行XSLT文件

[英]Is it possible to run the XSLT file through SHELL script

I have the below XSLT file and I just want to run it through SHELL script. 我有下面的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>

Sample XML: 样本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>

I just want to run the above xslt against the sample XML through SHELL script and I want to use it in the JENKINS shell script editor. 我只想通过SHELL脚本对示例XML运行上面的xslt,我想在JENKINS shell脚本编辑器中使用它。

Is there any way to achieve this? 有什么办法可以做到这一点?

You need an XSLT processor to apply an XSLT style file to an XML input file. 您需要一个XSLT处理器才能将XSLT样式文件应用于XML输入文件。

We use xsltproc for this and the shell command is 我们为此使用xsltproc ,而shell命令是

xsltproc [other_options] --output output.xml style.xslt input.xml

See the xsltproc manual page for the other_options. 有关other_options的信息,请参见xsltproc手册页。 In a nutshell: 简而言之:

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 | -}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM