XML : XSL template match pattern applies to all child nodes

First excuse me for not posting the entire stylesheet so you can extract the output. It is a bit more complicated. There is a xsl:param passed by ant script to the stylesheet. Unless I provide the entire project you wont be able to obtain the output. Although I believe the provided information is enough to answer since (in my opinion) this is basic xslt issue. Unfortunately I am a beginner. This is a snippet from my stylesheet:

      <xsl:template name="root" match="/">                  <xsl:apply-templates select="/office:document-content/office:body/office:text"/>          </xsl:template>          <!-- -->          <xsl:template name="text" match="office:text">                  <text>                          <xsl:apply-templates/>                  </text>          </xsl:template>          <xsl:template match="text:h|text:p">                  <para>                          <xsl:call-template name="apply-style"/>                          <xsl:value-of select="."/>                  </para>          </xsl:template>  

And this is the input xml file

And this is the output I get:

  <?xml version="1.0" encoding="UTF-8"?><text>  <para style="P1"/>  <para style="Normal"/>  <para style="Header"/>  <para style="ListBullet2"/>  <para style="ListBullet2"/>  <para style="ListBullet2"/>  <para style="ListNumber2"/>  <para style="ListNumber2"/>  <para style="ListNumber2"/>  <para style="ListNumber2"/>  <para style="ListNumber2"/>  <para style="Heading1"/>  <para style="Normal"/>  <para style="Quote"/>  </text>  

Please tell me why <xsl:template match="text:h|text:p"> is applied for the other siblings (text:list) elements too? I has been explicitly told to be applied for text:h and text:p only. Excuse my poor English. Thank you for your time.

No comments:

Post a Comment