Note that there are some explanatory texts on larger screens.

plurals
  1. POconverting xml to xml using xsl
    text
    copied!<p>Hi I have one xml I need to convert that xml to another xml using xsl</p> <p>my XML looks like</p> <pre><code>&lt;Information&gt; &lt;ShipmentType&gt; &lt;shipmentType&gt;A&lt;/shipmentType&gt; &lt;/ShipmentType&gt; &lt;ShipmentRouting&gt; &lt;airportCityCodeOrigin&gt;AAA&lt;/airportCityCodeOrigin&gt; &lt;airportCityCodeDestination&gt;BBB&lt;/airportCityCodeDestination&gt; &lt;/ShipmentRouting&gt; &lt;EarliestDepartureDateTime&gt; &lt;dayOfMonth&gt;00&lt;/dayOfMonth&gt; &lt;month&gt;OCT&lt;/month&gt; &lt;/EarliestDepartureDateTime&gt; &lt;/Information&gt; </code></pre> <p>It should be converted into this format: </p> <pre><code>&lt;ECIDRA-INP&gt; &lt;DRA-INP&gt; &lt;OPTION&gt; &lt;ORIGIN&gt; &lt;STATION&gt;AAA&lt;/STATION&gt; &lt;/ORIGIN&gt; &lt;DEST&gt; &lt;STATION&gt;BBB&lt;/STATION&gt; &lt;/DEST&gt; &lt;/OPTION&gt; &lt;/DRA-INP&gt; &lt;/ECIDRA-INP&gt; </code></pre> <p>I need only the value of <code>&lt;airportCityCodeOrigin&gt;</code> and <code>&lt;airportCityCodeDestination&gt;</code> but I am getting all the tags values.</p> <p>Below is the XSL that I wrote: </p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" indent="yes"/&gt; &lt;xsl:template match="/Information"&gt; &lt;ECIDRA-INP&gt; &lt;DRA-INP&gt; &lt;OPTION&gt; &lt;ORIGIN&gt; &lt;STATION&gt; &lt;xsl:value-of select="./ShipmentRouting/airportCodeofDeparture"&gt;&lt;/xsl:value-of&gt; &lt;/STATION&gt; &lt;/ORIGIN&gt; &lt;DEST&gt; &lt;STATION&gt; &lt;xsl:value-of select="./ShipmentRouting/airportCodeofArrival"&gt;&lt;/xsl:value-of&gt; &lt;/STATION&gt; &lt;/DEST&gt; &lt;/OPTION&gt; &lt;/DRA-INP&gt; &lt;/ECIDRA-INP&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload