tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@swapsimple.com
Subject Re: Trouble with "xtags:add"
Date Fri, 11 Nov 2005 07:45:40 GMT
On Tue, Nov 08, 2005 at 04:17:29PM +0100, Rolf Niepraschk wrote:
> I need the additional tag "XX" at the same level as "AA" just after "BB". All my
>  trials results in the last position. The small jsp program at the end of this
> email shows the problem. I have also tried the parameter "after" but with no
> success (the parameter isn't described in the documentation!).
> 
> Many thanks in advance,

>From the docs:
add	
Parses it's body (as an XML fragment) and appends the contents to the
current node. The current node must be an Element. 
^^^^^^^^^^^^

> <xtags:context context="${doc}" select="/">
> <textarea readonly="true" cols="75" rows="12"><xtags:copyOf select="*" />
> </textarea><br />
> 
> <c:set var="tmp" value="/A/BB[1]" />
> <xtags:context context="${doc}" select="${tmp}">
> <xtags:add after="true">
> <xtags:element name="XX">Hugo</xtags:element></xtags:add>
> </xtags:context>
Since the current node in this case is the <BB> element, it sounds to me
like this code should result in:
<A>
  <AA/><AA/>
  <BB><XX>Hugo</XX></BB>
	<CC/>
</A>

I can think of two ways to do what you want:
1) in the context of /A, use xtags:replace with a body that is a
	xargs:forEach over /A/* that just echoes back the element.  When
	you get to the element named BB, spit it out, then the additional one.
2) Split the contents of of <A> using three xpaths to get <BB>, the
	stuff before it, and the stuff after it.  Then piece those together
	and replace the contents of the A node.  e.g. the xpath for everything
	after the BB would be something like "/A/BB[1]/following-sibling::*".

eric

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


Mime
View raw message