| 85 | | root_attrs = root_interpolated[0].attrib |
| 86 | | eq_(root_attrs['{http://genshi.edgewall.org/}replace'], 'foo') |
| | 86 | child = root_interpolated[0] |
| | 87 | eq_(child.get('{http://genshi.edgewall.org/}replace'), 'foo') |
| | 88 | |
| | 89 | def test_column_looping(self): |
| | 90 | xml = ''' |
| | 91 | <table:table |
| | 92 | xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" |
| | 93 | xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" |
| | 94 | xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" |
| | 95 | xmlns:xlink="http://www.w3.org/1999/xlink" |
| | 96 | table:name="Tableau1" |
| | 97 | table:style-name="Tableau1"> |
| | 98 | <table:table-column table:style-name="Tableau1.A" |
| | 99 | table:number-columns-repeated="2"/> |
| | 100 | <table:table-column table:style-name="Tableau1.C"/> |
| | 101 | <table:table-column table:style-name="Tableau1.A"/> |
| | 102 | <table:table-column table:style-name="Tableau1.E"/> |
| | 103 | <table:table-header-rows> |
| | 104 | <table:table-row table:style-name="Tableau1.1"> |
| | 105 | <table:table-cell table:style-name="Tableau1.A1" |
| | 106 | office:value-type="string"> |
| | 107 | <text:p text:style-name="Table_20_Heading">Brol</text:p> |
| | 108 | </table:table-cell> |
| | 109 | <table:table-cell table:style-name="Tableau1.A1" |
| | 110 | office:value-type="string"> |
| | 111 | <text:p text:style-name="Table_20_Heading"> |
| | 112 | <text:a xlink:type="simple" |
| | 113 | xlink:href="relatorio://for each="title in titles"">for each="title in titles"</text:a> |
| | 114 | </text:p> |
| | 115 | </table:table-cell> |
| | 116 | <table:table-cell table:style-name="Tableau1.A1" |
| | 117 | office:value-type="string"> |
| | 118 | <text:p text:style-name="Table_20_Heading">${title}</text:p> |
| | 119 | <text:p text:style-name="Table_20_Heading"/> |
| | 120 | </table:table-cell> |
| | 121 | <table:table-cell table:style-name="Tableau1.A1" |
| | 122 | office:value-type="string"> |
| | 123 | <text:p text:style-name="Table_20_Heading"> |
| | 124 | <text:a xlink:type="simple" |
| | 125 | xlink:href="relatorio:///for">/for</text:a> |
| | 126 | </text:p> |
| | 127 | </table:table-cell> |
| | 128 | <table:table-cell table:style-name="Tableau1.E1" |
| | 129 | office:value-type="string"> |
| | 130 | <text:p text:style-name="Table_20_Heading">Truc</text:p> |
| | 131 | </table:table-cell> |
| | 132 | </table:table-row> |
| | 133 | </table:table-header-rows> |
| | 134 | <table:table-row> |
| | 135 | <table:table-cell table:style-name="Tableau1.A2" |
| | 136 | table:number-columns-spanned="5" |
| | 137 | office:value-type="string"> |
| | 138 | <text:p text:style-name="Table_20_Contents"> |
| | 139 | <text:a xlink:type="simple" |
| | 140 | xlink:href="relatorio://for%20each=%22items%20in%20lst%22">for each="items in lst"</text:a> |
| | 141 | </text:p> |
| | 142 | </table:table-cell> |
| | 143 | <table:covered-table-cell/> |
| | 144 | <table:covered-table-cell/> |
| | 145 | <table:covered-table-cell/> |
| | 146 | <table:covered-table-cell/> |
| | 147 | </table:table-row> |
| | 148 | <table:table-row> |
| | 149 | <table:table-cell table:style-name="Tableau1.A3" |
| | 150 | office:value-type="string"> |
| | 151 | <text:p text:style-name="Table_20_Contents">Brol</text:p> |
| | 152 | </table:table-cell> |
| | 153 | <table:table-cell table:style-name="Tableau1.A3" |
| | 154 | office:value-type="string"> |
| | 155 | <text:p text:style-name="Table_20_Contents"> |
| | 156 | <text:a xlink:type="simple" |
| | 157 | xlink:href="relatorio://for%20each=%22item%20in%20items%22">for each="item in items"</text:a> |
| | 158 | </text:p> |
| | 159 | </table:table-cell> |
| | 160 | <table:table-cell table:style-name="Tableau1.A3" |
| | 161 | office:value-type="string"> |
| | 162 | <text:p text:style-name="Table_20_Contents">${item}</text:p> |
| | 163 | <text:p text:style-name="Table_20_Contents"/> |
| | 164 | </table:table-cell> |
| | 165 | <table:table-cell table:style-name="Tableau1.A3" |
| | 166 | office:value-type="string"> |
| | 167 | <text:p text:style-name="Table_20_Contents"> |
| | 168 | <text:a xlink:type="simple" |
| | 169 | xlink:href="relatorio:///for">/for</text:a> |
| | 170 | </text:p> |
| | 171 | </table:table-cell> |
| | 172 | <table:table-cell table:style-name="Tableau1.A2" |
| | 173 | office:value-type="string"> |
| | 174 | <text:p text:style-name="Table_20_Contents">Truc</text:p> |
| | 175 | </table:table-cell> |
| | 176 | </table:table-row> |
| | 177 | <table:table-row> |
| | 178 | <table:table-cell table:style-name="Tableau1.A2" |
| | 179 | table:number-columns-spanned="5" |
| | 180 | office:value-type="string"> |
| | 181 | <text:p text:style-name="Table_20_Contents"> |
| | 182 | <text:a xlink:type="simple" |
| | 183 | xlink:href="relatorio:///for">/for</text:a> |
| | 184 | </text:p> |
| | 185 | </table:table-cell> |
| | 186 | <table:covered-table-cell/> |
| | 187 | <table:covered-table-cell/> |
| | 188 | <table:covered-table-cell/> |
| | 189 | <table:covered-table-cell/> |
| | 190 | </table:table-row> |
| | 191 | </table:table>''' |
| | 192 | interpolated = self.oot.insert_directives(xml) |
| | 193 | root = lxml.etree.parse(interpolated).getroot() |
| | 194 | child2 = root[1] |
| | 195 | eq_(child2.tag, "{%s}repeat" % RELATORIO_URI) |
| | 196 | eq_(child2.get("closing"), "3") |
| | 197 | eq_(child2.get("opening"), "1") |
| | 198 | eq_(len(child2), 1) |
| | 199 | child4 = root[3] |
| | 200 | eq_(child4.tag, "{%s}table-header-rows" % OO_TABLE_NS) |
| | 201 | row1 = child4[0] |
| | 202 | ok_(row1.get("{%s}attrs" % GENSHI_URI) |
| | 203 | .startswith('__relatorio_reset_col_count')) |
| | 204 | eq_(len(row1), 4) |
| | 205 | loop = row1[1] |
| | 206 | eq_(loop.tag, "{%s}for" % GENSHI_URI) |
| | 207 | cell = loop[0] |
| | 208 | ok_(cell.get("{%s}attrs" % GENSHI_URI) |
| | 209 | .startswith('__relatorio_inc_col_count')) |
| | 210 | last_row_node = row1[3] |
| | 211 | eq_(last_row_node.tag, "{%s}replace" % GENSHI_URI) |
| | 212 | ok_(last_row_node.get("value") |
| | 213 | .startswith('__relatorio_store_col_count')) |
| | 214 | |
| | 215 | def test_text_outside_p(self): |
| | 216 | "Testing that the tail text of a directive node is handled properly" |
| | 217 | xml = '''<xml xmlns:text="urn:text" xmlns:xlink="urn:xlink"> |
| | 218 | <text:a xlink:href="relatorio://if%20test=%22True%22">if test="True"</text:a> |
| | 219 | xxx |
| | 220 | <text:p text:style-name="other">yyy</text:p> |
| | 221 | zzz |
| | 222 | <text:a xlink:href="relatorio:///if">/if</text:a> |
| | 223 | </xml>''' |
| | 224 | interpolated = self.oot.insert_directives(xml) |
| | 225 | root_interpolated = lxml.etree.parse(interpolated).getroot() |
| | 226 | child = root_interpolated[0] |
| | 227 | eq_(child.tag, '{http://genshi.edgewall.org/}if') |
| | 228 | eq_(child.text.strip(), 'xxx') |