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

Re: X-Path expressions confusions

Subject: Re: X-Path expressions confusions
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 30 Jul 2002 09:31:11 +0100
x path rules
Hi Ashu,

> 1. I have read this at
> http://www.w3.org/TR/xslt#section-Applying-Template-Rules
>
> *In the absence of a select attribute, the xsl:apply-templates 
> instruction processes all of the children of the current node, 
> including text nodes.*
>    Does that mean if we use <xsl:apply-templates select="*"/> 
> instead of <xsl:apply-templates/> both are same except the one 
> will process all child nodes and the other will process all but 
> text child nodes.

Sort of. The XPath expression "*" selects all the child *elements* of
the context node, whereas the XPath expression "node()" selects all
the child *nodes* of the context node: elements, text nodes, comments
and processing instructions.

So:

  <xsl:apply-templates />

is equivalent to:

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

> 2.
> And one thing about overriding template rules.
>   <xsl:template match="node"/>
> Does that mean it will do nothing to node and process the child 
> nodes of node or It means it will not process any node which are 
> inside <node> and </node> like
> <node>
>    <node1>......</node1>
>     <node2>......</node2>
> </node>

The latter. The template says "when you find a node element, do
nothing". If you wanted it to say "when you find a node element,
process its children" then you'd need:

<xsl:template match="node">
  <xsl:apply-templates />
</xsl:template>

> 3.
> If we have
> <xsl:template match
> ="text()[preceding-sibling::node()[1][self::input][not(normalize-space())]]
> then we read it from left to right so if this has to be read it 
> reads
> Template matches text() node then check the first perceding 
> sibling of that node whether it is input or not and white spaces 
> in text node should be preserved. right?

Roughly. This template matches text nodes whose immediately preceding
sibling is an input element that doesn't have any non-whitespace
textual content. For example, it would match the text in:

  <input />text

or:

  <input>
  </input>text
  
but not in:

  <foo />text

or:

  <input>
    foo
  </input>text

> 4.
>   Some times we use "." dot and sometimes "*" astric
>   Are they not same used for all elements or they are different as 
> in select we use "*" and in count we use
> "." like count(.| some key).

They are different. "." is short for "self::node()" whereas "*" is
short for "child::*". So "." will get you the node that you're on at
the moment (the context node), whereas "*" will get you the child
elements of the node that you're on at the moment.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.