xsl-list
[Top] [All Lists]

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

2008-02-29 06:37:34
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--