Use Style Sheets
XML is a content-based metalanguage designed to structure data. XML does not include information about how a document should be displayed in a browser. To view an XML document in a browser, information about how its displayed must be provided by style sheets. These are coded by using either Cascading Style Sheets (CSS) or Extensible Style Sheet Language (XSL).
Use Extensible Style Sheet Language (XSL)
You can use XSL style sheets to specify how XML data is displayed in a browser. You can use existing XSL style sheets, but unlike CSS, style sheet information cannot be written to an external XSL file during the conversion.
Both CSS and XSL style sheets can be used to format XML documents. However, XSL can also transform XML documents. For example, list items can be transformed to display in alphabetical order, words can be replaced by other words, or empty elements can be replaced by text.
To use an existing XSL style sheet
-
Set the style sheet type to XSL by using one of the following methods:
-
Use the
setStyleSheetType
method of theXmlOptionInfo
class to set the option toXmlExport.STYLESHEET_XML_XSL
. -
Set the
eStyleSheetType
parameter in a template file toXML_XSL
.
-
-
Apply a pre-existing style sheet to the XML document by using one of the following methods:
-
Set the
setUseExistingStyleSheet
method of theXmlOptionInfo
class toTRUE
. -
Set the
bUseExistingStyleSheet
parameter in a template file toTRUE
.NOTE: Pre-existing style sheets are not validated.
-
-
Specify the path and file name of the external style sheet by using one of the following methods:
-
Use the
setExternalStyleFile(String)
method of theExport
object.
-
Set the
pszStyleSheet
parameter in a template file.
-
The external file style sheet is referenced in the XML output by a processing instruction of the form:
<xml-stylesheet href="style_file" type="text/xsl"?>
If the location of the style sheet is not specified, a default XSL style sheet that is appropriate for the source document type is used. The following are default XSL style sheets:
-
wp.xsl
(for word processing documents) -
ss.xsl
(for spreadsheets) -
pg.xsl
(for presentation graphics)
Use Cascading Style Sheets (CSS)
In addition to XSL style sheets, XML Export can write style sheet information to an external CSS file.
NOTE: Cascading style sheets can be used only with word processing documents.
To enable CSS mapping and output the resulting formatting data in an external file
-
Set the style sheet type to CSS by using one of the following methods:
-
Use the
setStyleSheetType
method of theXmlOptionInfo
class to set the option toXmlExport.STYLESHEET_XML_CSS
. -
Set the
eStyleSheetType
parameter in a template file toXML_CSS
.
-
-
Specify the path and file name of the external style sheet by using one of the following methods:
-
Use the
setExternalStyleFile(String)
method of theExport
object. -
Set the
pszStyleSheet
parameter in a template file.
-
To enable CSS mapping and use an existing CSS file
-
Set the style sheet type to CSS by using one of the following methods:
-
Use the
setStyleSheetType
method of theXmlOptionInfo
class to set the option toXmlExport.STYLESHEET_XML_CSS
. -
Set the
eStyleSheetType
parameter in a template file toXML_CSS
.
-
-
To apply a pre-existing style sheet to an XML document, use one of the following methods:
-
Set the
setUseExistingStyleSheet
method of theXmlOptionInfo
class toTRUE
. -
Set the
bUseExistingStyleSheet
parameter in a template file toTRUE
.NOTE: Pre-existing style sheets are not validated.
-
-
Specify the path and file name of the external style sheet by using one of the following methods:
-
Use the
setExternalStyleFile(String)
method of theExport
object. -
Set the
pszStyleSheet
parameter in a template file.
-
The external file style sheet is referenced in the XML output by a processing instruction of the form:
<xml-stylesheet href="style_file" type="text/css"?>
If bUseExistingStyleSheet
or setUseExistingStyleSheet
is TRUE
, but the location of the style sheet is not specified, a CSS style sheet is created.