0

I have a Map of this type but I have not been able to print it in a velocity template. This is for a SOAP service

{DATOS_CONTACTO=[{TIPO_DOCUMENTO=CC, NUMERO_DOCUMENTO=1525250, COD_DEPARTAMENTO=10, COD_MUNICIPIO=222, DIR_RESIDENCIA=CL 4A 3 52, TELEFONO=0, CELULAR=325252467, EMAIL=luzceni5252@hotmail.com}], DATOS_PARENTESCO=[{PARENTESCO=Hijos, DOCUMENTO=1052986, TIPODOC=1}, {PARENTESCO=Hijos, DOCUMENTO=1035252, TIPODOC=5}]}

The goal is to loop through the map and print its values Values are not displayed. I tried to get the result and iterate with a foreach

#foreach( $row in ${body} )
#if($row['DATOS_PARENTESCO']
#set ($foo = ($row["PARENTESCO"]))
<ns1:dato_parentesco>
<ns3:tipo_parentesco>#if($foo == "Conyuge")1 #elseif ($foo == "Compañero(a)")2 #elseif($foo =="Hijos")3 #elseif($foo == "Padres")4 #elseif($foo == "Otros")5 #else#end</ns3:tipo_parentesco>
<ns3:tipo_doc_cotizante>#if(!$row["TIPODOC"])#{else}$row["TIPODOC"]#end</ns3:tipo_doc_cotizante>
<ns3:num_doc_cotizante>#if(!$row["DOCUMENTO"])#{else}$row["DOCUMENTO"]#end</ns3:num_doc_cotizante>
</ns1:dato_parentesco>
#end
if($row['DATOS_CONTACTO'])
<ns1:datos_contacto>
<ns3:depto_residencia>#if(!$row["COD_DEPARTAMENTO"])#{else}$row["COD_DEPARTAMENTO"]#end</ns3:depto_residencia>
<ns3:municipio_residencia>#if(!$row["COD_MUNICIPIO"])#{else}$row["COD_MUNICIPIO"]#end</ns3:municipio_residencia>
<ns3:direccion_residencia>#if(!$row["DIR_RESIDENCIA"])#{else}$row["DIR_RESIDENCIA"]#end</ns3:direccion_residencia>
<ns3:telefono_residencia>#if(!$row["TELEFONO"])#{else}$row["TELEFONO"]#end</ns3:telefono_residencia>
<ns3:telefono_movil>#if(!$row["CELULAR"])#{else}$row["CELULAR"]#end</ns3:telefono_movil>
<ns3:correo_electronico>#if(!$row["EMAIL"])#{else}$row["EMAIL"]#end</ns3:correo_electronico>
</ns1:datos_contacto>
#end
#end
  • You're at least missing closing Parentheses after your first if and `#` before your second if. Maybe try opening the template in editor like VSCode with Velocity template plugin that includes syntax highlighting to see if there are any more errors. – Pasi Österman Mar 17 '23 at 10:01

0 Answers0