lizmehta 0 Newbie Poster

Hi,
I am just a beginner to XSLT.

My Input XMLs is like -

<?xml version="1.0" encoding="UTF-8"?>
<ABC>
<filter>
<name>Key Value</name>
<value><![CDATA[A=344#B=123445#C=432#D=1432#E=16485]]></value>
</filter>
</ABC>

I have made a XSLT which will fetch the value of above Key_Value

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="ABC">
<xsl:variable name="UsefulData">
<xsl:for-each select="filter">
<xsl:if test="name/text()='Key Value'">
<xsl:value-of select="value/text()"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:call-template name="Value">
<xsl:with-param name="input" select="$UsefulData"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="Value">
<xsl:param name="input"/>
<xsl:if test="$input != ''">
<xsl:element name="Name">
<xsl:value-of select="substring-before($input,'=')"/>
</xsl:element>
<xsl:element name="Value">
<xsl:variable name="Out">
<xsl:if test="substring-before($input,'#')=''">
<xsl:value-of select="substring($input,1)"/>
</xsl:if>
<xsl:value-of select="substring-before($input,'#')"/>
</xsl:variable>
<xsl:value-of select="substring-after($Out,'=')"/>
</xsl:element>
<xsl:call-template name="Value">
<xsl:with-param name="input" select="substring-after($input,'#')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>


</xsl:stylesheet>

The above XSLT will give the output in below Format -

<Name>A</Name><Value>344</Value><Name>B</Name><Value>123445</Value><Name>C</Name><Value>432</Value><Name>D</Name><Value>1432</Value><Name>E</Name><Value>16485</Value>

But in the above XSLT, i also want to fetch the value of each Name Tag and assign it to some Variable.Like for <A> tag i want to fetch the value 344 and assign it to some variable called as temp. Is it possible to fetch the value if i have used<xsl:element> in XSLT.i want to write the logic in the same XSLT to fetch the value .Is it possible.? This is required urgently.Can somebody help?

Thanks in Advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.