Liquid XML Studio
GetExtension
See Also Send Feedback
Data Mapping > Data Mapper Functions > By Category > File > GetExtension

Glossary Item Box

Function Name
GetExtension
Category
File
Icon
Description
Returns the extension of the specified path string.
Inputs
Filename The path string from which to get the extension.
Outputs
Extension The extension of the specified path (including the period "."), or null, or String.Empty. If path is null, GetExtension returns null. If path does not have extension information, GetExtension returns Empty string.
Properties
None -

Sample output

Sample Path Output extension
c:\temp\test.txt .txt
c:\test.txt .txt
.\temp\test.txt .txt
test.txt .txt
c:\temp\test
c:\temp\
"!InvalidPath' [ERROR]

 

Example

A range of functions are provided for working with Uri's and Path's. The following example demonstrates how these can be used.

 

In the following example we have a directory c:\UriExamples\ that contains the files Bookstore.xsd, Input001.xml, Input002.xml & ResolvedUri.Output.xml.

In our transform we have configured "ListFiles" to operate on the directory "c:\UriExamples\" and use the pattern "Input*.xml"

As you can see the ListFiles component gets the full paths of all the files that match the pattern. These filenames are then fed into the various Uri functions and output into an XML writer.

The result of the transform is as follows

Transform Output Copy Code
<FileProperties>
  <File>
    <FullFilename>C:\UriExamples\Input001.xml</FullFilename>
    <Filename>Input001.xml</Filename>
    <Extension>.xml</Extension>
    <Path>C:\UriExamples</Path>
    <AltFullFilename>C:\UriExamples\Backup\Input001.xml</AltFullFilename>
    <BackupFilename>C:\UriExamples\Input001.xml.bak</BackupFilename>
  </File>
  <File>
    <FullFilename>C:\UriExamples\Input002.xml</FullFilename>
    <Filename>Input002.xml</Filename>
    <Extension>.xml</Extension>
    <Path>C:\UriExamples</Path>
    <AltFullFilename>C:\UriExamples\Backup\Input002.xml</AltFullFilename>
    <BackupFilename>C:\UriExamples\Input002.xml.bak</BackupFilename>
  </File>
</FileProperties>

Lets examine the output in more detail

Compatibility

Native Execution Engine, XSLT 2.0, C#

This is a scalar function so the standard rules apply if multiple values are presented to one or more inputs.

See Also