I am trying to transform a XML document with data that has coded values. I have a second external document with those values decoded. I want to search the external file to match an element value (QuantityUnitOfMeasure/Code) from the processing file with element value(root/row/NCItCode) from the external document to ultimately return a sibling element(/root/row/NCIDefinition) from the external file. This is not working, new to XSLT.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:variable name="externalDoc" select="document('NCPDP.xml')"/>
<xsl:for-each select="Quantity">
<span>Quantity Unit Of Measure Code : </span>
<span> <xsl:value-of select="QuantityUnitOfMeasure/Code"/> </span>
<br></br>
<xsl:for-each select="$externalDoc/root/row">
<xsl:if test="NCItCode=QuantityUnitOfMeasure/Code">
<span> <xsl:value-of select="NCIDefinition"/> </span>
</xsl:if>
</xsl:for-each>
Processing XML:
<Quantity>
<Value>300</Value>
<CodeListQualifier>38</CodeListQualifier>
<QuantityUnitOfMeasure>
<Code>C48672</Code>
</QuantityUnitOfMeasure>
</Quantity>
ExternalXML File (NCPDP.xml):
<root>
<row>
<NCItCode>C48672</NCItCode>
<NCPDPPreferredTerm>Schedule I Substance</NCPDPPreferredTerm>
<NCIDefinition>
A category of drugs not considered legitimate for medical use.
</NCIDefinition>
</row>
<root>
Expected results:
Quantity Unit Of Measure Code : C48672
A category of drugs not considered legitimate for medical use.