﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
226	genshi Transformer Substitute Transformation performs replacement across the document instead of selected nodes	jhammel@…	cmlenz	"When doing a {{{Transform(<xpath>).substitute(from, to)}}} transformation, everything in the document that matches from is substituted instead of just elements matching the xpath expression:

{{{
>>> html2
<genshi.core.Stream object at 0xb7dba42c>
>>> print html2
<b>foo</b><i>fee</i>
>>> print html2 |  Transformer('//b').replace('replaced')
replaced<i>fee</i>
>>> print html2 |  Transformer('//b').substitute('f', 'g')
<b>goo</b><i>gee</i>
}}}

Even though {{{<i>fee</i>}}} shouldn't be matched because it is not in the xpath (as evidenced by the preceding replace call), the substitution is erroneously performed.

I believe this is due to a missing check around here:

http://genshi.edgewall.org/browser/trunk/genshi/filters/transform.py#L871

I have fixed this locally by replacing this line with the following:

{{{
            if kind is TEXT and mark is not None:
}}}

I'm not sure if this is a good fix, but it does get the above test example to correctly display:

{{{
>>> print html2 | Transformer('//b').substitute('f', 'g')
<b>goo</b><i>fee</i>
}}}"	defect	closed	major	0.5	General	devel	fixed		
