Sun N1 Service Provisioning System 5.1 XML Schema Reference Guide

<transform> Step

The <transform> step is used to perform a text-based transformation to a file on the target host. Currently, the provisioning system supports Perl-type and XSLT-based transformations.

If the output file exists on the target host before the transformation, the permissions and ownership of the file are preserved. However, if the output file is new, it inherits the default RA permissions.

The <transform> child elements specify the transformation to be applied to the input file. The child elements can be any one of the following elements:

Attributes for the <transform> Step

The <transform> step has the following attributes:

The input and output attributes can reference the same or distinct files. The value of these attributes is a generalized path that can include zip archives or zip derivatives, such as JAR, as directory elements. For example, a path might be webapp/myapp.jar/config.xml.

<stylesheet> Element

The <stylesheet> element is a child of the <transform> step. This element specifies an XSLT transformation to apply to the input source. At most one <stylesheet> element can appear as a child of a particular <transform> element. You cannot use the <stylesheet> element in conjunction with other child elements.

The <stylesheet> element is an XSLT Version 1.0 element as defined by the http://www.w3.org/1999/XSL/Transform name space. For more information, see Version 1.0 of the XSL Transformations (XSLT) specification at http://www.w3.org/TR/xslt.html. Only the XSLT <stylesheet> element is accepted as a child of the <transform> element. In particular, neither the XSLT synonym <transform> nor the simplified XSLT transform syntax described in Section 2.3 of the XSLT specification is supported as a child of the <transform> element.

The <stylesheet> element body can include substitution variable references if the body is still a valid XSLT without first undergoing variable substitution.

When a <stylesheet> element is used as a transformation, the input file must be written in XML. For more information, see Version 1.0 of the XSL Transformations (XSLT) specification.


Example 2–4 Using the <stylesheet> Element

This transformation changes each a to a b in the /etc/hosts file. The hosts file is overwritten with these changes.


<transform output="/etc/hosts">
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
            <xsl:for-each select="a">
                <xsl:value-of select="b"/>
            </xsl:for-each>
        </xsl:template>
    </xsl:stylesheet>
</transform>

<subst> Element

The <subst> element is a child of the <transform> step. This element specifies a Perl-like substitution pattern to apply as a transformation. One or more <subst> elements can appear as children of the <transform> element, but they cannot be used in conjunction with other child elements. When more than one <subst> element appears, they are applied sequentially.

All occurrences of the pattern in the input file are replaced, including multiple occurrences on a line.

For information about the supported syntax, see Java documentation (class java.util.regex.Pattern).

Attributes for the <subst> Element

The <subst> element has the following attributes:


Example 2–5 Using the <subst> Element

The following transformation converts all occurrences of the string 127.0.0.xxx to 10.10.0.xxx in the /etc/hosts file:


<transform output=”/etc/hosts”>
    <subst match="127\.0\.0\.(\d+)"
    replace="10.10.0.$1"/>
</transform>

<source> Element

The <source> element is a child of the <transform> step. This element specifies an external file on the target host that contains the transformation to be applied to the input file. At most one <source> element can appear as a child of a particular <transform> element. You cannot use the <source> element in conjunction with other child elements.

Configuration generation is not performed on the specified source file as part of the <transform> step. However, the specified source file can be a config-type resource file that is deployed as part of a component installation. In such as case, substitution variables that are contained in the source file would have been substituted when the file was deployed.

Attributes for the <source> Element

The <source> element has the following attributes: