The task I need to accomplish is to get the value of the element attribute (ws:PriorValue="PriorValue) and map it to a field in a C# class. The way I have it now I get null. I don't work much with XML and have never used XSLT before but from what I've seen I would need to use <xsl:value-of select="" /> but I'm not quite sure how to accomplish that with the what we already have. I was able to map the value of the element (TestValue) using <xsl:with-param name="targetNode" select="ws:Additional_Information/ws:User_Name/[@Pws:PriorValue] so I know that works but obviously it's not the correct value.
Example XML
<ws:Additional_Information>
<ws:User_Name ws:PriorValue="PriorValue">TestValue</ws:User_Name>
<ws:Additional_Information>
XSLT Template:
<xsl:template name="MapElement">
<xsl:param name="targetNode" />
<xsl:param name="elementName" />
<xsl:if test="$targetNode and string-length($targetNode/text())>0">
<xsl:element name="{$elementName}" >
<xsl:value-of select="$targetNode/text()"/>
</xsl:element>
</xsl:if>
</xsl:template>
Map value to C#:
<xsl:template name="MapWorker" match="ws:Worker" mode="TransformWorker">
<Worker>
<AdditionaInformation>
<xsl:call-template name="MapElement">
<xsl:with-param name="targetNode" select="ws:Additional_Information/ws:User_Name/@ws:PriorValue" />
<xsl:with-param name="elementName" select="'PriorUserName'" />
</xsl:call-template>
<xsl:call-template name="MapElement">
<xsl:with-param name="targetNode" select="ws:Personal/ws:Name_Data[ws:Name_Type='Legal']/ws:Last_Name" />
<xsl:with-param name="elementName" select="'LastName'" />
</xsl:call-template>
<xsl:call-template name="MapElement">
<xsl:with-param name="targetNode" select="ws:Personal/ws:Name_Data[ws:Name_Type='Preferred']/ws:First_Name" />
<xsl:with-param name="elementName" select="'PreferredFirstName'" />
</xsl:call-template>
</AdditionalInformation>
</Worker>
</xsl:template>