Skip to content

XLST Extensions

awisto XLST extension

To simplify formatting inside XSLT documents the following XSLT extension are available. All of them allow formatting of numbers and dates based on the internationalised settings.

Integration

The Namespace of the extensions must be made known to the node in this way:

<xsl:stylesheet version="2.0"
    xmlns:fn="awisto:format-number"
    xmlns:fd="awisto:format-date"
    xmlns:fs="awisto:format-string"
    xmlns:fi="awisto:format-image"
    xmlns:sw="awisto:system-wide-variable"
    xmlns:az="awisto:http-request"

Unused Extensions

Use only those extensions required for your data source

format-number

int

  • formatint (number)

float

  • formatfloat(number, accuracy)

money

  • formatmoney(number, symbol, accuracy)

Format a number with specified accuracy or the currency symbol based on the user settings. Formatmoney allows to specify the accuracy, if no accuracy is specified the default value 2 is taken

<xsl:value-of select=“fn:formatfloat($myvaribale, 2)” />

formate-date

  • format(text, format)

    text: could be any field or the datetime format: the requested format for the date within C# Format

  • now() :

    returns DateTime.Now. This will return the current universal time. You can use the format function if you want a specific format.

Format a date text based on the user settings and the entered .NET Franwork Time- and Date-Formats.

format-string

replace

  • replace(text, search, replace)

Replace a string search in text text with the specified replace replace.

<xsl:value-of select=“fs:replace($myvaribale, ‘MyString’, ‘MyReplacement’)” />

format-image

  • Scale(image, scaleFactor)

  • image: The field which contains the image as base64 string

  • scaleFactor: The factor in percentage to scale a image up or down. A value below 100 will scale down and a value upper then 100 will scale up

  • Scale(image, width, height)

  • image: The field which contains the image as base64 string

  • width: The absolut with of the image in pixel. Can be lower or bigger as the original image. If you choose a different width / height ratio the image will be warped. You can use -1 to calculate the width based on the given height to keep the current ration.
  • height: The absolut height of the image in pixel. Can be lower or bigger as the original image. If you choose a different width / height ratio the image will be warped. You can use -1 to calculate the width based on the given height to keep the current ration.

Warping

Using an absolut width and height the image could be warped. You can use the absolut scaling while keeping the ratio. Just set one value to an absolut value while keeping the other value to -1

  • Cut(image, width, height, startX, startY)

  • image: The field which contains the image as base64 string

  • width: The absolut with of the image in pixel. This will not scale the image. If you choose a bigger width as the original image, the image will be filled with empty space.
  • height: The absolut height of the image in pixel. This will not scale the image. If you choose a bigger width as the original image, the image will be filled with empty space.
  • The X position where the cut should start. The position must be within the original image.
  • The Y position where the cut should start. The position must be within the original image.

  • Crop(image)

  • image: The field which contains the image as base64 string. The function will detect the border automatically and removes it

  • Padding(image, paddingLeft, paddingTop , paddingRight, paddingBottom, color)

  • image: The field which contains the image as base64 string.

  • paddingLeft: The amount of pixels which should be added as padding on the left.
  • paddingTop : The amount of pixels which should be added as padding on the top.
  • paddingRight: The amount of pixels which should be added as padding on the tight.
  • paddingBottom: The amount of pixels which should be added as padding on the bottom.
  • color: The color of the added padding. You can use either the name of the color or its HEX code

Examples for Image Scaling

  • scale a image down to 25%
    <xsl:value-of select="fi:Scale(documentbody, 25)"/>
    
  • scale a image down to 50 pixel in width and 50 pixel in height
    <xsl:value-of select="fi:Scale(entityimage, 50, 50)"/>
    
  • cut an image to a widht of 300 and a height of 200, starting on the topper left corner (position 0, 0)
    <xsl:value-of select="fi:Cut(documentbody, 300, 200, 0 ,0)"/>
    
  • crop an image / remove a border
    <xsl:value-of select="fi:Crop(documentbody)"/>
    
  • add a padding of 50 pixel on each side in the red color
    <xsl:value-of select="fi:Padding(documentbody, 50, 50, 50, 50, 'red')"/>
    
  • remove the current border and add an padding of 50 pixel on each side in the red color
    <xsl:value-of select="fi:Padding(fi:Crop(documentbody), 50, 50, 50, 50, 'red')"/>
    

system-wide-variable

  • get(variable)

  • the get function of the system-wide-variable extension can be used to use a system wide variable within the xml itself. Any system wide variable can be used as parameter for the get function. The variable should be used without the @ tag.
<xsl:value-of select="sw:get('userid')"/>