<?xml version="1.0" encoding="utf-8" ?> <Parameters xmlns="http://www.tempuri.org/Parameters"> <Client> <Name First="Pat" Last="Jones" /> <DateOfBirth Month="5" Day="6" Year="1987" /> </Client> <AnalysisDate Month="1" Day="16" Year="2006" /> </CalculatorParameters>I am transforming XML to XML. What I want to transform my data to is,
<?xml version="1.0" encoding="utf-8" ?> <Parameters xmlns="http://www.tempuri.org/CalculatorParameters"> <Client> <Name First="Pat" Last="Jones" /> <DateOfBirth Age="19"/> </Client> <AnalysisDate Month="1" Day="16" Year="2006" /> </Parameters>I tried using an absolute path in my XSLT,
<xsl:template match="DateOfBirth"> <DateOfBirth> <xsl:attribute name="Age"> <xsl:value-of select="/Parameters/Client/DateOfBirth/@Year - @Year"/> </xsl:attribute> </ClientDateOfBirth> </xsl:template>and also a relative one,
<xsl:value-of select="../../AnalysisDate/@Year - @Year"/>but both times, my Age attribute comes out empty, not 19. There must be something about XPaths that I am missing. I have looked at the documentation that I have, but it still isn't clear.