I’m trying to output a text file that will remove duplicate and only return active.
For example:
<Report_Data>
<Report_Entry>
<id>1</wd:id>
<status>Inactive</status>
<Report_Entry>
<Report_Entry>
<id>1</wd:id>
<status>Active</status>
<Report_Entry>
<Report_Entry>
<id>3</wd:id>
<status>Active</status>
<Report_Entry>
<Report_Entry>
<id>4</wd:id>
<status>Inactive</status>
<Report_Entry>
I tried to use xsl:for-each-group and group-by but not achieving the result.
<xsl:template match="Report_Data">
<row>
<text>id|status</text>
<xsl:value-of select="$newline"/>
</row>
<xsl:for-each-group select="Report_Entry" group-by="id[../status='Active']">
<row>
<id>
<xsl:value-of select="id"/>
<xsl:value-of select="$delimiter"/>
</id>
<status>
<xsl:value-of select="status"/>
</status>
</row>
The output is:
id|status
1|Active
3|Active
But the desired output is
id|status
1|Active
3|Active
4|Inactive
Tried this code but also returning the incorrect output
<xsl:for-each-group select="Report_Entry[status='Active']" group-by="id">
Thanks in advance. 🙂