velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: 1 xml file to many
Date Thu, 12 Sep 2002 23:54:03 GMT
On 9/12/02 7:23 PM, "Charles N. Harvey III" <charlieh@alloy.com> wrote:

> 
>>> I am now a firm +1 for DVSL.  I have gotten it to work with no actual
>>> java coding on my part.  Gotta like a tool where I don't actually have
>>> to write any code.  The only code I needed was posted to the list and
>>> Bill had given me the link - thanks for that by the way.
>>> 
>>> I have a question though.  I am transforming from one xml file to other
>>> xml files so I do not want any of the text "un-xmled".  The current xml
>>> has:
>>> &lt;p&gt;&amp;nbspSome Text&amp;nbsp;&lt;/p&gt;
>>> 
>>> and it is being converted to:
>>> <p> Some Text </p>
>>> 
>>> And I do NOT want it to do that.  I want the text to be left in its
>>> original format.  Is this possible?  Can I turn off the switch which is
>>> converting the text?
>> 
>> There's no DVSL switch.  The problem is that you are escaping the
> entities.
>> 
>> If you do something like :
>> 
>> 
>>  <foo><![CDATA[&lt;p&gt;&amp;nbspSome Text&amp;nbsp;&lt;/p&gt;]]></foo>
>> 
>> That should solve it.  I am assuming much here, but I think this is what
> you
>> want...
>> 
> 
> Argh.  My initial xml file is huge.  And the format that it came in does not
> have
> all the fields wrapped in <![CDATA[ ]]> tags.  I tried out a small sample of
> the
> data and put the tags in and it worked as expected.  I might be up a creek
> without
> a paddle on this one without a massive search and replace on that file.

Glad it worked, and "Argh!" indeed.

You could write a little proggie that takes that XML file, and uses dom4j or
something to go through and search for any elements in the tree that contain
< or > and CDATA those... I guess it depends on what the rest of the doc
looks like.

> 
> One more question...
> 
> $variable.toString.substring(0,5)    -    works!
> $variable.toString.replace('a','b')    -    does not.  And I cannot figure out
> why.

There is no character support in Velocity, and if I remember right, the
replace() method takes chars.  'a' -> a string.  Something we didn't think
of, I guess.  The only thing I can think of, w/o using a tool, and w/o
trying it myself, is

#set($a = 'a')
#set($b = 'b')

$variable.toString.replace($a.charAt(0),$b.charAt(0))

Which I will admit is a pain.  How about a tool?

$var.toString.replace($tool.char('a',0), $tool.char('b', 0))


 
> I keep getting "is not a valid reference" in the output.  I can do every
> operation
> on a string except replace?  Is there something I don't know.  I've been
> killing
> myself over this for two hours now.  :)

:)

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
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