%% Specify Transformation Source XML as a SourceString Object
% This example transforms the XML markup for countries and their capital cities into an HTML table. The example specifies the input XML as a matlab.io.xml.transform.SourceString object.
% The example uses capitals.xsl as the stylesheet for the transformation.
% <?xml version="1.0"?>
%
% <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
%
% <xsl:template match="/">
%   <html>
%   <body>
%       <table>
%       <tr>
%         <th>Country</th>
%         <th>Capital</th>
%       </tr>
%       <xsl:for-each select="Countries/Country">
%         <tr>
%           <td><xsl:value-of select="Name"/></td>
%           <td><xsl:value-of select="Capital"/></td>
%         </tr>
%       </xsl:for-each>
%     </table>
%   </body>
%   </html>
% </xsl:template>
%
% </xsl:stylesheet>
% Create a SourceString object, sourceObj, to contain the XML source for the transformation.

import matlab.io.xml.transform.*
s1 = "<Countries><Country><Name>Canada</Name>";
s2 = "<Capital>Ottawa</Capital></Country></Countries>";
XMLText = s1 + s2; 
sourceObj = SourceString(XMLText);

% Perform the transformation and provide sourceObj as the XML source, capitals.xsl as the stylesheet, and capitals.html as the name of the output file.

transform(Transformer,sourceObj,"capitals.xsl","capitals.html");

% Open capitals.html in a browser.

web("capitals.html")

% Here is the HTML table:
%
%
% Copyright 2020 The MathWorks, Inc.