Filter large XML file with xslt and child contains text -
i have large xml file (20 mb) , want make smaller filtering relevant elements. filtering need nodes element "allterms" contains word "energy".
the xml source this:
<?xml version="1.0" encoding="utf-8" ?> <nodes> <node> <titel>the title here</titel> <allterms>term1; term2</allterms> <shorttext>&lt;div&gt;html text &lt;/div&gt;</shorttext> <nid>3433333</nid> <year>2015</year> </node> <node> <titel>the title here</titel> <allterms>term1; term2; energy</allterms> <shorttext>&lt;div&gt;html text &lt;/div&gt;</shorttext> <nid>2211338</nid> <year>2014</year> </node> </nodes>
i want create same xml xslt new xml should have <node>
<allterms>
contains word "energy".
i found examples , tried them, not seem work:
- test="contains(allterms, 'energy')
- , match="nodes/node[contains(allterms, 'energy')]
a> how should xslt desired result?
b> use internet explorer xslt , 20 mb xml smaller filtered xml? or there better tool?
thanks!
use xslt stylesheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="node[not(contains(allterms, 'energy'))]"/> </xsl:stylesheet>
to use xslt transform xml xml suggest use xml ide or editor oxygen, stylus studio, altova xmlspy or xslt plugin favorite programming editor or ide or xslt processor can run command line.
Comments
Post a Comment