xsl-list
[Top] [All Lists]

RE: xpath question

2003-03-28 06:32:03
A very strange structure if you don't mind me saying!

If you assume that the description nodes are in the same order as the 
equivalent column nodes
(which in your example is not the case!!) :

<xsl:template match="column">
        <xsl:variable name="pos" select="position()" />

        <xsl:for-each select="key('groupKey', @name)">
                <xsl:value-of 
select="/root/descriptions/description[$position()]" />
      </xsl:for-each>

</xsl:template>

It is not obvious in your example how the description elements relate to the 
column
elements other than the fact they have the same fruit...!?!

A far better structure might be:
<root>
 ..
  <order>
     <column name="orange" description="this is an orange"/>
     <column name="apple"  description="this is an apple"/>
   </order>
 ..
</root>

Bryan


-----Original Message-----
From: florian [mailto:csshsh(_at_)structbench(_dot_)com]
Sent: 28 March 2003 12:57
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] xpath question



hi!

i would have an additional question to this:

if my document would look like this:

<root>
   <descriptions>
     <description>this is an apple</description>
     <description>this is an orange</description>
   </descriptions>
   <group>
      <apple>bla</apple>
      <orange>bla</orange>
   </group>
   <group>
      <apple>bla</apple>
      <orange>bla</orange>
   </group>
   <order>
     <column name="orange" />
     <column name="apple" />
   </order>
</root>


how could i get the matching description for every column,
when i loop though them via the order described in the order
node?

somehow i cannot think of a way to do that with xpath : /

thanks!

ciao!
florian



At 12:07 PM 3/27/2003, you wrote:
i have a document xml doc like this:

<root>
  <group>
     <apple>bla</apple>
     <orange>bla</orange>
  </group>
  <group>
     <apple>bla</apple>
     <orange>bla</orange>
  </group>

  <order>
    <column name="orange" />
    <column name="apple" />
  </order>
</root>

i would like to do the following: im going though all the column nodes
and would like to access the group nodes where the column attribute name
and the group node name match up.

basically i can just not think of a way to do that in xpath.. anybody
got an tip? how can i say in xpath that it should get the node with
the name in @name and not just access the name attribute of a group
node..


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
Visit our website at http://www.rm.com

This message is confidential.  You should not copy it
or disclose its contents to anyone.  You may use and apply the information
only for the intended purpose.  Internet communications are not secure and
therefore RM does not accept legal responsibility for the contents of this
message.  Any views or opinions presented are only those of the author and
not those of RM.  If this email has come to you in error please delete it
and any attachments.  Please note that RM may intercept incoming and
outgoing e-mail communications.

This email has been scanned for viruses by Trend ScanMail.

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



<Prev in Thread] Current Thread [Next in Thread>