Discussion:
XPath in py:match is completely broken?
Ozzi Lee
2010-12-09 20:18:01 UTC
Permalink
For example, "foo/bar" only selects the first bar element inside a foo
element. "foo//bar" selects every bar element, inside a foo element or
not. I've included an example of the first problem below.

This is an obnoxious issue for me, as I need to match foo/bar and baz/
bar separately.

Input:

<?xml version="1.0"?>
<root xmlns:py="http://genshi.edgewall.org/">

<py:match path="foo/bar">
<zzzzz/>
</py:match>

<foo>
<bar/>
<bar/>
</foo>

<bar/>

</root>

Output:
<root>
<foo>
<zzzzz/>
<bar/>
</foo>
<zzzzz/>
</root>
--
You received this message because you are subscribed to the Google Groups "Genshi" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to genshi+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/genshi?hl=en.
osimons
2010-12-12 23:49:38 UTC
Permalink
Post by Ozzi Lee
For example, "foo/bar" only selects the first bar element inside a foo
element. "foo//bar" selects every bar element, inside a foo element or
not. I've included an example of the first problem below.
This is an obnoxious issue for me, as I need to match foo/bar and baz/
bar separately.
<?xml version="1.0"?>
<root xmlns:py="http://genshi.edgewall.org/">
  <py:match path="foo/bar">
    <zzzzz/>
  </py:match>
  <foo>
    <bar/>
    <bar/>
  </foo>
  <bar/>
</root>
<root>
  <foo>
    <zzzzz/>
    <bar/>
  </foo>
    <zzzzz/>
</root>
Confirmed. I've done some bisecting as I'm sure this used to work
correctly before, and find this to be the offending changeset:

http://genshi.edgewall.org/changeset/1097

Your example works fine if I install genshi trunk r1096:

In [1]: from genshi.template import MarkupTemplate
In [2]: print(MarkupTemplate("""<?xml version="1.0"?>
...: <root xmlns:py="http://genshi.edgewall.org/">
...: <py:match path="foo/bar">
...: <zzzzz/>
...: </py:match>
...: <foo>
...: <bar/>
...: <bar/>
...: </foo>
...: <bar/>
...: </root>""").generate())
<?xml version="1.0"?>
<root>
<foo>
<zzzzz/>
<zzzzz/>
</foo>
<bar/>
</root>

I'm reopening the ticket:

http://genshi.edgewall.org/ticket/370


:::simon

https://www.coderesort.com
http://trac-hacks.org/wiki/osimons
--
You received this message because you are subscribed to the Google Groups "Genshi" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to genshi+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/genshi?hl=en.
Nathan Roling
2010-12-13 22:05:24 UTC
Permalink
Post by osimons
Confirmed. I've done some bisecting as I'm sure this used to work
http://genshi.edgewall.org/changeset/1097
Thanks Simon, for looking into this. I'll keep an eye on the Trac ticket.

I realize my first email sounded a bit harsh, sorry about that. I was
somewhat frustrated at the time :-)

Ozzi
--
You received this message because you are subscribed to the Google Groups "Genshi" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to genshi+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/genshi?hl=en.
Loading...