Re: [xsl] XSL omit part of a text inside TAG

Subject: Re: [xsl] XSL omit part of a text inside TAG
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 7 Mar 2008 11:33:28 GMT
You only want to affect FontFace, so move your template matching down to
that element rather than matching its parent. Also as a general comment
if you have a tempolate that only consists of an xsl:chhose or xsl:if
block it's often better to simplify it to put the test into the match
pattern, so rather than match on all FontFace and then check that teh
parent has the right xsl:type, I just match on the ones you want to
affect.


David


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
    
<xsl:template match="/">
  <xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="VisualObject[@xsi:type='CBarCode']/FontFace">
  <xsl:copy>
    <xsl:call-template name="while">
      <xsl:with-param name="foo" select="."/>
    </xsl:call-template>
  </xsl:copy>
</xsl:template>

<xsl:template name="while">
  <xsl:param name="foo"/>
  <xsl:choose>
    <xsl:when test="contains($foo,'\')">
      <xsl:call-template name="while">
	<xsl:with-param name="foo" select="substring-after($foo,'\')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$foo"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>

Current Thread