[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Find the node name of the parent in the result tree?


Subject: [xsl] Find the node name of the parent in the result tree?
From: Martin Holmes <mholmes@xxxxxxx>
Date: Fri, 22 Mar 2013 14:14:33 -0700

If I have a template matching an attribute, and producing one in the output tree, like this:

  <xsl:template match="@style">
        <xsl:attribute name="style" select="."/>
  </xsl:template>

Is there any way to know the name of the element in the result tree which is the parent of the attribute being created?

Some context: I'm turning TEI @style attributes into HTML @style attributes in the output, and I'd like to handle situations in which this kind of input:

<hi rend="text-align: center;">Centred text</hi>

results in output that doesn't work:

<span style="text-align: center;">NOT centred because it's a span</span>

If I knew the output element was a <span> or element which is inline by default, I could add "display: block" automatically to any @style attribute that contains a block-level CSS property such as text-align. I don't want to add "display: block" in all cases, because e.g. a <div> element might already have a class which floats it.

Cheers,
Martin


Current Thread
Keywords
tei