Why does py:match only apply to an xi:include directly after it?

143 Views Asked by At

I have a primary genshi template that I'm trying to apply several overrides to in an xsl:fo template:

<py:match path="fo:page-sequence[@master-reference='invoice-sequence']"> ... </py:match> <xi:include href="main.xml" />

.. This works fine, but when I provide more than one py:match tag, like this:

<py:match path="fo:page-sequence[@master-reference='invoice-sequence']"> ... </py:match> <py:match path="fo:block[@id='dateF']"> ... </py:match> <xi:include href="main.xml" />

Only the last py:match will work. I can move the xi:include around, and it seems to only be affected by a py:match directly above it, and not at all at the top. What I would expect to work is the include at the top, which starts the stream, and then py:matches after it to modify the stream, but this doesn't seem to be the case, as the py:matches only work if they're placed before the xi:include

Could someone explain to me how to accomplish my goal of using more than one py:match against the xi:include? I'd also love it if there was some theory about includes and py:match so that I could understand why this behaviour is how it seems.

1

There are 1 best solutions below

1
Pierre-Francoys Brousseau On

According to https://groups.google.com/forum/#!topic/genshi/VIUhr-W3Un4 :

""" Hodgestar
8/6/13 I think this is how things are expected to work -- match templates are applied one after the other and the previous state of the XML isn't remember (I'm not even sure how to define the behaviour in such a scenario). """

Which leads me to look for a way to reset the context. Perhaps using multiple xi:include, one for each py:match? [This idea could help others figure this one out]