EDN Admin
Well-known member
Hi experts,
Im facing with the requirement to merge 2 xml strings. Im newbie in XSL and dont know how to make the XSLT file and passing XML string to XSLT as variable.
XML1:
<?xml version = "1.0" encoding = "UTF-8"?><br/>
<CIFInfo><br/>
<CIFNUM>02123011</CIFNUM><br/>
<LICID>111-CA-43999</LICID><br/>
</CIFInfo>
XML2:
<?xml version="1.0" encoding="UTF-8"?><br/>
<MSG xmlns="http://www.localhost/schemas/cifmsg" xmlns:ns0="http://www.localhost/schemas/cifmsg/field <br/>
<ns0:Field><br/>
<ns0:Name>SocketMessageLength</ns0:Name><br/>
<ns0:Type>B</ns0:Type><br/>
<ns0:Length>9</ns0:Length><br/>
<ns0:Size>4</ns0:Size><br/>
<ns0:Value>0</ns0:Value><br/>
<ns0osition>1</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>HeaderType</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>5</ns0:Length><br/>
<ns0:Size>5</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>5</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>DeviceName</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>15</ns0:Length><br/>
<ns0:Size>15</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>10</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>SocketNumber</ns0:Name><br/>
<ns0:Type>S</ns0:Type><br/>
<ns0:Length>5</ns0:Length><br/>
<ns0:Size>5</ns0:Size><br/>
<ns0:Value>0</ns0:Value><br/>
<ns0osition>25</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>PortNumber</ns0:Name><br/>
<ns0:Type>S</ns0:Type><br/>
<ns0:Length>6</ns0:Length><br/>
<ns0:Size>6</ns0:Size><br/>
<ns0:Value>0</ns0:Value><br/>
<ns0osition>30</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>Filler</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>1</ns0:Length><br/>
<ns0:Size>1</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>36</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>CIFNUM</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>0</ns0:Length><br/>
<ns0:Size>0</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>0</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>LICID</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>0</ns0:Length><br/>
<ns0:Size>0</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>0</ns0osition><br/>
</ns0:Field><br/>
</MSG>
And I want to merge the text value of 2 tags <CIFNUM> and <LICID> from XML1 to tag <Value> in XML2 in which the field <Name> is matched.
Could you please advice on how to do this. Your answer or suggest is very highly appreciated.<br/>
Thanks.
Langlv
<br/>
View the full article
Im facing with the requirement to merge 2 xml strings. Im newbie in XSL and dont know how to make the XSLT file and passing XML string to XSLT as variable.
XML1:
<?xml version = "1.0" encoding = "UTF-8"?><br/>
<CIFInfo><br/>
<CIFNUM>02123011</CIFNUM><br/>
<LICID>111-CA-43999</LICID><br/>
</CIFInfo>
XML2:
<?xml version="1.0" encoding="UTF-8"?><br/>
<MSG xmlns="http://www.localhost/schemas/cifmsg" xmlns:ns0="http://www.localhost/schemas/cifmsg/field <br/>
<ns0:Field><br/>
<ns0:Name>SocketMessageLength</ns0:Name><br/>
<ns0:Type>B</ns0:Type><br/>
<ns0:Length>9</ns0:Length><br/>
<ns0:Size>4</ns0:Size><br/>
<ns0:Value>0</ns0:Value><br/>
<ns0osition>1</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>HeaderType</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>5</ns0:Length><br/>
<ns0:Size>5</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>5</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>DeviceName</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>15</ns0:Length><br/>
<ns0:Size>15</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>10</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>SocketNumber</ns0:Name><br/>
<ns0:Type>S</ns0:Type><br/>
<ns0:Length>5</ns0:Length><br/>
<ns0:Size>5</ns0:Size><br/>
<ns0:Value>0</ns0:Value><br/>
<ns0osition>25</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>PortNumber</ns0:Name><br/>
<ns0:Type>S</ns0:Type><br/>
<ns0:Length>6</ns0:Length><br/>
<ns0:Size>6</ns0:Size><br/>
<ns0:Value>0</ns0:Value><br/>
<ns0osition>30</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>Filler</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>1</ns0:Length><br/>
<ns0:Size>1</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>36</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>CIFNUM</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>0</ns0:Length><br/>
<ns0:Size>0</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>0</ns0osition><br/>
</ns0:Field><br/>
<ns0:Field><br/>
<ns0:Name>LICID</ns0:Name><br/>
<ns0:Type>A</ns0:Type><br/>
<ns0:Length>0</ns0:Length><br/>
<ns0:Size>0</ns0:Size><br/>
<ns0:Value/><br/>
<ns0osition>0</ns0osition><br/>
</ns0:Field><br/>
</MSG>
And I want to merge the text value of 2 tags <CIFNUM> and <LICID> from XML1 to tag <Value> in XML2 in which the field <Name> is matched.
Could you please advice on how to do this. Your answer or suggest is very highly appreciated.<br/>
Thanks.
Langlv
<br/>
View the full article