3

i have the below pieces of my xml.

Case1:

 <para>
    <content-style font-style="bold">Affidavit</content-style>
</para>

Case2:

 <para>This is a different <content-style font-style="bold">Affidavit</content-style> case              
</para>

i want here the control to call section template if there is only node present(Case 1) but not if it also has text in it(Case 2). i tried the below xslt but it is not working. please let me know how to do it.

<xsl:template match="para">
<xsl:choose>
<xsl:when test="child::content-style/node[1]">
<xsl:call-template name="section"/>
</when></xsl:choose>
</xsl:template>

Thanks

user2423959
  • 836
  • 1
  • 13
  • 27

1 Answers1

2

From your example I think you should call a template section for para with content-style but no text. Best way to do this is something like the following:

<xsl:template match="para" />
<xsl:template match="para[content-style][not ( text() )]">
            <xsl:call-template name="section"/>
</xsl:template>

With xsl:when this should do:

<xsl:template match="para" >
    <xsl:choose>
        <xsl:when test="content-style and not(text())">
            <xsl:call-template name="section"/>
        </xsl:when>
    </xsl:choose>
</xsl:template>
Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
hr_117
  • 9,589
  • 1
  • 18
  • 23
  • Hi @hr_117 thanks for the quick reply, can you please tell me how do i add it in when condition, as template para has a lot of validations among which this is one. – user2423959 Jun 17 '13 at 10:05
  • can you please have a look at http://stackoverflow.com/questions/17021734/sum-of-parent-child-and-parent-nodes/17024253?noredirect=1#comment24620882_17024253 – user2423959 Jun 17 '13 at 11:20