Aussie Mike Posted July 24, 2009 Report Share Posted July 24, 2009 xml...<Cashflow> <principalExchange id="startExchange"> <adjustedPrincipalExchangeDate>2009-06-15</adjustedPrincipalExchangeDate> <principalExchangeAmount>-23000.00</principalExchangeAmount> </principalExchange> <principalExchange id="maturityExchange"> <adjustedPrincipalExchangeDate>2009-06-16</adjustedPrincipalExchangeDate> <principalExchangeAmount>25567.00</principalExchangeAmount> </principalExchange></Cashflow>Attempted code.....based on answer i got from a similar issue <maturity_amount> <xsl:value-of select="//principalExchange[@id=$maturityExchange]/principalExchangeAmount"/></maturity_amount>As you can likely see i am wanting to extract the specific amount for maturity.In general i have been having difficulty navigating with and around these <tag attribute="value"> need to understand how to handle the syntax with these betterCheers Link to comment Share on other sites More sharing options...
boen_robot Posted July 24, 2009 Report Share Posted July 24, 2009 (edited) The example me and aalbetski gave you was supposed to be a starting point...I suppose the real problem is that you need to give each maturity_amount the corresponding principalExchangeAmount, and not that this doesn't output anything, correct?XPath syntax: nodenameSelects all child nodes of the named node /Selects from the root node //Selects nodes in the document from the current node that match the selection no matter where they are .Selects the current node ..Selects the parent of the current node @Selects attributesPurpose of xsl:for-each:The XSL <xsl:for-each> element can be used to select every XML element of a specified node-setpurpose of xsl:value-ofThe <xsl:value-of> element can be used to extract the value of an XML element and add it to the output stream of the transformationNOTE: xsl:value-of returns only the first results from the resulting node-set.With that in mind, here's an excersize for you:<xsl:for-each select=" get all elements for which you want to create a maturity_amount element "><maturity_amount> <xsl:value-of select=" select the one node you need the value of... keep in mind that "//" usually matches multiple nodes "/></maturity_amount></xsl:for-each> Edited July 24, 2009 by boen_robot Link to comment Share on other sites More sharing options...
Aussie Mike Posted July 24, 2009 Author Report Share Posted July 24, 2009 Thanks. The answer from the other covered this. I was aware of the <xsl:for each> option, but need to output these in wildly different places in my xml with indiviual tags. So the single extraction method seems best.Apologies for being a pain, but i am 4 days into my xslt life. I seem to have also inherited an xml feed that is incorporating every possible way of structuring the data. I've used nearly every command i've found. :-)Cheers for the help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now