You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by narasimha gudisa <gu...@gmail.com> on 2023/05/25 12:48:15 UTC

Unable to convert the data to xml

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

Re: Unable to convert the data to xml

Posted by Claude Brisson <cl...@renegat.net.INVALID>.
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-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

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


Re: Unable to convert the data to xml

Posted by Claude Brisson <cl...@renegat.net.INVALID>.
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-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org