xsl key - multiple levels for an element
Posted
by
user1004770
on Stack Overflow
See other posts from Stack Overflow
or by user1004770
Published on 2011-11-20T05:43:22Z
Indexed on
2011/11/20
9:50 UTC
Read the original article
Hit count: 335
My previous post was not very meaningful. reposting here. What i am looking for is the QueueManager element, under SORRegion name="default"(which is the parent), within inan.xml. I have used xsl key. In my xsl the value 'default' is hardcoded.
here is the xsl i used
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output omit-xml-declaration="yes" indent="yes" method="xml" />
<xsl:key name="CR-lookup" match="Service" use="concat(@ServiceName, '+', SOR/@SORname, '+', */CountryCode/@Ctrycd, '+', */*/SORRegion/@name, '+', */*/*/ConsumerName/@name)"/>
<xsl:variable name="CRTable" select="document('inan.xml')"/>
<xsl:template match="/">
<Contributor>
<ContributorRole>
<xsl:for-each select="$CRTable">
<!-- change context document -->
<xsl:for-each select="key('CR-lookup', concat('StatementIndicatorsService', '+', 'Globestar', '+', '124', '+', 'default', '+', 'MYCA'))">
<a>
<xsl:value-of select="*/*/*/*/QueueManager"/>
</a>
</xsl:for-each>
</xsl:for-each>
</ContributorRole>
</Contributor>
</xsl:template>
</xsl:stylesheet>
any input xml file is fine.
here is my actual output
<Contributor>
<ContributorRole />
</Contributor>
expected output
<Contributor>
<ContributorRole>
<a>MAO1</a>
</ContributorRole>
</Contributor>
inan.xml document
<RoutingDetails>
<Service ServiceName="StatementIndicatorsService">
<SOR SORname="Globestar">
<CountryCode Ctrycd="124">
<SORRegion name="Test">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146B</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146C</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="default">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKBX1">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKAX4">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.GDAS.DHIPO204.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKEX7">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.ICS.DP.DHIPO247.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
</CountryCode>
<CountryCode Ctrycd="826">
<SORRegion name="Test">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="default">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKBX1">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKAX4">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.GDAS.DHIPO204.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKEX7">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA1146A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA1146A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.GDAS.DHIPO247.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
</CountryCode>
<CountryCode Ctrycd="724">
<SORRegion name="Test">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA4248A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA4248A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.GDAS.DHIPO239.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="default">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA4248A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA4248A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.GDAS.DHIPO239.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKBX1">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA4248A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA4248A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.ICS.DP.DHIPO211.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKAX4">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA4248A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA4248A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.GDAS.DHIPO204.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
<SORRegion name="CICDKEX7">
<ConsumerName name="MYCA">
<AutomationIds>
<PreAutoId>
<AutomationId>XA4248A</AutomationId>
<AutomationId>XA1146A</AutomationId>
</PreAutoId>
<DefaultAutoId>
<AutomationId>XA4248A</AutomationId>
</DefaultAutoId>
</AutomationIds>
</ConsumerName>
<QueueDetails>
<QueueManager>MAO1</QueueManager>
<ReplyQueueManager>MAO1</ReplyQueueManager>
<RequestQueue>GSTAR.GDAS.DHIPO247.REQUEST</RequestQueue>
<ReplyQueue>ICS.DP.REPLY</ReplyQueue>
</QueueDetails>
</SORRegion>
</CountryCode>
</SOR>
</Service>
</RoutingDetails>
© Stack Overflow or respective owner