Hello All,
I have a requirement to split the input.xml file different files and i have tried using earlier examples(where i have posted in the forum), but still no luck
Here is my input.xml
<jms-system-resource>
<name>UMSJMSSystemResource</name>
<target>soa_server1,bam_server1</target>
<sub-deployment>
<name>UMSJMSServer522129776</name>
<target>UMSJMSServer_auto_1</target>
</sub-deployment>
<sub-deployment>
<name>UMSJMSServer1709690790</name>
<target>UMSJMSServer_auto_2</target>
</sub-deployment>
<descriptor-file-name>jms/UMSJMSSystemResource-jms.xml</descriptor-file-name>
</jms-system-resource>
For the above file we need to have two different files
Output file 1
**************
File name should be the value of
<name>
tag under
<jms-system-resource>
tag.
and it needs to have two parameters namley JMSModulename and Targetserver
For Ex:- for the above input.xml
file the expected outputfile1 should be
" UMSJMSSystemResource.Properties
" and inside this file
JMSModulename:-UMSJMSSystemResource
Targetserver:-soa_server1,bam_server1
Output File2:-
****************
File name should be the value of
<name>
tag under
<sub-deployment>
tag.
and it needs to have three parameters namely JMSModulename,Subdeployemntname and Targetservers
For Ex:- for the above input.xml file the expected outputfile2 should be
" UMSJMSServer522129776_subdeployment.Properties
" and inside this file
JMSModulename:-UMSJMSSystemResource
Subdeploymentname:-UMSJMSServer522129776
TargetServer:-UMSJMSServer_auto_1
and one more file for second
<sub-deployemnt>
tag
" UMSJMSServer1709690790_subdeployment.Properties
" and inside this file
JMSModulename:-UMSJMSSystemResource
Subdeploymentname:-UMSJMSServer1709690790
TargetServer:-UMSJMSServer_auto_2
Here is the code which i have tried
awk -v s1="JMSModuleName = " -v s2="TargetServer = " -F"[><]" '
flag && /<\/jms-system-resource>/{
flag="";
print val1 ORS val2 > file;
close(file)
}
/<jms-system-resource>/{
flag=1;
next
}
flag && /<name>/{
file=$3".properties";
val1=s1 $3
next
}
flag && /<target>/{
val2=s2 $3;
next
}
' Test_data.xml
please provide some assistance on this.
Thanks,