[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Different conditional outputs in same Stylesheet o

Subject: Re: 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
Re:  Different conditional outputs in same Stylesheet o
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.