Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Wed, 6 Feb 2008 08:03:40 -0800 (PST),    group: microsoft.public.xsl        back       


Simple select question (newbie to xsl+xml) - Selecting from just one node at a time   
Hi all,

I have several nodes that are identical. They each have a properties
X:

<nodes>
  <node>
    <X>one</X>
    <X>two</X>
  </node>
  <node>
    <X>aaa</X>
    <X>bbb</X>
  <node>
</nodes>


In my xsl I have


   <xsl:for-each select="//blah/nodes">
<nodes>

</node>
</xsl:for-each>


Which is fine for getting each of the nodes out, but problem arises
when I try to take out X properties of the individual node in
transform.

I keep getting all values of all X properties in each node by using
<xsl:for-each select="//X">:

nodes>
  <node>
    <Xs>
    <X>aaa</X>
    <X>bbb</X>
    <X>one</X>
    <X>two</X>
   </Xs>
  </node>
  <node>
   <Xs>
    <X>aaa</X>
    <X>bbb</X>
    <X>one</X>
    <X>two</X>
   </Xs>
  <node>
</nodes>

I'm very new to xsl, haven't been able to find the solution (not even
not sure of the terminology).

Thank you for your help,

C
date: Wed, 6 Feb 2008 08:03:40 -0800 (PST)   author:   unknown

Re: Simple select question (newbie to xsl+xml) - Selecting from just one node at a time   
conorgaff@gmail.com wrote:

> I have several nodes that are identical. They each have a properties
> X:
> 
> <nodes>
>   <node>
>     <X>one</X>
>     <X>two</X>
>   </node>
>   <node>
>     <X>aaa</X>
>     <X>bbb</X>
>   <node>
> </nodes>
> 
> 
> In my xsl I have
> 
> 
>    <xsl:for-each select="//blah/nodes">
> <nodes>
> 
> </node>
> </xsl:for-each>
> 
> 
> Which is fine for getting each of the nodes out, but problem arises
> when I try to take out X properties of the individual node in
> transform.
> 
> I keep getting all values of all X properties in each node by using
> <xsl:for-each select="//X">:

I guess you are looking for relative XPath expressions e.g.
   <xsl:for-each select="/nodes/node">
     <xsl:for-each select="X">
That way the inner for-each selects only the 'X' elements of the 'node' 
element selected by the outer for-each.

So be careful with prefixing XPath expressions with //, that way you are 
always looking at descendants of the root node.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Wed, 06 Feb 2008 17:14:23 +0100   author:   Martin Honnen

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us