xslt - choosing specific column value from the input xml -
i have below xml input have xsl transformation
<emml> <tradeeventheader> <tradeidentifier> <tradeid>104823343913</tradeid> <systemreference>rds</systemreference> <systemdomainname>internal</systemdomainname> </tradeidentifier> <tradestateidentifier> <tradestateid>validated</tradestateid> <systemreference>rds</systemreference> <tradestateidclassificationscheme>vn state</tradestateidclassificationscheme> </tradestateidentifier> <tradestateidentifier> <tradestateid>pending</tradestateid> <systemreference>swapswire</systemreference> <tradestateidclassificationscheme>mang state</tradestateidclassificationscheme> </tradestateidentifier> <tradestateidentifier> <tradestateid>accpt_novated_sw</tradestateid> <systemreference>rds</systemreference> <tradestateidclassificationscheme>clearing state</tradestateidclassificationscheme> </tradestateidentifier> </tradeeventheader> <emmlextension systemid="rds yto"> <emmlmediumstring idref="legid1" name="roll date option">short initial</emmlmediumstring> </emmlextension> </emml>
as shown above in input xml objective identify value of tradestateidclassificationscheme parameter , if value of parameter equal 'clearing state' correspond have check value of column tradestateid , if value of column tradestateid starts accpt_novated_sw in case need return true string , rest other need return false string ..
i have come below template in xslt 1.0 , please advise correct approach..
calling template :-
<isclearednovated> <xsl:call-template name="cleared_novated"> <xsl:with-param name="tradestateid" select="emml/*/*/tradestateidentifier" /> </xsl:call-template> </isclearednovated> called template :- <xsl:template name="cleared_novated"> <xsl:param name="tradestateid" /> <xsl:for-each select="$tradestateid/tradestateidclassificationscheme"> <xsl:choose> <xsl:when test="$tradestateid[starts-with(tradestateidclassificationscheme,'accpt')] , systemreference='rds'"> <xsl:value-of select="'true'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="'false'"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template>
i don't understand, needs are, xslt not want - suspect nothing...
so maybe can start suggestion below , can tell, has refined:
<?xml version="1.0" encoding="utf-8"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:apply-templates select="//tradestateidclassificationscheme"/> </xsl:template> <xsl:template match="tradestateidclassificationscheme[ . = 'clearing state' , ../tradestateid = 'accpt_novated_sw' , ../systemreference = 'rds' ]"> <xsl:value-of select="concat(.,': true
')"/> </xsl:template> <xsl:template match="tradestateidclassificationscheme"> <xsl:value-of select="concat(.,': false
')"/> </xsl:template> <xsl:template match="@*|*"/> </xsl:transform>
you find 2 templates dealing tradestateidclassificationscheme
, 1 matches conditions, , 1 others.
note didn't write contents of systemreference
, while trial template addresses element. therefore, added condition well.
the output in version is:
vn state: false mang state: false clearing state: true
Comments
Post a Comment