How to extract data using XML stylesheet? -
we have xml , need extract line index having patch string
<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>
our output
<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 using xml code stylesheet, not getting output
<?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>
your match of /catalog/cd/line[index='1']
doesn't match in sample input. copy/paste different?
try like:
<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>
Comments
Post a Comment