N1 Service Provisioning System 4.1 Reference Guide

transform Step

The <transform> step is used to perform a text-based transformation on a file contained on the target host. Currently, Perl5 and XSLT based transforms are supported.

transform Step attributes

Name 

Type 

Required 

Configurable 

Description 

input 

String 

No 

Yes 

The generalized path of the file on the target host to apply the transform to. If unspecified, input is read from the output file. 

output 

String 

Yes 

Yes 

The generalized path of the file on the target host to write the result of the transform to. 

The input and output attributes can reference the same or distinct files. The value of the input and output attributes is a generalized path that can include zip archives (or zip derivatives such as JAR, etc.) as directory elements, e.g. webapp/myapp.jar/Configurablexml.

transform Element child elements

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

The stylesheet transform Child Element

The <stylesheet> element is a child of the <transform> step, and specifies an XSLT transform to apply on the input source. At most one <stylesheet> element may appear as a child of a particular <transform> element, and they may not be used in conjunction with any other child elements.

The <stylesheet> element is an XSLT version 1.0 element as defined by the namespace “http://www.w3.org/1999/XSL/Transform”. Please see the XSLT specification at “http://www.w3.org/TR/xslt” for details. Note that 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 are supported as children of the transform element.

The stylesheet element body may include substitution variable references so long as the body is still considered valid XSLT without first undergoing variable substitution.

When a <stylesheet> element is used as a transform, it is assumed that the input file is written in XML.

Example of the stylesheet Element

The following is an example of an XSLT transform.


<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> 

The subst transform Child Element

The <subst> element is a child of the <transform> step, and specifies a Perl5-based substitution pattern to apply as a transform. Multiple <subst> elements may appear as children of the <transform> elements, but they may not be used in conjunction with any other child elements. When more than one <subst> elements appear, they are applied sequentially.

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

The details of the supported syntax can be found in the Oro documentation (class org.apache.oro.text.regex.Perl5Substitution).

subst Element attributes

Name 

Type 

Required 

Configurable 

Description 

match 

String 

Yes 

Yes 

A case-sensitive Perl5 regular expression which is sought for in the input.  

replace 

String 

Yes 

Yes 

A Perl5 replacement value substituted for each occurrence of the pattern given by “match”. This value is not interpreted verbatim: the construct $n is interpreted as the nth parenthesized expression inside the matching expression. 

An Example of the subst Element

The following transform converts all occurrences of the string 127.0.0.xxx into 10.10.0.xxx within the file /etc/hosts:


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

The source transform Child Element

The <source> element is a child of the <transform> step, and specifies an external file on the target host which contains the transform to be applied to the input file. At most one <source> element may appear as a child of a particular <transform> element, and they may not be used in conjunction with any other child elements.


Note –

No config generation is performed on the named source file as part of the <transform> step. However, the named source file may be a config-type resource file deployed as part of a component install, in which case substitution variables contained in the source file would have been substituted when the file was deployed.


source Element attributes

Name 

Type 

Required 

Configurable 

Description 

type 

One of: 

PERL 

XSLT 

Yes 

No 

The type of transform contained in the named file, as described below.  

name 

String 

Yes 

Yes 

The name of the file on the target host that contains the transform. The content of the named file must correspond to the type defined by the “type” attribute. The name may not include zip archives as directory elements.  

The type Attribute of the source Element

The “type” attribute of the <source> element specifies the type of transformation contained in the named file.

A value of “PERL” indicates a Perl5-based transform similar to that of the <subst> element. In this case, the named file should have format similar to the following:


<?xml version='1.0'?>
<transform>
	<subst match=”127\.0\.0\.(\d+)” replace=”10.10.0.$1” />
</transform> 

Perl-type external transform files may contain any number of <subst> elements.

A value of “XSLT” indicates an XSLT transform. In this case the named file contains a standard XSLT version 1.0 transform as defined by the namespace “http://www.w3.org/1999/XSL/Transform”. Note that unlike inline transforms which only allow the XSLT <stylesheet> element, XSLT transforms contained in external source files may include any valid top-level XSLT transform element including <stylesheet>, <transform>, and simplified XSLT syntax as described in section 2.3 of the XSLT specification.