Xslt code for fetching name value basing on the id value given in input



Input to the xslt is :



<input>
<id>456</id>
<class>1</class>
</input>


Below is the xml code that is stored in local file and I need to compare the input id value with the id values that are present in the below file and fetch the name value for the relevant id value.



<details>
<data>
<id>12</id>
<name>apple</name>
</data>
<data>
<id>34</id>
<name>orange</name>
</data>
</details>


sample XSLT code that I wrote



<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output method="text"/>
<xsl:variable name="consumerInfoDoc" select="document('local:///details.xml')"/>
<xsl:variable name="InputId" select="//id"/>
<xsl:variable name="Id" select="$consumerInfoDoc/details/information/id/text()"/>
<xsl:if test="$InputId=$Id">
<xsl:value-of select=" "/>
</xsl:if>
</xsl:stylesheet>


The above code that I have written is sample one, please correct it and provide the complete code. Thanks in advance.


No comments:

Post a Comment