Jump to content

Displaying Specific Duplicated Tags


Recommended Posts

Hi all,Really need help on this one. Am completely new to XSLT.I have an xml that has repetitive tags. I need to display one of the repeated tags based on the value of another repeated tag.i.e. i need to display the specific <tradeId> when <systemDomainName> = TIDSo i need to locate the right <systemDomainName> under <tradeIdentifier> parent (term?) and display the <tradeId> that occurs under the same parent (term?)Have looked at xsl:if, xsl:choose examples and tutorials, but i don't seem to be able to get it right. I think it will be very easy when i see it.Cheers<tradeIdentifier> <tradeId>730397523000000</tradeId> <tradeVersion>1</tradeVersion> <systemReference>System1</systemReference> <systemDomainName>TID</systemDomainName> <tradeIdClassificationScheme>Primary Transaction Identifier</tradeIdClassificationScheme> </tradeIdentifier><tradeIdentifier> <tradeId>0906150186305</tradeId> <systemReference>System1</systemReference> <systemDomainName>DEAL_NUMBER</systemDomainName> <tradeIdClassificationScheme>Secondary Transaction Identifier</tradeIdClassificationScheme> </tradeIdentifier><tradeIdentifier> <tradeId>MM0906153032</tradeId> <systemReference>System1</systemReference> <systemDomainName>EXT_TRADE_NO</systemDomainName> </tradeIdentifier>

Link to post
Share on other sites

Good luck with your XSLT programming journey!This will get you going to find what your'e looking for, It says, look at all the tradeIdentifer nodes and then find the one that has a child node called systemDomainName with a value of 'TID', When found, return the tradeId node value.

<xsl:value-of select="//tradeIdentifier[systemDomainName = 'TID']/tradeId"/>

Edited by aalbetski
Link to post
Share on other sites

Have hit another stumbling block on selecting specific duplicated tags.When the node has an attribute in it.Want to be able to extract <adjustedPrincipalExchangeDate> for <principalExchange id="startExchange"><principalExchange id="startExchange"> <adjustedPrincipalExchangeDate>2009-07-17</adjustedPrincipalExchangeDate> <principalExchangeAmount>-20000000.00</principalExchangeAmount> </principalExchange>-<principalExchange id="maturityExchange"> <adjustedPrincipalExchangeDate>2009-10-19</adjustedPrincipalExchangeDate> <principalExchangeAmount>20000000.00</principalExchangeAmount> </principalExchange>Cheers

Link to post
Share on other sites

'scuse me, have you read the XPath tutorial? You mentioned you're new to XSLT, and that's OK, but XSLT uses XPath. You need XPath to use XSLT up to its full potential.aalbetski has already given you the solution. Just rename the element names, and use an attribute selector in the predicate (and if you don't know what "predicate" means, read the XPath tutorial (again?)):

<xsl:value-of select="//principalExchange[@id = 'startExchange']/adjustedPrincipalExchangeDate"/>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...