This project is read-only.

Xslt Extension Functions

One of the great things about having your own xslt utility is that you can add functions that permit you to do things that are hard or impossible in pure xslt.

To use these add the following attribute to your xsl:stylesheet tag:

xmlns:PerfectStorm="urn:PerfectStorm"
exclude-result-prefixes="PerfectStorm"

CamelToPascal

<xsl:value-of select="PerfectStorm:CamelToPascal(@name)" />

This is useful for various coding standards.
XML attributes are traditionally camelCase where elements are either lowercase or PascalCase.

Filename

<xsl:value-of select="PerfectStorm:Filename()" />

Returns the name of the generated file.

FileRegenerated

<xsl:value-of select="PerfectStorm:FileRegenerated()" />

Returns TRUE if this file had previously existed, FALSE if the file is new.

GetDateTime

<xsl:value-of select="PerfectStorm:GetDateTime()" />

GetVariable

<xsl:value-of select="PerfectStorm:GetVariable('CodeGen.Tool')" />

This is useful for inserting standard pieces of text / XML / code across multiple files.
The example provide a better version of the "This code was generated by a tool" that is added by a certain Microsoft code generation tool.

The intent is to include more complex variable interactions.
One possibility is that a variable may be assigned the output of a regex that is run on the previously existing file.
This could be used to maintain vcs assigned header comments across regenerations.

LowerCase

<xsl:value-of select="PerfectStorm:LowerCase(@name)" />

This is useful for various coding standards.
XML attributes are traditionally camelCase where elements are either lowercase or PascalCase.

NamedGuid

<xsl:value-of select="PerfectStorm:NamedGuid(@Name)" />

First call with a given name will create a variable of given name containing a new guid.
Will always return that guid within a session (single call of CodeGen or in the upcoming batch mode).

NewGuid

<xsl:value-of select="PerfectStorm:NewGuid()" />

Will return a new guid.

PascalToCamel

<xsl:value-of select="PerfectStorm:PascalToCamel(@name)" />

This is useful for various coding standards.
XML attributes are traditionally camelCase where elements are either lowercase or PascalCase.

UpperCase

<xsl:value-of select="PerfectStorm:UpperCase(@name)" />

Upper Case is frequently used in code for constants or in some places for SQL keywords.

Last edited Jul 29, 2008 at 5:29 AM by chriseyre2000, version 3

Comments

No comments yet.