Re: [xsl] Different conditional outputs in same Stylesheet or calling another stylesheet (version 1.0, Xalan)

Subject: Re: [xsl] Different conditional outputs in same Stylesheet or calling another stylesheet (version 1.0, Xalan)
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Fri, 29 Feb 2008 14:37:02 +0100
Pankaj Chaturvedi schrieb:

[...]

<xsl:template match="article/meta/journalcode">
	<xsl:if test="string(.)='CEDE'">

You can simplify this to: ". = 'CEDE'"


		<xsl:copy>
			<xsl:apply-templates mode="CEDE"/>
		</xsl:copy>
	</xsl:if>
</xsl:template>

In the absence of a @select, xsl:apply-templates has an implicit @select reading "node()", so what you have is:

<xsl:apply-templates select="node()" mode="CEDE"/>

This means: process all child nodes of the context node.

In your XML sample, your <ref-book> is not beneath your <journalcode> -
it's not a child node of <journalcode>. There is only a text node
beneath your <journalcode>.

Take a look back at the example I gave earlier in this thread.

 <xsl:template match="article[ .//journalcode = 'CEDE' ]">
  <xsl:comment>CEDE</xsl:comment>
  <xsl:copy>
   <xsl:apply-templates mode="CEDE"/>
  </xsl:copy>
 </xsl:template>

The processing starts from above the <journalcode>; what I want to get
at, is beneath. So, the implicit "node()" works fine here.

If you want to reach back to the <ref-book> from within the
<journalcode>, you need to supply a more sporty XPath that climbs
back up and then dives down again.

    ../../references/ref-book                   # one way
    ../following-sibling::references/ref-book   # another way

Michael

Current Thread