FRENDS⁴ Common Components : Frends.Common.Data.TransformData.XSLTTransform

This task takes an XML document as an input and then executes the given XSLT transformation to that document outputting the resulting XML.

Input Parameters

Input Parameters

Parameter nameDescriptionData typeExample values
Input

The document that the XSLT transformation is executed against. Input can be given in the following formats:

  • XML as a C# String
  • C# XmlDocument
String / XmlDocument
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
      <bar><xsl:value-of select="foo"/></bar>
    </xsl:template>
</xsl:stylesheet>
XSLT
  • The XSLT document that the input is transformed against.
String
<?xml version="1.0" encoding="UTF-8"?>
<foo>bar</foo>
XSLT Parameters

Collection of XSLT-parameters for the transform. For examples and documentation see XSLT <xsl:param> Element.

Parameter nameDescriptionData typeExample
 Name Name of the parameter. Value can be used in the XSLT-map with this name.String "NumberOfPeople"
Value  Value of the parameter.String  "100"
Object collection 
ParserXSLT parser beeing used.
Saxon, .Net

Output Result

  • String
    • A string containing the transformed XML document

Parser

Starting from task version 1.3.4.0 it possible to set XSLT parser (processor) being used. Saxon, which is used in previous versions, is used by default and XSLT parser provide by .Net is available as option. The main difference is that Saxon supports XSLT 2.0 and .Net support XSLT 1.0 with support to msxsl:script blocks, which enables using C# script inside XSL files.

Errors

The task will return an exception The input data was not recognized. Supported formats are XML string and XMLDocument. if the input data or the XSLT document could not be read correctly.

The task will return an exception Xpath query returned zero elements. if the XPath did not match any elements.

 

Example Usage

For XSLT examples and documentation see W3Schools XSLT.

Input: 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
      <bar><xsl:value-of select="foo"/></bar>
    </xsl:template>
</xsl:stylesheet>

XML:  

<?xml version="1.0" encoding="UTF-8"?>
<foo>bar</foo>

Results

<bar>bar</bar>