I was handling this processing instruction: <?Pub _kern Amount="-25pt"?>
with:
<xsl:template match="processing-instruction('Pub')">
<xsl:choose>
<xsl:when test="starts-with(., '_kern')">
<xsl:attribute name="style"><xsl:text>padding-left: </xsl:text>
<xsl:value-of select="if (contains(.,'Amount')) then (substring-before(substring-after(., 'Amount="'), '"')) else '12pt'"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>
but this only works when the PI is inside a container element like <div>, etc. I received an error because the XSLT was trying to add a style tag to a non-existent parent element. If I include a <span> before the <xsl:attribute name="style"> then the code doesn't work when the PI is inside a container element. How can I detect whether there is a container element so I know whether or not to add a span? Unless there is a better way to do this, I'm a beginner with XSLT.
No comments:
Post a Comment