XSLT using a sibling node to generate xml



I have the following xml



<FRA>
<Id>USD Libor Futures</Id>
<FRA>


I would like the following output



<FRA>
<Id>USD Libor Futures</Id>
<ModifyMktData srcid="USD Libor Futures Convexity" optype="add" srctype="spread" dsttype="rate"/>
</FRA>


I am using the following xslt:



<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="FRA/PriceBasis">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
<xsl:variable name="fraid" select="Id"/>
<ModifyMktData>
<Update srccontractid="{$fraid} Convexity" optype="add" srctype="Spread" dsttype="Price"/>
</ModifyMktData>
</xsl:template>
</xsl:stylesheet>


I am essentially looking to reuse the Id in the attribute for ModifyMktData. Obviously the xslt I have does not work as I would like it to. Thanks in advance.


No comments:

Post a Comment