You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by be...@euphonynet.be on 2005/11/27 15:22:29 UTC

[JELLY] Using an attribute's value selected using xpath expression as variable

Hello,
I want to output the result of the processing of a stylesheet to a file
based on the value of an attribute.
I retrieve the value of the attribute using an "<x:set..." from the XML
tag library and  I use it later.
Insteadof giving me the value of the attribute as a string, It returns an
object (DefaultAttribute).
If I try to get the value of that object using "${name.getValue()}", the
result is an empty string

How can I do it ?

The code sample is :
<x:forEach select="xsd:complexType">
	    <x:set select="@name" var="name"/>
            package test;
                <x:expr select="@name" />
		getName() result: <j:expr value="${name}"/>
		<j:expr value="${name.getValue()}"/>
<j:file name="${name}.java">
...

The name of the created file is something like :
[org.dom4j.tree.DefaultAttribute@143c8b3 [Attribute: name name value
"empty"]]

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [JELLY] Using an attribute's value selected using xpath expression as variable

Posted by Jason Vinson <vi...@charter.net>.
Hi Benoit,

You'll want to use the single attribute on your jelly:xml tags in order to pull a single node value.  Otherwise,
+you'll get back a List of nodes (even if there is only one).  Try this:

<x:set select="@name" var="name" single="true"/>

Hope This Helps,
Jason

On Sun, Nov 27, 2005 at 03:22:29PM +0100, benoit.callebaut@euphonynet.be wrote:
> Hello,
> I want to output the result of the processing of a stylesheet to a file
> based on the value of an attribute.
> I retrieve the value of the attribute using an "<x:set..." from the XML
> tag library and  I use it later.
> Insteadof giving me the value of the attribute as a string, It returns an
> object (DefaultAttribute).
> If I try to get the value of that object using "${name.getValue()}", the
> result is an empty string
> 
> How can I do it ?
> 
> The code sample is :
> <x:forEach select="xsd:complexType">
> 	    <x:set select="@name" var="name"/>
>             package test;
>                 <x:expr select="@name" />
> 		getName() result: <j:expr value="${name}"/>
> 		<j:expr value="${name.getValue()}"/>
> <j:file name="${name}.java">
> ...
> 
> The name of the created file is something like :
> [org.dom4j.tree.DefaultAttribute@143c8b3 [Attribute: name name value
> "empty"]]
> 
> Thanks
> 
> 
> ---------------------------------------------------------------------
> 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