RE: [xsl] XSL Help!!

Subject: RE: [xsl] XSL Help!!
From: sara.mitchell@xxxxxxxxx
Date: Thu, 5 Dec 2002 18:42:50 -0500
Chandra, you might want to look through the
XSLT FAQ at http://www.dpawson.co.uk/. This
along with some of the books suggested at the site
can help a lot. But to answer your questions:

> When u say <xsl:apply-templates select="NAME"/>, Will all the 
> NAME nodes 
> under MEMBER be selected(say there are more than 1 NAME nodes under 
> MEMBER)?

yes (but only NAME children, not descendants that are an lower
    in the hierarchy)

>Also will the NAME template rule be applied to each 
> one of the NAME 
> nodes before the Phone node is selected?

yes

> 
> 2)
> <xsl:variable name='signers'
> select=/legal_authenticator/person'/>
> 	<xsl:if test='$signers'>
> .....
> .....
> </xsl:if>
> 
> What is the xsl:if tag doing here? Is it testing whether 
> /legal_authenticator/person' exists??

yes

> 
> 3)<person_name>
>           <nm>
>             <GIV V="Henry"/>
>             <FAM V="Levin"/>
>            </nm>
>           <person_name.type_cd V="L" S="2d"/>
>         </person_name>
> 
> For the above xml, I see the following in the stylesheet
> <xsl:apply-templates 
> select='person_name[person_name.type_cd/@V="L"]'/>
> What do the [] mean?? Why can't I just have / instead of the []??

[] is what the XSLT spec calls a predicate. It's a way of 
specifying a criteria rather than pointing to a specific node. 
So, what this select is saying (in English) is: 

Select all person_name nodes from the current context that
contain a person_name.type_cd element with a V attribute
whose value is "L"

But what is selected is the person_name node and that's
what the XSLT engine looks for and how it selects the template
to apply to person_name. If you had this instead: 

<xsl:apply-templates select='person_name/person_name.type_cd/@V="L"/>

what the select would say would be: 

Select the V attribute on the person_name.type_cd element that is 
a child of a person_name element that is a child of the current 
context. 

It selects the attribute. 

Sara

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


Current Thread