7 users online. Create an account or sign in to join them.Users
Removing duplicates with axes
This is an open discussion with 4 replies, filed under XSLT.
Search
I've corrected the XPath. What i have now selects unique dates and it works on the debug devkit.
/data/eventos-calendario/entry[not(fecha-evento=preceding-sibling::entry/fecha-evento)]/fecha-evento
But when i try to compare the result of date:month-in-year in the predicate it outputs the whole list of values:
<xsl:for-each select="data/eventos-calendario/entry[not(date:month-in-year(fecha-evento)=date:month-in-year(preceding-sibling::entry/fecha-evento))]/fecha-evento">
<xsl:value-of select="."/>
</xsl:for-each>
So no success, yet.
I've located why the last XPath example doesn't work.
data/eventos-calendario/entry[not(date:month-in-year(fecha-evento)=date:month-in-year(preceding-sibling::entry/fecha-evento))]/fecha-evento
The second part of the predicate: date:month-in-year(preceding-sibling::entry/fecha-evento) allways returns the same result, that is the first month-in-year of all the nodes in the node-set, and that makes sense now that i see it.
Unfortunately this puts me on a dead-end since i have no clue on how to manipulate the strings of the resulting node-set while keeping its node-set type.
Thinking on giving up the axes route and trying keys. Even so, i would love to see this solved.
I've finally learned that i can group by dates in the data-source configuration :/
Yes, that'd be the easiest option :-) Grouping by a Date field will group by year/month, which matches your requirement. If you need to group by year, or by day, then XPath axes would do the trick. I'm not quite sure why your example above didn't work, but it looks like you were close.
Create an account or sign in to comment.
Hi guys.
Im struggling to create this simple thing;
Out of this xml:
<data> <eventos-calendario> <section id="1" handle="eventos">Eventos</section> <entry id="103"> <fecha-evento time="19:42" weekday="2">2011-05-17</fecha-evento> </entry> <entry id="93"> <fecha-evento time="23:30" weekday="6">2011-04-30</fecha-evento> </entry> <entry id="91"> <fecha-evento time="23:30" weekday="5">2011-04-29</fecha-evento> </entry> <entry id="88"> <fecha-evento time="23:30" weekday="6">2011-03-23</fecha-evento> </entry> <entry id="84"> <fecha-evento time="23:30" weekday="5">2011-03-22</fecha-evento> </entry> </eventos-calendario> </data>I want to create a node-selection of unique month dates, so i can xsl:for-each it.
This is my best try so far, it outputs every date but the desired result would be: 2011-05-17, 2011-04-30, 2011-03-23
<xsl:for-each select="data/eventos-calendario/entry/fecha-evento[not(date:month-in-year(.)=date:month-in-year(preceding-sibling::data/eventos-calendario/entry/fecha-evento))]"> <xsl:value-of select="."/> </xsl:for-each>I readed several posts regarding grouping and duplicate removing. I was going to look further into Muenchian grouping but i really want to learn the axes stuff properly, so i want this solution using a :: selector. The date: namespace is making things a bit harder for me too. I still dont fully understand how axes, context and steps interact with stuff like ".", current(), and node(), and i guess thats why i struggle with this simple task.
Any help is much appreciated.
Saludos.