commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Ochs" <danochs...@hotmail.com>
Subject Re: [jelly] bringing a jelly::core variable into an jelly::xml xpath
Date Tue, 19 Aug 2003 04:16:49 GMT
I got the following to work for my input testme.xml as shown below:

<j:jelly xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:x="jelly:xml">
   <x:parse var="groups" xml="testme.xml"/>
   <j:set var="dollar" value="$"/>
   <j:set var="groupName" value="MyGroup"/>
   <j:set var="inStr">${dollar}groups//group[@name='${groupName}']/@</j:set>
   <x:set var="mode" select="${inStr}mode"/>
   <j:set var="desc"><x:expr select="${inStr}desc"/></j:set>
   <ant:echo>Group ${groupName}: ${desc} - Mode: <x:expr 
select="$mode"/></ant:echo>
</j:jelly>

testme.xml:
<contentGroups>
   <group desc="Desc 1" mode="HIGH" name="MyGroup"/>
</contentGroups>

output is:
     [echo] Group MyGroup: Desc 1 - Mode: HIGH

thanks, dan


>From: Bill Keese <billk@tech.beacon-it.co.jp>
>Reply-To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
>To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
>Subject: Re: [jelly] bringing a jelly::core variable into an jelly::xml 
>xpath
>Date: Mon, 18 Aug 2003 09:38:16 +0900
>
>Paul, I'm having trouble understanding your suggestion.  Are you suggesting 
>that the following should work?
>
><xml:set var="input" 
>select="$groups//group[@name='${userEnteredExpression}']/@desc"/>
>
>(and also the following should work)
>
><xml:set var="input" select="${userEnteredExpression}" />
>
>I think I tried that once and it didn't work.  Also, Dan tried that in his 
>original example in this e-mail thread, and it didn't work for him either.
>
> > I think xml:parse accepts strings for source.
>But xml:parse doesn't evaluate X-path expressions.  It is for reading in 
>XML documents.  X-Path expressions work via xml:set or xml:expr, right?
>
>Bill
>
>Paul Libbrecht wrote:
>
>>Dan Ochs wrote:
>>
>>>I have tried <xml:set var="input" 
>>>select="$groups//group[@name='content']/@desc"/> and it works, but I was 
>>>trying to make my example simple.
>>>What if 'content' above is a variable that the user enters at the command 
>>>line during execution?
>>
>>
>>You would have to parse it the same way. I think xml:parse accepts strings 
>>for source.
>>
>>Or if I want to allow the user to enter
>>
>>>an entire xpath?
>>
>>
>>select="${userEnteredExpression}"
>>
>>Now you see why the xpath expression is not in ${}...
>>
>>Paul
>>
>>>
>>>
>>>>From: Paul Libbrecht <paul@activemath.org>
>>>>Reply-To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
>>>>To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
>>>>Subject: Re: [jelly] bringing a jelly::core variable into an jelly::xml 
>>>>xpath
>>>>Date: Thu, 14 Aug 2003 15:31:51 +0200
>>>>
>>>>Dan Ochs wrote:
>>>>
>>>>>I'm trying to figure out a way to pass a variable from a jelly::core 
>>>>>var into a jelly::xml XPath expression.  The document loading and 
>>>>>parsing is working correctly. The following code does not raise an 
>>>>>exception, but also does not return anything.  Any other combination I

>>>>>try rasises various exceptions, null pointer being the most common.
>>>>>thanks for the help, dan
>>>>>
>>>>>xml:
>>>>><groups>
>>>>>   <group desc="I am your content description" name="content"/>
>>>>></groups>
>>>>>
>>>>>
>>>>>jelly:
>>>>><xml:parse var="groups" xml="groups.xml"/>
>>>>><jelly:set 
>>>>>var="input">$groups//group[@name='content']/@desc</jelly:set>
>>>>><jelly:set var="desc">
>>>>>   <xml:expr select="${input}"/>
>>>>></jellt:set>
>>>>
>>>>
>>>>
>>>>
>>>>Dan,
>>>>
>>>>Have you tried, instead of <jelly:set var="input">... the following
?
>>>>
>>>><xml:set var="input" select="$groups//group[@name='content']/@desc"/>
>>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>

_________________________________________________________________
<b>MSN 8:</b> Get 6 months for $9.95/month. 
http://join.msn.com/?page=dept/dialup


Mime
View raw message