-- solution 1 -- local lasttitle = nil -- -- function xml.functions.test_b(t) -- local title = xml.text(t, "c") -- local content = xml.text(t, "d") -- context.startxrow() -- context.startxcell( { background="color", backgroundcolor="yellow" } ) -- if lasttitle == title then -- context.color( { "red" }, title) -- else -- lasttitle = title -- context.color( { "blue" }, title) -- end -- context.stopxcell() -- context.startxcell() -- context(content) -- context.stopxcell() -- context.stopxrow() -- end -- solution 2 -- local titles = { } -- -- function xml.functions.reset_b(t) -- titles = { } -- end -- -- function xml.functions.test_b(t) -- local title = xml.text(t, "c") -- local content = xml.text(t, "d") -- context.startxrow() -- context.startxcell( { background="color", backgroundcolor="yellow" } ) -- if titles[title] then -- context.color( { "red" }, title) -- else -- titles[title] = true -- context.color( { "blue" }, title) -- end -- context.stopxcell() -- context.startxcell() -- context(content) -- context.stopxcell() -- context.stopxrow() -- end -- solution 3 function xml.functions.test_b(t) local title = xml.text(t, "c") local content = xml.text(t, "d") context.startxrow() context.startxcell( { background="color", backgroundcolor="yellow" } ) if xml.text(t,"./preceding-sibling::/[-1]") == title then context.color( { "red" }, title) else context.color( { "blue" }, title) end context.stopxcell() context.startxcell() context(content) context.stopxcell() context.stopxrow() end