I am trying to apply a transform to the XML below using XPath and XSLT.
<AuthorGroup>
<Author AffiliationID="A1">
<GivenName>John</GivenName>
<Initials/>
<FamilyName>Smith</FamilyName>
<Degrees/>
<Roles/>
</Author>
<Author AffiliationID="A2">
<GivenName>Bill</GivenName>
<Initials/>
<FamilyName>Atkins</FamilyName>
<Degrees/>
<Roles/>
</Author>
<Affiliation AFFID="A1">
<OrgDivision/>
<OrgName>Some Org</OrgName>
<OrgAddress/>
</Affiliation>
<Affiliation AFFID="A2">
<OrgDivision/>
<OrgName>Another Org</OrgName>
<OrgAddress/>
</Affiliation>
</AuthorGroup>
I try to combine the names of authors and affiliates under one node, so I get a structure like:
<AUG>
<AU><NAME>John Smith</NAME><AUINFO>Some Org</AUINFO></AU>
<AU><NAME>Bill Atkins</NAME><AUINFO>Another Org</AUINFO></AU>
</AUG>
I am trying to find a way to select a node value to which the parent node attribute matches the attribute value of another node. For example, for the author, John Smith, I would like to select the node value, which corresponds to the membership identifier.
So far I have the code in my stylesheet as shown below, but I know that the selection inside node does not work.
<xsl:for-each select="AuthorGroup/Author">
<AU>
<NAME><xsl:value-of select="./FamilyName" /> <xsl:value-of select="./GivenName" /></NAME>
<AUINFO><xsl:value-of select="../Affiliation[@AFFID='NEED TO MATCH AUTHOR AFFILIATIONID']/OrgName" /> </AUINFO>
</AU>
</xsl:for-each>
How to choose the value of the correct organization name for the associated author?
Many thanks
Jim