velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stéphane MOR <stephane_lis...@yahoo.fr>
Subject DVSL XPATH : Help Neede !
Date Mon, 12 Aug 2002 08:51:44 GMT
Hi !

I'm trying to use XPath expressions in a DVSL template.
In Maven, I have a file that looks like:

<project>
  <plugin name="foo">
    <goal id="0" name="foo:bar">
      <prerequisite name="prereq:one"/>
      <prerequisite name="prereq:two"/>
    </goal>
  </plugin>
  <plugin name="prereq">
    <goal id="1" name="prereq:one"/>
    <goal id="2" name="prereq:two"/>
  </plugin>
</project>

Ok, now what I would like to do is :

for each <goal>, I'd like to retrieve the ids of the prerequisites,
so that I have something like:
"'foo:bar' depends on '1' and '2'".

For this I need to get the node "/plugin/goal" whose name equals
$prereq.attrib("name").

What I have right now:

#match("plugin")
  #set ( $pluginName = $attrib.name )

  #foreach( $goal in $node.selectNodes("goal") )
    #foreach ( $prereq in $goal.selectNodes("prerequisite") )
      #set ( $prereqName = $prereq.attrib("name") )

      #* Here is the bloody XPath expression ... *#
      #* There IS a match for every goal, so it should return something 
every time ... *#
      #set ( $prereqGoal = $node.get("/plugin/goal[@name='$prereqName']") )
      #set ( $prereqId = $prereqGoal.attrib("id") )

      "$goal.attrib("name") depends on '$prereqId'".
    #end
  #end
#end

I thought that this would give me:
"foo:bar depends on '1'".
"foo:bar depends on '2'".

but it didn't :(

I don't know what is wrong, and I tried MANY combinations of expressions 
& tricks, without
success.

If someone with more experience than me with XPath / DVSL / both could 
give me some
advice, it'd be very cool !

Thanx,
Stéphane

PS: if my big, fat XSLT / XPath book continues staring at me like it 
does, it's gonna learn how to fly very soon ! :)

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message