Edgewall Software

Opened 19 years ago

Last modified 15 years ago

#8 new defect

Path expressions on match templates don't work with path segments encountered before the match directive

Reported by: cmlenz Owned by: cmlenz
Priority: minor Milestone:
Component: Template processing Version: 0.6
Keywords: Cc:

Description (last modified by cmlenz)

Before [18], the following worked:

<div xmlns:py="markup.edgewall.org/">
  <span py:match="div/greeting">
    Hello ${select('@name')}
  </span>
  <greeting name="Dude" />
</div>

Since [18], the patch expression “div/greeting” no longer matches because the <div> element is encountered before the py:match directive in the input. This should probably be fixed, though. One option is to keep a stack of already encountered elements in the Template._match filter and push them into the path evaluator so that it has the correct context.

Change History (7)

comment:1 Changed 18 years ago by cmlenz

  • Milestone set to 0.3

comment:2 Changed 18 years ago by cmlenz

  • Description modified (diff)

comment:3 Changed 18 years ago by cmlenz

  • Milestone changed from 0.2 to 0.3

Not going to get this in for 0.2.

comment:4 Changed 18 years ago by cmlenz

  • Component changed from General to Template processing

comment:5 Changed 18 years ago by cmlenz

  • Milestone changed from 0.3 to 0.4

And again…

comment:6 Changed 18 years ago by cmlenz

  • Milestone 0.4 deleted
  • Priority changed from major to minor

This is not high priority right now, so clear the milestone.

comment:7 Changed 15 years ago by Carsten Klein <carsten.klein@…>

  • Version set to 0.6

Since the span represents the context node in which the matcher is being applied in, simply matching "div/greeting" would look for a child element "div" on the "span" element.

This is actually the correct way to implement it, see http://www.w3.org/TR/xpath/#path-abbrev for a few examples.

For example "divgreeting" would match all grandchildren of the context element, which is "span" that are descendants of a given "div" child element.

Does genshi know about ".." as a selector? If so, then "../greeting" would be the correct way to do it, or just "div[...]/greeting" for the not so optimal selection.

What do you think?

Note: See TracTickets for help on using tickets.