TAGS :Viewed: 12 - Published at: a few seconds ago

[ To match XSL with the good expression XML ]

I take back the collegue's program

In my XML I search to match the XSL only when the paragraph starting by annexe is not in the CELL parent

For exemple :

         <BODY>
            .............
            <CELL>
                <PARAGRAPH align="centre">32</PARAGRAPH>
                <PARAGRAPH align="centre">annexe V</PARAGRAPH>
            </CELL>
            .............
            <PARAGRAPH align="centre">annexe C</PARAGRAPH>
            .............
         </BODY>

The actual XSL is (&start-annexe; is just a function to match when the element PARAGRAPH starts by annexe):

<xsl:template match="PARAGRAPH[(@align='center' or @align='left') and &start-annexe;]">
  <Annexe>
    <xsl:apply-templates select="@*|node()"/>
  </Annexe>
</xsl:template>

The actual result is :

 <BODY>
    .............
    <CELL>
        <PARAGRAPH align="centre">32</PARAGRAPH>
        <ANNEXE>annexe V</ANNEXE>
    </CELL>
    .............
    <ANNEXE>annexe C</ANNEXE>
    .............
 </BODY>

I would like :

 <BODY>
    .............
    <CELL>
        <PARAGRAPH align="centre">32</PARAGRAPH>
        <PARAGRAPH align="centre">annexe V</PARAGRAPH>
    </CELL>
    .............
    <ANNEXE>annexe C</ANNEXE>
    .............
 </BODY>

I tried several possibilities but I don't success...

For exemple

<xsl:template match="PARAGRAPH[(@align='center' or @align='left') and &start-annexe; and not(parent::CELL)]">

Could you help me? Thanks

Answer 1


I believe you are looking for the starts-with function

<xsl:template match="PARAGRAPH[(@align='center' or @align='left')
    and starts-with(., 'annexe')
    and not(parent::CELL)]">