主要内容

matlab.io.xml.transform.stylesheetsourceCument.class

Package:matlab.io.xml.transform.

Stylesheet source document for transformation

Description

使用对象matlab.io.xml.transform.stylesheetsourceCument.class to specify amatlab.io.xml.dom.Document对象作为样式表用于转换。你可以提供一个styleSheetsourceCument.object as the stylesheet input to the转变要么transformToStringmethod of amatlab.io.xml.transform..Transformer目的。

Thematlab.io.xml.transform.stylesheetsourceCument.班级是A.handleclass.

Class Attributes

ConstructOnLoad
真的
HandleCompatible
真的

For information on class attributes, seeClass Attributes.

Creation

Description

example

stylesheetSourceObj = matlab.io.xml.transform.StylesheetSourceDocument(doc)creates amatlab.io.xml.transform.stylesheetsourceCument.对象与之Document属性设置为指定的matlab.io.xml.dom.Document目的。

Properties

expand all

Document containing stylesheet specified as amatlab.io.xml.dom.Document目的。

Attributes:

GetAccess
民众
SetAccess
immutable
Transient
真的
NonCopyable
真的

方法

expand all

Examples

collapse all

Suppose that you want to customize a stylesheet for a transformation, but do not want to modify the file that contains the stylesheet. You can read the stylesheet file into a DOM document, modify the style in the document, and then use the document as the stylesheet for the transformation. Specify the stylesheet as amatlab.io.xml.transform.stylesheetsourceCument.目的。

This example transforms the XML markup for countries and their capital cities into an HTML table. The original XSL file specifies a table with the default color, black. The example parses the XSL from the file into amatlab.io.xml.dom.Document目的,modifies the style to make the table green, and passes theDocumentobject to the transformation as amatlab.io.xml.transform.stylesheetsourceCument.目的。

The example uses these files:

  • capitals.xml

 CanadaOttawa FranceParis PeruLima 
  • capitals.xsl

      
Country Capital

Parse a stylesheet file into amatlab.io.xml.dom.Document目的。

importmatlab.io.xml.dom.*importmatlab.io.xml.transform。*importmatlab.io.xml.xpath。*ssDoc = parseFile(Parser,"capitals.xsl");

Find the table element and add a style attribute that specifies the color green.

tableElem =评估(评估员,"//table",ssDoc); styleAttr = createAttribute(ssDoc,"style"); setValue(styleAttr,"color:green"); setAttributeNode(tableElem,styleAttr);

创建一个styleSheetsourceCument.目的,stylesheetObj, that contains theDocument对象与XSL标记用于转换。

stylesheetobj = styleSheetsourceCument(SSDOC);

执行转换并提供stylesheetObjas the stylesheet,capitals.xml作为源XML,和capitals.htmlas the name of the output file.

转变(Transformer,"capitals.xml",stylesheetObj,“capitals.html”);

Open capitals.html in a browser.

web(“capitals.html”)

Here is the HTML table:

Introduced in R2021a