Main Content

matlab.io.xml.transform.ResultFile Class

Namespace: matlab.io.xml.transform

Store transformation result as file

Since R2021a

Description

Use an object of the matlab.io.xml.transform.ResultFile class to specify the location to store a file that contains the serialized result of a document transformation. You can provide a ResultFile object to the transform method of a matlab.io.xml.transform.Transformer object.

The matlab.io.xml.transform.ResultFile class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

resultObj = matlab.io.xml.transform.ResultFile(path) creates a matlab.io.xml.transform.ResultFile object and sets the Path property to path.

example

Properties

expand all

Path of the file that contains the transformation results, specified as a character vector or string scalar.

Attributes:

GetAccess
public
SetAccess
public
GetObservable
true
SetObservable
true

Examples

collapse all

This example transforms the XML markup for countries and their capital cities into an HTML table. The transformation saves the result in a matlab.io.xml.transform.ResultFile object.

The example uses these files:

  • 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 ResultFile object.

import matlab.io.xml.transform.*
resultObj = ResultFile("capitals.html");

Perform the transformation and save the results in the ResultFile object.

transform(Transformer,"capitals.xml","capitals.xsl",resultObj);

View the resulting HTML markup in the file.

type("capitals.html")
<html>
<body>
<table>
<tr>
<th>Country</th><th>Capital</th>
</tr>
<tr>
<td>Canada</td><td>Ottawa</td>
</tr>
<tr>
<td>France</td><td>Paris</td>
</tr>
<tr>
<td>Peru</td><td>Lima</td>
</tr>
</table>
</body>
</html>

Version History

Introduced in R2021a