So I have this code:
<xsl:for-each select="item">
<Row>
<Cell Borders="#ffffff">
<xsl:attribute name="Background">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">#CCCCFF</xsl:when>
<xsl:when test="position() mod 2 = 0">#FFFFFF</xsl:when>
</xsl:choose>
</xsl:attribute>
<Paddings Left="5" Right="5" Top="2" Bottom="2"/>
<xsl:for-each select="//queries/query/selection/dataItem">
<Text Style="TableContent">
<xsl:value-of select="@name"/>
</Text>
</xsl:for-each>
</Cell>
<Cell Borders="#ffffff">
<xsl:attribute name="Background">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">#CCCCFF</xsl:when>
<xsl:when test="position() mod 2 = 0">#FFFFFF</xsl:when>
</xsl:choose>
</xsl:attribute>
<Paddings Left="5" Right="5" Top="2" Bottom="2"/>
<Text Style="TableContent">
<xsl:choose>
<xsl:when test="qi">
<xsl:value-of select="qi"/>
</xsl:when>
<xsl:otherwise>
<Text>N/A</Text>
</xsl:otherwise>
</xsl:choose>
</Text>
</Cell>
</Row>
</xsl:for-each>
I am trying to pull information from an XML, however the information is in two different nodes, with two different XPATH. Also I need to match the information from one node, i.e. name. to another node located under a different location, with a different XPATH. is there a way to go through each name in the node and match it to the information found in another node all in the same XML??
EDIT
Added link to original XML
Thank you very much
It looks like you are trying to access dataItem elements where the expression element matches the name element of the current item.
In this case, you can create a key to look up dataItem records by their expression value
Then, instead of looping through all dataItem records like you are doing currently…
You can replace this line to simply use the key to iterate over only those dataItems with the relevant value
Here, name is the name element under the current item element on which you are currently positioned.
Here is some fuller XSLT, to show the xsl:key element in context