[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Selecting non-duplicate nodes
I posted a similar problem last week that required a somewhat more complex
answer but received no responses to it, so I have reduced my requirements
and simplified the problem substantially. My question now is: how can I
change this stylesheet so that for the listed input, no <FormatButtons> in
the output contains more than one copy of a <Format> with the same attribute
name and value? That is, where the current output is, for example:
<FormatPage souvenir-sheet="365"> <FormatButtons> <Formats se-tenant="365"/> <Formats se-tenant="365"/> <Formats coupon="367"/> <Formats coupon="368"/> </FormatButtons> </FormatPage> where the <Formats se-tenant="365" appears twice. What I desire is: <FormatPage souvenir-sheet="365"> <FormatButtons> <Formats se-tenant="365"/> <Formats coupon="367"/> <Formats coupon="368"/> </FormatButtons> </FormatPage> Thanks, Mark ------------------------------------------------------ [Input file and stylesheet] --------------------------------------------- <Input> <Set> <Stamp> <CatNumbers pofis-number="105"/> <Formats souvenir-sheet="105"/> <Formats se-tenant="105"/> </Stamp> <Stamp> <CatNumbers pofis-number="106"/> <Formats souvenir-sheet="105"/> <Formats se-tenant="105"/> </Stamp> <Stamp> <CatNumbers pofis-number="107"/> <Formats souvenir-sheet="105"/> <Formats se-tenant="107"/> </Stamp> <Stamp> <CatNumbers pofis-number="108"/> <Formats souvenir-sheet="105"/> <Formats se-tenant="107"/> </Stamp> </Set> <Set> <Stamp> <CatNumbers pofis-number="146"/> <Formats souvenir-sheet="146"/> <Formats se-tenant="146"/> </Stamp> <Stamp> <CatNumbers pofis-number="147"/> <Formats souvenir-sheet="146"/> <Formats se-tenant="146"/> </Stamp> <Stamp> <CatNumbers pofis-number="148"/> <Formats souvenir-sheet="146"/> <Formats se-tenant="146"/> </Stamp> </Set> <Set> <Stamp> <CatNumbers pofis-number="244"/> <Formats coupon="244"/> </Stamp> <Stamp> <CatNumbers pofis-number="245"/> <Formats souvenir-sheet="245"/> </Stamp> </Set> <Set> <Stamp> <CatNumbers pofis-number="365"/> <Formats souvenir-sheet="365"/> <Formats se-tenant="365"/> </Stamp> <Stamp> <CatNumbers pofis-number="366"/> <Formats souvenir-sheet="365"/> <Formats se-tenant="365"/> </Stamp> <Stamp> <CatNumbers pofis-number="367"/> <Formats souvenir-sheet="365"/> <Formats coupon="367"/> </Stamp> <Stamp> <CatNumbers pofis-number="368"/> <Formats souvenir-sheet="365"/> <Formats coupon="368"/> </Stamp> </Set> </Input> -------------------- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xs xd" version="2.0"> <xsl:strip-space elements="*"/> <xsl:template match="Input"> <xsl:element name="Output"> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="Set"> <!-- <xsl:apply-templates mode="stamp"/> --> <xsl:apply-templates mode="formats"/> </xsl:template> <xsl:template match="Stamp" mode="formats"> <xsl:apply-templates mode="formats"/> </xsl:template> <xsl:template match="Formats" mode="formats"> <xsl:if test="@* eq ../CatNumbers/@pofis-number"> <xsl:element name="FormatPage"> <xsl:copy-of select="@*"/> <xsl:variable name="format" select="name(@*)"/> <xsl:variable name="number" select="@*"/> <xsl:element name="FormatButtons"> <xsl:for-each-group select="../../Stamp" group-by="Formats"> <xsl:for-each select="current-group()"> <xsl:if test="Formats/@*[name(.)=$format]=$number"> <Formats> <xsl:copy-of select="Formats/@*[not(name(.)=$format)]"/> </Formats> </xsl:if> </xsl:for-each> </xsl:for-each-group> </xsl:element> </xsl:element> </xsl:if> </xsl:template> </xsl:stylesheet
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|