<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=860124120-05052006>I was actually suggesting (as did Thomas) to not use
JDOM at all and just use regex across the whole document. But now you're saying
that the replacement text is somehow related to the context within the XML
document.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=860124120-05052006></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=860124120-05052006>Can you provide some more detail?</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=860124120-05052006></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=860124120-05052006>And please respond to the list, not to me
individually.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=860124120-05052006></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=860124120-05052006>Justin</SPAN></FONT></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Leonardo Barbosa
[mailto:lsbarbosa@gmail.com] <BR><B>Sent:</B> Friday, May 05, 2006 4:38
PM<BR><B>To:</B> Edelson, Justin<BR><B>Subject:</B> Re: [jdom-interest] Text
replacement<BR></FONT><BR></DIV>
<DIV></DIV>Thanks Justin!<BR><BR>Infact, the problem with creating the string
and using replaceAll is that I don't have the output ready at this time. I'm
iterating over the <chamada> tags and, for each one, I need to replace all
ocurrences of $REPLACE_THIS with a spacific value, for that <chamada> tag.
To be more specific, each <chamada> tag has a url associated with it,
according to it's position in the XML. <BR><BR>So, to replace using replaceAll,
wouldnt I need to create an String out using XMLOutputter for each
<chamada> tag, and them use the SAXParser to create the JDOM model again,
and atach this new JDOM model to the old one? <BR><BR>I mean, I can't reaplace
in the and, when I finish processing the document, beacause its the same string
$REPLACE_ALL with diferent values.. I could ask the client to use diferente
names, but i could generate errors, I upset him :-) <BR><BR>Thanks again for
your help,<BR>Leonardo Barbosa.<BR><BR>
<DIV><SPAN class=gmail_quote>On 5/5/06, <B class=gmail_sendername>Edelson,
Justin</B> <<A href="mailto:Justin.Edelson@mtvn.com">Justin.Edelson@mtvn.com
</A>> wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV style="DIRECTION: ltr">
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>I'd first
look at whether or not you need ANY kind of XML processing for this. If all
you are doing is replacing $REPLACE_THIS with some string, then you could just
get the template into a String object and do</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>string.replaceAll("\$REPLACE_THIS",
replacementString);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>(because
replaceAll expects a RegEx, you need to escape the dollar
sign)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Doing this
wouldn't even require "tidying" up the doc.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV><BR>
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:jdom-interest-bounces@jdom.org"
target=_blank>jdom-interest-bounces@jdom.org</A> [mailto:<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:jdom-interest-bounces@jdom.org"
target=_blank>jdom-interest-bounces@jdom.org</A>] <B>On Behalf Of </B>Leonardo
Barbosa<BR><B>Sent:</B> Friday, May 05, 2006 2:10 PM<BR><B>To:</B> <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:jdom-interest@jdom.org"
target=_blank>jdom-interest@jdom.org</A><BR><B>Subject:</B> [jdom-interest]
Text replacement<BR></FONT><BR></DIV></DIV>
<DIV style="DIRECTION: ltr"><SPAN class=e id=q_10b05f8cbf26b6e3_1>
<DIV></DIV>Hi!<BR><BR>I'm new to jdom and xml, so sorry if this is non
sense.<BR>I read a xml template (a html to be true, transformed to XML using
tidy) file from my client, and want to change all ocurrences of one text to
something else. It will probably be inside some javascript, something like
<BR><a href="#" onclick="javascript:openLink($REPLACE_THIS);"><BR><BR>bu
could be in the text of some <script> tag for
example:<BR><script><BR>funcion onclick(){<BR>
opeanUrl("REPLACE_THIS"); <BR>}<BR></script><BR><BR>There only one more
thing: It needs to be inside some tag, the one that defines the link
url:<BR><BR><chamada><BR>1
<a href="#" onclick="openLink($REPLACE_THIS);">click here</a>
<BR></chamada><BR><BR><chamada><BR>2
<a href="#"
onclick="openLink($REPLACE_THIS);">$REPLACE_THIS</a><BR></chamada><BR><BR><BR>Is
there a way to do this with jdom API, without getting all Descendents from the
tag <chamada> and looking inside its Text and Attributes ?<BR>something
like:<BR><BR> Iterator chamadaIterator =
root.getDescendants (new ElementFilter("chamada"));<BR>
while (chamadaIterator.hasNext()) {<BR>
Element chamadaTag =
(Element) chamadaIterator.next();<BR>
chamadaTag.setTextReplacement("$REPLACE_THIS",
" <A onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.thinkgeek.org"
target=_blank>http://www.thinkgeek.org</A>");<BR>
}<BR><BR>I've searched the forum and found some ideas
aboute html entities, but it seams to be not the case, since I have one value
for the <SPAN>whole </SPAN>document.<BR><BR>I no that it seeas to be lazyness
:-)<BR>But in fact I'm trying to avoid some desnecessary loop inside all
elements, all texts from theese elements, and all attributes from theese
elements. <BR><BR>Thanks in advance,<BR>Leonardo Barbosa<BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:lsbarbosa@gmail.com"
target=_blank>lsbarbosa@gmail.com</A><BR><BR></SPAN></DIV></BLOCKQUOTE></DIV><BR></BODY></HTML>