%% Specify Stylesheet as a StylesheetSourceFile Object
% This example transforms the XML markup for countries and their capital cities into an HTML table. The example specifies the input stylesheet as a matlab.io.xml.transform.StylesheetSourceFile object.
% The example uses these file:
% capitals.xml
% <Countries>
%     <Country><Name>Canada</Name><Capital>Ottawa</Capital></Country>
%     <Country><Name>France</Name><Capital>Paris</Capital></Country>
%     <Country><Name>Peru</Name><Capital>Lima</Capital></Country>
% </Countries>
% capitals.xsl
% <?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 StylesheetSourceFile object,stylesheetObj, that contains the path of the stylesheet to use for the transformation.

import matlab.io.xml.transform.*
stylesheetObj = StylesheetSourceFile("capitals.xsl");

% Perform the transformation. Provide stylesheetObj as the stylesheet input, capitals.xml as the XML source, and capitals.html as the name of the output file.

transform(Transformer,"capitals.xml",stylesheetObj,"capitals.html");

% Open capitals.html in a browser.

web("capitals.html")

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