tags:

views:

34

answers:

3

Hi,

I have an XSL stylesheet (A) that imports another one (B). A overrides a template (t) in B, and invokes B's template with apply-imports:

From A:

<xsl:template match="t">
    <xsl:apply-imports/>
</xsl:template>

From B:

<xsl:template match="t">
    <p><!-- Do something --></p>
</xsl:template>

I now want A to add an attribute to the fragment (<p>...</p>) returned by apply-imports. The attribute should be added to element p directly, p should not be wrapped in another element. How can I do this?

Regards, Jochen

+1  A: 

IMHO, you can't.

B is self-contained, when its matching template finishes running then <p> is already constructed in the result tree and inaccessible to A.

Tomalak
A: 

Think about doing some preprocessing to B. It's only a xml after all.

Krab
A: 

Can you add a parameter to your B template and include it in the A match? That way you can add the attribute you want based controlled by the A match.

Nat
Not in this case since I can only change A, not B.
Jochen