Oh, and : please read the Velocity Template Language syntax: you cannot use parenthesis or spaces like you do.

On 28/06/2023 01:58, Claude Brisson wrote:
Please don't copy paste your templates like this, it's not useful. You are getting variable names just because your context is not properly populated. Without any further description of how you call Velocity, it is difficult to help you.


On 25/05/2023 14:48, narasimha gudisa wrote:
Hello, I have data in the excel file I would like to convert the data to
the xml format using the apache velocity transformation engine.

My template  :

<?xml version="1.0" encoding="UTF-8"?>
<root>
#foreach ($line in $data)
<row>
     <timestamp type = "string">$(line.Timestamp(optional))</timestamp>
  <targettype type = "string">$line.Target Type</targettype>
<targetname type = "string">$line.Target Name</targetname>
<blockingevent type = "string">$line.Blocking
Event(optional)</blockingevent>
  <message type = "string">$line.Message</message>

</row>
#end
</root>

Getting the output :

<root>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
<row>
<timestamp type="string">$(line.Timestamp(optional))</timestamp>
<targettype type="string">$line.Target Type</targettype>
<targetname type="string">$line.Target Name</targetname>
<blockingevent type="string">$line.Blocking Event(optional)</blockingevent>
<message type="string">$line.Message</message>
</row>
</root>

I'm getting the variable names instead of data can you help me achieve this

Thanks in advance

Thanks
Narasimha Gudisa


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org

Reply via email to