How to prevent duplicate entries in a list, and then, ideally, sort this list? What I am doing is when information at one level is missing, taking information from a level below it to create a missing list at a higher level. I currently have an XML similar to this:
<c03 id="ref6488" level="file"> <did> <unittitle>Clinic Building</unittitle> <unitdate era="ce" calendar="gregorian">1947</unitdate> </did> <c04 id="ref34582" level="file"> <did> <container label="Box" type="Box">156</container> <container label="Folder" type="Folder">3</container> </did> </c04> <c04 id="ref6540" level="file"> <did> <container label="Box" type="Box">156</container> <unittitle>Contact prints</unittitle> </did> </c04> <c04 id="ref6606" level="file"> <did> <container label="Box" type="Box">154</container> <unittitle>Negatives</unittitle> </did> </c04> </c03>
Then apply the following XSL:
<xsl:template match="c03/did"> <xsl:choose> <xsl:when test="not(container)"> <did> <xsl:if test="../c04/did/container"> <container label="Box" type="Box"> <xsl:for-each select="../c04/did"> <xsl:if test="position() > 1">, </xsl:if> <xsl:value-of select="container"/> </xsl:for-each> </container> </did> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template>
But I get the result of the "container"
<container label="Box" type="Box">156, 156, 154</container>
when I want,
<container label="Box" type="Box">154, 156</container>
Below is the full result that I am trying to get:
<c03 id="ref6488" level="file"> <did> <container label="Box" type="Box">154, 156</container> <unittitle>Clinic Building</unittitle> <unitdate era="ce" calendar="gregorian">1947</unitdate> </did> <c04 id="ref34582" level="file"> <did> <container label="Box" type="Box">156</container> <container label="Folder" type="Folder">3</container> </did> </c04> <c04 id="ref6540" level="file"> <did> <container label="Box" type="Box">156</container> <unittitle>Contact prints</unittitle> </did> </c04> <c04 id="ref6606" level="file"> <did> <container label="Box" type="Box">154</container> <unittitle>Negatives</unittitle> </did> </c04> </c03>
Thanks in advance for your help!
duplicates xslt
LOlliffe
source share