Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't figure out XPath for XSLT
Message
De
16/01/2006 16:41:36
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
XML
Titre:
Can't figure out XPath for XSLT
Versions des environnements
Database:
MS SQL Server
Divers
Thread ID:
01087342
Message ID:
01087342
Vues:
49
I am having trouble doing math in an XSLT. I think that I am not handling my Xpath correctly. My XML is,
<?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.

Can anyone see what my mistake is?
David S. Alexander
Kettley Publishing
20271 SW Birch Street, 2nd Floor
Newport Beach, CA 92660-1752
Répondre
Fil
Voir

Click here to load this message in the networking platform