2017-08-18 22 views
0

我々は、XMLを持っている指標は、私たちの出力は、XMLコードのスタイルシートとしてこれを使用しますが、出力XMLスタイルシートを使用してデータを抽出する方法は?

<?xml version="1.0" encoding="UTF-8"?> 
<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="/catalog/cd/line[index='1']> 
<xsl:copy> 
      <xsl:apply-templates select="@*|node()"/> 
</xsl:copy> 
    </xsl:template> 
</body> 
</html> 
を得ていない

<line index="68">Patch 26030218  : applied on Tue Aug 01 08:22:54 EDT 2017</line> 
    <line index="74">Patch 25879656  : applied on Tue Aug 01 08:22:50 EDT 2017</line> 

IAMされる文字列

<output> 

    <line index="68">Patch 26030218  : applied on Tue Aug 01 08:22:54 EDT 2017</line> 
    <line index="69">Unique Patch ID: 21310870</line> 
    <line index="70"> Created on 30 May 2017, 10:51:03 hrs PST8PDT</line> 
    <line index="71"> Bugs fixed:</line> 
    <line index="72">  26030218, 25423453</line> 
    <line index="73"></line> 
    <line index="74">Patch 25879656  : applied on Tue Aug 01 08:22:50 EDT 2017</line> 
    <line index="75">Unique Patch ID: 21310870</line> 
    <line index="76"> Created on 10 May 2017, 06:43:45 hrs PST8PDT</line> 
    <line index="77"> Bugs fixed:</line> 
    <line index="78">  20299015, 21972320, 22502493, 25369547, 18681862, 24433711, 19727057</line> 
    <line index="79">  21352646, 25879656, 23177648, 18139690, 20803583, 17343514, 19271443</line> 
    <line index="80">  19854503, 17551709</line> 
    </output> 

としてパッチを有する行を抽出する必要があります

enter image description here

答えて

1

あなたのma​​のtchがサンプル入力のものと一致しません。それは完全に異なるものからのコピー/ペーストですか?

ような何か試してみてください。私は、任意の出力を与えていない、使用

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output indent="yes"/> 
    <xsl:strip-space elements="*"/> 

    <xsl:template match="/catalog/cd"> 
    <xsl:copy-of select="line[starts-with(normalize-space(),'patch')]"/> 
    </xsl:template> 

</xsl:stylesheet> 
+0

はPIC – deepti

+0

ダニエルのおかげを参照してください、しかし、PICに私はケースを変更してから使用してきました。それは – deepti

+0

でした、あなたは写真を見ることができますか? – deepti

関連する問題