Extension Objects

Abstract

Description of ePublisher XSL extension objects and their methods.

1   Introduction

The WebWorks ePublisher engine uses XML, XSL, and XPath as the foundation for all processing. While extremely powerful, XSL has many shortcomings when used to perform system level scripting tasks. Operations such as working with files and advanced string operations are not included in the standard XSL language.

XSL does provide a generic extension mechanism to add new features to the base language. WebWorks ePublisher provides a standard set of extension objects which enable XSL to generate all required formats.

1.1   Changes

Initial version.

2   General XSL Extensions

XSL extensions live in a specific namespace. Users can define their own prefix to associate with a given namespace, but in general sticking with a consistent naming convention makes life easier.

For example, the XSL namespace is:

http://www.w3.org/1999/XSL/Transform

To define a prefix for it, one adds an XSL namespace declaration to your XSL stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
..
</xsl:stylesheet>

Now the desired namespace can be referenced just using a prefix rather than the actual namespace. Therefore, the following two lines are equivalent:

<xsl:variable name="VarNew" select="'Hello'" />

<variable xmlns="http://www.w3.org/1999/XSL/Transform" name="VarNew" select="'Hello'" />

Microsoft's XSL transform implementation does not support extension elements at this time. Therefore, methods must be called from within "select" contexts.

<xsl:value-of select="wwexsldoc:Document($VarResult, $VarPath)" />
<xsl:variable name="VarDocumentWrite" select="wwexsldoc:Document($VarResult, $VarPath)" />

3   Microsoft Extensions

Extension objects that are defined and implemented by Microsoft as part of the .NET XSL transform runtime.

3.1   Microsoft XSLT

Purpose:
Microsoft implemented additional methods not part of the XSLT 1.1 standard. This work was done prior to the XSLT 2.0 and EXSLT specifications being finalized.
Namespace:
urn:schemas-microsoft-com:xslt
Prefix:
msxsl
Methods:
node-set(string textualXML):

Converts textual XML into a node set in a new XML document. Most often used to convert intermediate XML back into a working node set for additional processing.

Returns:
A node set equivalent to the provided textual XML.
Example:

Determine a unique set of style names for a group of paragraphs.

<xsl:variable name="VarStylesAsXML">
 <xsl:for-each select="$VarParagraphs">
  <xsl:variable name="VarParagraph" select="." />

  <wwstyle:Style name="{$VarParagraph/@stylename}" />
 </xsl:for-each>
</xsl:variable>
<xsl:variable name="VarStyles" select="msxsl:node-set($VarStylesAsXML)/*" />

<xsl:variable name="VarUniqueStylesAsXML">
 <xsl:for-each select="$VarStyles">
  <xsl:variable name="VarStyle" select="." />

  <xsl:variable name="VarStylesWithName" select="key('wwstyles-styles-by-name', $VarStyle/@name)" />
  <xsl:if test="count($VarStyle | $VarStylesWithName[1]) = 1">
   <xsl:copy-of select="$VarStyle" />
  </xsl:if>
 </xsl:for-each>
</xsl:variable>
<xsl:variable name="VarUniqueStyles" select="msxsl:node-set($VarUniqueStylesAsXML)" />

4   ePublisher Extensions

ePublisher implements a variety of extension objects to enable full processing of desired output within the language of XSL.

Note

Optional parameters are marked with a * around them. The should render as italic.

4.1   Adapters

Purpose:
xx
Namespace:
urn:WebWorks-XSLT-Extension-Adapter
Prefix:
wwadapter
Methods:
TemporaryLicense(string toolAdapterName):

xx

Returns:
Boolean.
Example:
xx
GeneratePostScriptForImage(XPathNodeIterator frameNodeIterator, string postScriptPath):

xx

Returns:
Boolean.
Example:
xx
SetPDFPageNumberOffset(int pageNumberOffset):

xx

Returns:
Nothing.
Example:
xx
AddToPDFPageNumberOffset(int addToPageNumberOffset):

xx

Returns:
Nothing.
Example:
xx
GeneratePostScriptForPDF(string originalDocumentPath, string conversionPDFDocumentPath, bool singleFile, node-set tocStylesNodeSet, node-set groupFilesNodeSet, string postScriptFilePath):

xx

Returns:
Number of pages in the PDF.
Example:
xx

4.2   Environment

Purpose:
Enable XSL transforms to query the current system environment for the location and state of programs and variables.
Namespace:
urn:WebWorks-XSLT-Extension-Environment
Prefix:
wwenv
Methods:
JDKHome():

Determine the path to the default Java Developer Kit install directory.

Returns:
Platform path as string.
Example:

Determine the path to the current JDK and jar some files.

<xsl:variable name="VarJDKHome" select="wwenv:JDKHome()" />
<xsl:variable name="VarJarPath" select="wwfilesystem:Combine($VarJDKHome, 'jar')" />
<xsl:variable name="VarJarCommand" select="wwexec:ExecuteCommand($VarJarPath, 'cvf', 'output.jar', '.')" />
RequestedPipeline(string pipelineName):

Determine if a named pipeline was specifically requested as a generation target.

Returns:
Boolean.
Example:

Generate a given report only if specifically enabled in a project or a user has specifically requested that report.

<xsl:variable name="VarGenerateReportSetting" select="wwprojext:GetFormatSetting('report-filenames-generate', 'true') = 'true'" />
<xsl:variable name="VarRequestedPipeline" select="wwenv:RequestedPipeline($GlobalPipelineName)" />
<xsl:variable name="VarGenerateReport" select="($VarGenerateReportSetting) or ($VarRequestedPipeline)" />

4.3   Exec

Purpose:
Allow XSL stylesheets to execute external programs and process results.
Namespace:
urn:WebWorks-XSLT-Extension-Execute
Prefix:
wwexec
Returns:

Exec XML Document

Namespace:
urn:WebWorks-XSLT-Extension-Execute
Prefix:
wwexec
Format:

Provides the return code, stdout, and stderr results from the running process.

<wwexec:Result version="1.0" retcode="-1">
 <wwexec:Stream name="Output">
  Standard output will show up here, aka stdout.
 </wwexec:Stream>
 <wwexec:Stream name="Error">
  Standard error will show up here, aka stderr.
 </wwexec:Stream>
</wwexec:Result>
Methods:
Execute(string commandLine):

Runs the command line using the current target's output directory as the working directory.

Returns:
Exec XML Document
Example:

Execute prettycool.exe --stdout "Isn't this grand?" --stderr nothing.

<xsl:variable name="VarExecResult" select="wwexec:Execute('prettycool.exe --stdout &quot;Isn\'t this grand?&quot; --stderr nothing')" />
ExecuteInDirectory(string directoryPath, string commandLine):

Runs the command line in the specified working directory.

Returns:
Exec XML Document
Example:

Execute prettycool.exe --stdout "Isn't this grand?" --stderr nothing in the directory C:\workingdir.

<xsl:variable name="VarExecResult" select="wwexec:ExecuteInDirectory('C:\\workingdir', 'prettycool.exe --stdout &quot;Isn\'t this grand?&quot; --stderr nothing')" />
ExecuteProgramWithArguments(string program, string arguments):

Runs the specified program with arguments formatted as a string using the current target's output directory as the working directory.

Returns:
Exec XML Document
Example:

Execute prettycool.exe --stdout "Isn't this grand?" --stderr nothing.

<xsl:variable name="VarExecResult" select="wwexec:ExecuteProgramWithArguments('prettycool.exe', '--stdout &quot;Isn\'t this grand?&quot; --stderr nothing')" />
ExecuteProgramWithArgumentsInDirectory(string directoryPath, string program, string arguments):

Runs the specified program with arguments formatted as a string in the specified working directory.

Returns:
Exec XML Document
Example:

Execute prettycool.exe --stdout "Isn't this grand?" --stderr nothing in the directory C:\workingdir.

<xsl:variable name="VarExecResult" select="wwexec:ExecuteProgramWithArgumentsInDirectory('C:\\workingdir', 'prettycool.exe', '--stdout &quot;Isn\'t this grand?&quot; --stderr nothing')" />
ExecuteCommand(string command, string argument1, string argument2, string argument3, string argument4, string argument5, string argument6, string argument7, string argument8, string argument9, string argument10, string argument11, string argument12, string argument13, string argument14, string argument15, string argument16, string argument17, string argument18, string argument19, string argument20):

Runs the specified program with zero or more arguments using the current target's output directory as the working directory.

Returns:
Exec XML Document
Example:

Execute prettycool.exe --stdout "Isn't this grand?" --stderr nothing.

<xsl:variable name="VarExecResult" select="wwexec:ExecuteCommand('prettycool.exe', '--stdout', 'Isn\'t this grand?', '--stderr', 'nothing')" />
ExecuteCommandInDirectory(string directoryPath, string command, string argument1, string argument2, string argument3, string argument4, string argument5, string argument6, string argument7, string argument8, string argument9, string argument10, string argument11, string argument12, string argument13, string argument14, string argument15, string argument16, string argument17, string argument18, string argument19, string argument20):

Runs the specified program with zero or more arguments in the specified working directory.

Returns:
Exec XML Document
Example:

Execute prettycool.exe --stdout "Isn't this grand?" --stderr nothing in the directory C:\workingdir.

<xsl:variable name="VarExecResult" select="wwexec:ExecuteCommandInDirectory('C:\\workingdir', 'prettycool.exe', '--stdout', 'Isn\'t this grand?', '--stderr', 'nothing')" />

4.4   ExslDocument

Purpose:
Allow multiple output files from an single XSL transform. Also provides routines to quickly load XML files without invoking XML validators as well as utility methods to enable correct output formatting.
Namespace:
urn:WebWorks-XSLT-Extension-Document
Prefix:
wwexsldoc
Methods:
Document(node-set nodeSet, string path, string encoding, string method, string version, string indent, string omit_xml_declaration, string standalone, string doctype_public, string doctype_system, string cdata_section_elements, string media_type):
Writes the specified node set to a file at the location defined by path. For information on additional parameters, please refer to XSL documentation for the <xsl:output> element.
Returns:
Nothing.
Example:

Write a node set to a file.

<xsl:variable name="VarResultAsXML">
 ...
</xsl:variable>
<xsl:variable name="VarResult" select="msxsl:node-set($VarResultAsXML)/*" />
<xsl:variable name="VarWriteDocument" select="wwexsldoc:Document($VarResult, 'C:\badplacefor.xml')" />
LoadXMLWithoutResolver(string uriAsString):

Loads an XML file without resolving internal paths and validation DTDs.

Returns:
A node set.
Example:

Load the page template without resolving attribute paths.

<xsl:variable name="VarPageTemplate" select="wwexsldoc:LoadXMLWithoutResolver($VarPathTemplatePath)" />
MakeEmptyElement(node-set nodeSet):

Converts a non-empty XML node to an empty node. Non-empty XML nodes have an open and close element, as in:

<img src="blue.jpg">
</img>

Empty XML nodes are composed of a single element:

<img src="blue.jpg" />
Returns:
A node set contain a single empty XML node.
Example:

Insure <img> element is emitted as an empty XML node for proper display in HTML browsers.

<xsl:variable name="VarImageElementAsXML">
 <xsl:element name="img">
  <xsl:attribute name="src">
   <xsl:value-of select="'blue.jpg'" />
  </xsl:attribute>
 </xsl:element>
</xsl:variable>
<xsl:variable name="VarImageElement" select="msxsl:node-set($VarImageElementAsXML)/*" />

<xsl:value-of select="wwexsldoc:MakeEmeptyElement($VarImageElement)" />

4.5   Files

Purpose:
xx
Namespace:
urn:WebWorks-XSLT-Extension-Files
Prefix:
wwfiles
Methods:
UpToDate(string path, string projectChecksum, string groupID, string documentID, string actionChecksum):

xx

Returns:
xx
Example:
xx

4.6   FileSystem

Purpose:
Allow XSL transforms to query and manipulate files and directories. Also handles system path parsing and processing.
Namespace:
urn:WebWorks-XSLT-Extension-FileSystem
Prefix:
wwfilesystem
Methods:
Exists(string path):

Determine if a file or directory exists at the given path.

Returns:
Boolean.
Example:

Create directory C:\exists if it does not exist.

<xsl:if test="wwfilesystem:Exists('C:\\exists')">
 <xsl:variable name="VarCreateDirectory" select="wwfilesystem:CreateDirectory('C:\\exists')" />
</xsl:if>
DirectoryExists(string path):

Determine if a directory exists at the given path. If a file exists with the given path, this method will return false().

Returns:
Boolean.
Example:

Log existence of directory C:\direxists.

<xsl:if test="wwfilesystem:DirectoryExists('C:\\direxists')">
 <xsl:variable name="VarLog" select="wwlog:Message('Directory \'', 'C:\\direxists', '\' exists!')" />
</xsl:if>
FileExists(string path):

Determine if a file exists at the given path. If directory exists with the given path, this method will return false().

Returns:
Boolean.
Example:

Log existence of file C:\fileexists.

<xsl:if test="wwfilesystem:DirectoryExists('C:\\fileexists')">
 <xsl:variable name="VarLog" select="wwlog:Message('Directory \'', 'C:\\fileexists', '\' exists!')" />
</xsl:if>
CreateDirectory(string path):

Creates a directory with the given path. If the directory already exists, the method will return false().

Returns:
Boolean.
Example:

Create directory C:\exists if it does not exist.

<xsl:if test="wwfilesystem:Exists('C:\\exists')">
 <xsl:variable name="VarCreateDirectory" select="wwfilesystem:CreateDirectory('C:\\exists')" />
</xsl:if>
DeleteDirectory(string path):

Delete the directory with the given path.

Returns:
Nothing.
Example:

Delete the directory C:\deleteme.

<xsl:variable name="VarDeleteDirectory" select="wwfilesystem:DeleteDirectory('C:\\deleteme')" />
DeleteFile(string path):

xx

Returns:
Nothing.
Example:
xx
GetFiles(string path):

xx

Returns:
xx
Example:
xx
GetRelativeFiles(string path):

xx

Returns:
xx
Example:
xx
CopyDirectoryFiles(string sourceDirectoryPath, string destinationDirectoryPath):

xx

Returns:
xx
Example:
xx
CopyFile(string sourcePath, string destinationPath):

xx

Returns:
xx
Example:
xx
FilesEqual(string alphaPath, string betaPath):

xx

Returns:
Boolean.
Example:
xx
AppendFileWithFile(string targetPath, string sourcePath):

Appends the contents of the file located at the sourcePath to the file located at the targetPath.

Returns:
Nothing.
Example:

Append the contents of "C:\FileSampleDoc.txt" to "C:\OutputAllContent.txt".

<xsl:variable name="VarADoc">C:\\File\Sample\Doc.txt</xsl:variable>
<xsl:variable name="VarAllDocs">C:\\Output\All\Content.txt</xsl:variable>
<xsl:variable name="ActionAppendingDocToAllContent" select="wwfilesystem:AppendFileWithFile($VarAllDocs, $VarADoc)" />
GetDirectoryName(string path):

xx

Returns:
xx
Example:
xx
GetFileName(string path):

xx

Returns:
xx
Example:
xx
GetExtension(string path):

xx

Returns:
xx
Example:
xx
GetFileNameWithoutExtension(string path):

xx

Returns:
xx
Example:
xx
GetWithExtensionReplaced(string path, string extension):

xx

Returns:
xx
Example:
xx
Combine(string path, string component1, string component2, string component3, string component4, string component5, string component6):

xx

Returns:
xx
Example:
xx
GetChecksum(string path):

xx

Returns:
xx
Example:
xx
ChecksumUpToDate(string path, string checksum):

xx

Returns:
xx
Example:
xx
GetRelativeTo(string path, string anchorPath):

xx

Returns:
xx
Example:
xx
TranslateFileToEncoding(string sourceFilePath, string sourceFileEncodingName, string destinationFilePath, string destinationFileEncodingName):

xx

Returns:
xx
Example:
xx

4.7   Fonts

Purpose:
Answer questions about fonts that might affect format output.
Namespace:
urn:WebWorks-XSLT-Extension-Fonts
Prefix:
wwfonts
Methods:
UnicodeFont(string fontFamily):

Determines if the specified font family is a Unicode font family. Used to detect Symbol font families.

Returns:
Boolean.
Example:

Determine if Symbol is a unicode font family.

<xsl:variable name="VarIsUnicodeFont" select="wwfonts:UnicodeFont('Symbol')" />

4.8   Imaging

Purpose:
Enable processing of images within XSL transforms.
Namespace:
urn:WebWorks-XSLT-Extension-Imaging
Prefix:
wwimaging
Returns:

Imaging Info XML Document.

Namespace:
urn:WebWorks-Imaging-Info
Prefix:
wwimageinfo
Format:

Returns information about a particular image file, including width and height, image format, bit-depth, path on system, etc.

<wwimageinfo:ImageInfo format="jpeg" width="200" height="300" bitdepth="32" grayscale="false" path="C:\\image.jpg" />
Methods:
GetInfo(string imageFilePath):

xx

Returns:
Imaging Info XML Document
Example:
xx
Transform(string inputImageFilePath, string outputImageFormat, int outputImageWidth, int outputImageHeight, string outputImageFilePath):

Create a new version of an image with a different format or with different dimensions.

Returns:
Imaging Info XML Document
Example:
xx
RasterizePostScript(string postScriptFilePath, int renderHorizontalDPI, int renderVerticalDPI, int renderWidth, int renderHeight, string targetImageFormat, int targetImageColorDepth, bool targetImageGrayscale, bool targetImageTransparent, bool targetImageInterlaced, int targetImageQuality, string targetFilePath):

Render a PostScript file to a known image format such as BMP, JPEG, PNG, or GIF.

Returns:
Imaging Info XML Document
Example:
xx
RasterizePostScript(string postScriptFilePath, bool watermark, int renderHorizontalDPI, int renderVerticalDPI, int renderWidth, int renderHeight, string targetImageFormat, int targetImageColorDepth, bool targetImageGrayscale, bool targetImageTransparent, bool targetImageInterlaced, int targetImageQuality, string targetFilePath):

Render a PostScript file to a known image format such as BMP, JPEG, PNG, or GIF.

Returns:
Imaging Info XML Document
Example:
xx
PostScriptToPDF(string postScriptFilePath, string pdfJobSettings, string pdfFilePath):

Convert the specified PostScript file to a PDF.

Returns:
Boolean.
Example:
xx

4.9   Log

Purpose:
Enable XSL transforms to report messag, warnings, and errors to the generation log.
Namespace:
urn:WebWorks-XSLT-Extension-Log
Prefix:
wwlog
Methods:
Message(string string1, string string2, string string3, string string4):

Record a message in the generation log.

Returns:
Nothing.
Example:
xx
Warning(string string1, string string2, string string3, string string4):

Record a warning in the generation log.

Returns:
Nothing.
Example:
xx
Error(string string1, string string2, string string3, string string4):

Record an error in the generation log.

Returns:
Nothing.
Example:
xx

4.10   MultiSearchReplace

Purpose:
Replace multiple strings in a single operation.
Namespace:
urn:WebWorks-XSLT-Extension-MultiSearchReplace
Prefix:
wwmultisere
Methods:
ReplaceAllInFile(string inputEncodingAsString, string inputFilePath, string outputFilePath, node-set replacements):
Replaces strings in a text file with the specified input encoding and writes the result to the output path with the specified output encoding.

[Comments from David Shaked] 1. What gets replaced with what? What is the syntax of the "node-set replacements" parameter? 2. By experiment, I discovered that the inputEncodingAsString seems to determine the output encoding, too. Is that correct? 3. I need an example showing the XSL code, sample input, and sample output of the method.

Note

Not recommended for XML files. Use page templates instead.

Returns:
Nothing.
Example:
xx
ReplaceAllInString(string input, node-set replacements):

Replaces strings in the given string and returns the result.

Returns:
String.
Example:
xx

4.11   Progress

Purpose:
Report progress during long lived XSL transforms.
Namespace:
urn:WebWorks-XSLT-Extension-Progress
Prefix:
wwprogress
Methods:
Abort():

Check to see if the user has clicked the "Cancel" button.

Returns:
Boolean.
Example:

Short-circuit XSL processing if the user has aborted.

<xsl:for-each select="$VarParagraphs">
 <xsl:variable name="VarParagraph" select="." />

 <xsl:if test="not(wwprogress:Abort())">
  <xsl:call-template name="NotVerySimpleProcess">
   <xsl:with-param name="ParamParagraph" select="VarParagraph" />
  </xsl:call-template>
 </xsl:if>
</xsl:for-each>
Start(int totalSubSteps):

Create a new progress step with the given number of sub-steps.

Returns:
Nothing.
Example:

Create a progress bar with two sub-steps.

<xsl:variable name="VarProgressTotalStart" select="wwprogress:Start(2)" />

<xsl:variable name="VarProgressStep1Start" select="wwprogress:Start(1)" />
<xsl:variable name="VarProgressStep1End" select="wwprogress:End()" />

<xsl:variable name="VarProgressStep2Start" select="wwprogress:Start(1)" />
<xsl:variable name="VarProgressStep2End" select="wwprogress:End()" />

<xsl:variable name="VarProgressTotalEnd" select="wwprogress:End()" />
End():

End the current progress step.

Returns:
Nothing.
Example:

Create a progress bar with two sub-steps.

<xsl:variable name="VarProgressTotalStart" select="wwprogress:Start(2)" />

<xsl:variable name="VarProgressStep1Start" select="wwprogress:Start(1)" />
<xsl:variable name="VarProgressStep1End" select="wwprogress:End()" />

<xsl:variable name="VarProgressStep2Start" select="wwprogress:Start(1)" />
<xsl:variable name="VarProgressStep2End" select="wwprogress:End()" />

<xsl:variable name="VarProgressTotalEnd" select="wwprogress:End()" />
SetStatus(string message):

Set the status bar for the current progress step.

Returns:
Nothing.
Example:

Report status as paragraphs are processed.

<xsl:variable name="VarParagraphCount" select="count($VarParagraphs)" />
<xsl:variable name="VarProgressParagraphsStart" select="wwprogress:Start($VarParagraphCount)" />
<xsl:variable name="VarProgressParagraphsStatus" select="wwprogress:SetStatus(concat('Processing ', $VarParagraphCount))" />
<xsl:for-each select="$VarParagraphs">
 <xsl:variable name="VarParagraph" select="." />

 <xsl:variable name="VarProgressParagraphStart" select="wwprogress:Start(1)" />

 <xsl:variable name="VarProgressParagraphStatus" select="wwprogress:SetStatus('Processing paragraph ', position(), ' of ', $VarParagraphCount, '.'))" />

 <xsl:variable name="VarProgressParagraphEnd" select="wwprogress:End()" />
</xsl:for-each>
<xsl:variable name="VarProgressParagraphsEnd" select="wwprogress:End()" />

4.12   Project

Purpose:
xx
Namespace:
urn:WebWorks-XSLT-Extension-Project
Prefix:
wwprojext
Methods:
GetDocumentsToGenerateChecksum():

xx

Returns:
String.
Example:
xx
GetProjectDataDirectoryPath():

This returns the project's top level data directory path. Traditionally this is the "Data" directory that is located next to the project file (.wep).

Returns:
String.
Example:
<!-- Create an absolute path to a configuration file in the data directory -->
<!--                                                                       -->
<xsl:variable name="VarConfFilename">MyConfigurationFile.xml</xsl:variable>
<xsl:variable name="VarDataDirectory" select="wwprojext:GetProjectDataDirectoryPath()" />
<xsl:variable name="VarPathToConfigurationFile" select="wwfilesystem:Combine($VarDataDirectory, $VarConfFilename)" />
GetProjectFilesDirectoryPath():

xx

Returns:
String.
Example:
xx
GetProjectFormatDirectoryPath():

xx

Returns:
String.
Example:
xx
GetTargetDataDirectoryPath():

xx

Returns:
String.
Example:
xx
GetTargetOutputDirectoryPath():

This returns the full path to the current target's output directory.

Returns:
String.
Example:

Create a path to "UserManual.pdf" in the output directory.

<xsl:variable name="VarUserManualFilePath select="wwfilesystem:Combine(wwprojext:GetTargetOutputDirectoryPath(), 'UserManual.pdf')" />
GetConfigurationChangeID():

xx

Returns:
String.
Example:
xx
GetRule(string ruleTypeAsString, string ruleName):

xx

Returns:
xx
Example:
xx
GetContextRule(string ruleTypeAsString, string ruleName, string documentID, string uniqueID):

xx

Returns:
xx
Example:
xx
GetOverrideRule(string ruleTypeAsString, string ruleName, string documentID, string uniqueID):

xx

Returns:
xx
Example:
xx
GetFormatName():

xx

Returns:
String.
Example:
xx
GetFormatID():

xx

Returns:
String.
Example:
xx
GetFormatSetting(string name, string defaultValue*):

This retrieves a value from the format settings. New format settings can be created using the .fti files found in the format. For example, the company info settings are found in:

Formats/Shared/common/companyinfo/companyinfo.fti

[Comment from David Shaked] Please provide a list of the format identifiers (values of the "name" parameter) that can be used in this method. I found examples by searching the XSL. Some of them are not obvious.]

Returns:
String.
Example:
<!-- in companyinfo.fti -->
<Settings>
  ...
  <Setting name="company-name" group="company-info" default="">
    <SettingClass name="string" />
  </Setting>
  ...
</Setting>

<!-- in the XSLs -->

<!-- get the company name from the format settings -->
<xsl:variable name="VarCompanyName" select="wwprojext:GetFormatSetting('company-name', 'WebWorks.com')" />
GetConditionIsPassThrough(string conditionName):

xx

Returns:
Boolean.
Example:
xx
GetGroupName(string groupID):

Gets the name of the group based on the groupID.

Returns:
String.
Example:
<xsl:variable name="VarGroupName" select="wwprojext:GetGroupName($VarProjectGroup/@GroupID)" />
GetGroupDataDirectoryPath(string groupID):

xx

Returns:
String.
Example:
xx
GetDocumentPath(string documentID):

xx

Returns:
String.
Example:
xx
GetDocumentDataDirectoryPath(string documentID):

xx

Returns:
String.
Example:
xx
GetDocumentGroupPath(string documentID):

xx

Returns:
String.
Example:
xx
DocumentExtension(string extension):

xx

Returns:
Boolean.
Example:
xx

4.13   StringUtilities

Purpose:
Extend the available string processing methods to XSL to include message formatting, specialized text escaping, regular expression operations, etc.
Namespace:
urn:WebWorks-XSLT-Extension-StringUtilities
Prefix:
wwstring
Methods:
ToLower(string value):

Convert the given string to lowercase.

Returns:
String.
Example:

Convert UppERcAse to lowercase.

<xsl:value-of select="wwstring:ToLower('UppERcAse')" />
ToUpper(string value):

Convert the given string to uppercase.

Returns:
String.
Example:

Convert lOwErcAsE to uppercase.

<xsl:value-of select="wwstring:ToUpper('lOwErcAsE')" />
Replace(string input, string search, string replacement):

Replace all occurances of search in input with replacement.

Returns:
String.
Example:

Replace all instances of <letter> with O.

<xsl:value-of select="wwstring:Replace('<letter>scar's <letter>nly <letter>strich <letter>iled an <letter>range <letter>wl t<letter>day.', '<letter>', 'o')" />
MatchExpression(string input, string searchExpressionAsString, string replacement):

Return success of match for matchExpressionAsString in input.

Returns:
Boolean.
Example:

Contains 3-4 "a"s?

<xsl:value-of select="wwstring:MatchExpression('The end of aa sentenceaaaaalways leaves me sad.', 'a{3-4}')" />
MatchExpressionValue(string input, string matchExpressionAsString):

Return value of match for matchExpressionAsString in input.

Returns:
String.
Example:

Value of 3-4 "a"s.

<xsl:value-of select="wwstring:MatchExpressionValue('The end of aa sentenceaaaaalways leaves me sad.', 'a{3-4}')" />
ReplaceWithExpression(string input, string searchExpressionAsString, string replacement):

Replace all occurances of searchExpressionAsString in input with replacement.

Returns:
String.
Example:

Replace runs of 3-4 "a"s with ". ".

<xsl:value-of select="wwstring:ReplaceWithExpression('The end of aa sentenceaaaaalways leaves me sad.', 'a{3-4}', '. ')" />
CSSClassName(string styleName):

Convert the given string into a valid CSS class name.

Returns:
String.
Example:

Convert Blue_Moon.Detective;Agency into a valid CSS style name.

<xsl:value-of select="wwstring:CSSClassName('Blue_Moon.Detective;Agency')" />
WebWorksHelpContextOrTopic(string value):

Converts the given string intto a valid WebWorks Help context or topic string.

Note

WebWorks Help context and topic strings may only contain the characters A-Z, a-z, 0-9, and _.

Returns:
String.
Example:

Convert A long time... into a valid WebWorks Help context or topic name.

<xsl:value-of select="wwstring:WebWorksHelpContextOrTopic('A long time...')" />
MD5Checksum(string value):

Compute the MD5 checksum on the given string.

Returns:
MD5 checksum as string.
Example:

Determine the MD5 signature for A long time ago, way back in history, when all there was to drink, was nothing but cups 'o tea..

<xsl:value-of select="wwstring:MD5Checksum('A long time ago, way back in history, when all there was to drink, was nothing but cups \'o tea.')" />
EscapeForXMLAttribute(string value):

Escape string assume it will be written as the value of an XML attribute.

Returns:
String.
Example:

Write onClick handler for <div> tag.

<html:div onClick="{wwstring:EscapeForXMLAttribute('alert(\'Boo!\');')}">
 Click me!
</html:div>
JavaScriptEncoding(string value):

Convert all non-ASCII characters to Unicode escape sequences. Also convert all ASCII characters less than 32 along with problematic escape characters, i.e. \, to Unicode escape sequences.

Returns:
String.
Example:

Convert Hello\nworld!\n to JavaScript encoded text.

<xsl:value-of select="wwstring:JavaScriptEncoding('Hello\nworld!\n')" />
PalmReaderEncoding(string encodingName, string value):

Encode string as required by Palm Reader.

Returns:
String.
Example:

Encode Black moon rising\nwas entertaining. for Palm Reader.

<xsl:value-of select="wwstring:PalmReaderEncoding('Black moon rising\nwas entertaining.')" />
Format(string format, string argument1, string argument2, string argument3, string argument4, string argument5, string argument6, string argument7, string argument8, string argument9, string argument10*):

Format a message using the C# string formatter.

See also C# String Formatting Information.

Returns:
String.
Example:

Format message 17 total, 15 of 17..

<xsl:value-of select="wwstring:Format('{0} total, {1} of {0}.', 17, 15)" />

4.14   Units

Purpose:
Utility methods for extracting units and value from raw strings along with unit-to-unit conversion routines.
Namespace:
urn:WebWorks-XSLT-Extension-Units
Prefix:
wwunits
Methods:
NumericPrefix(string value):

Extract the numeric prefix of the given string.

Returns:
String.
Example:

Determine numeric prefix of 24px.

<xsl:variable name="VarNumber" select="wwunits:NumericPrefix('24px')" />
UnitsSuffix(string value):

Extract the units suffix of the given string. Only returns a non-zero length string of there is also a numeric prefix.

Returns:
String.
Example:

Determine units of 24px.

<xsl:variable name="VarNumber" select="wwunits:UnitsSuffix('24px')" />
Convert(double sourceValue, string sourceUnits, string targetUnits):

Convert a measurement from one set of units to another.

Returns:
Number.
Example:

Convert 2in to centimeters (cm).

<xsl:variable name="VarCentimeters" select="wwunits:Convert(wwunits:NumericPrefix('2in'), wwunits:UnitsSuffix('2in'), 'cm')" />
xx():

xx

Returns:
xx
Example:
xx
RTFColor(string htmlColor):

Convert a standard HTML/CSS color to an RTF color.

Returns:
RTF color as string.
Example:

Convert #FF3399 to an RTF color.

<xsl:varaible name="VarRTFColor" select="wwunits:RTFColor('#FF3399')" />
CSSRGBColor(string htmlColor):

Convert the given HTML/CSS color to a hex encoded CSS color. Useful for converting named colors such as green to their hex equivalents.

Returns:
Hex encoded CSS color as string.
Example:

Convert green to the hex equivalent.

<xsl:variable name="VarGreenAsRGB" select="wwunits:CSSRGBColor('green')" />
EncodingFromCodePage(int codePage):

Determine the HTML encoding for a page given a Windows code page value.

Returns:
String.
Example:

Determine the HTML encoding for code page 23.

<xsl:variable name="VarEncoding" select="wwunits:EncodingFromCodePage(23)" />

4.15   URI

Purpose:
Utility methods which convert to and from file paths and create absolute or relative URIs.
Namespace:
urn:WebWorks-XSLT-Extension-URI
Prefix:
wwuri
Methods:
IsFile(string uriAsString):

Determine if the supplied URI refers to the file system.

Returns:
Boolean.
Example:

Determine if \\network\filesystem\file and file:///network/filesystem/file are file URIs.

<xsl:if test="wwuri:IsFile('\\\\network\\filesystem\\file')">
 <xsl:variable name="VarLog" select="wwlog:Message('File!')" />
</xsl:if>

<xsl:if test="wwuri:IsFile('file:///network/filesystem/file')">
 <xsl:variable name="VarLog" select="wwlog:Message('File!')" />
</xsl:if>
AsFilePath(string uriAsString):

Convert a file URI into a system file path.

Returns:
File path as string.
Example:

Convert URIs \\network\filesystem\file and file:///network/filesystem/file to file paths.

<xsl:variable name="VarFilePath1" select="wwuri:AsFilePath('\\\\network\\filesystem\\file')">

<xsl:variable name="VarFilePath2" select="wwuri:AsFilePath('file:///network/filesystem/file')">
AsURI(string uriAsString):

Convert file paths to URIs.

Returns:
URI as string.
Example:

Convert C:\file to a URI.

<xsl:variable name="VarURI" select="wwuri:AsURI('C:\\file')" />
GetRelativeTo(string uriAsString, string anchorUriAsString):

Convert an absolute URI into a relative URI.

Returns:
URI as string.
Example:

Determine the relative path to http://www.webworks.com/css/webworks.css from http://www.webworks.com/information/index.html.

<xsl:variable name="VarRelativeURI" select="wwuri:GetRelativeTo('http://www.webworks.com/css/webworks.css', 'http://www.webworks.com/information/index.html')" />
MakeAbsolute(string absoluteUriAsString, string uriAsString):

Convert a relative URI into an absolute URI. If the second parameter is already an absolute URI, it will be returned unchanged.

Returns:
URI as string.
Example:

Fully qualify the relative URI ../css/webworks.css against the absolute URI http://www.webworks.com/information/index.html.

<xsl:variable name="VarCSSURI" select="wwuri:MakeAbsolute('http://www.webworks.com/information/index.html', '../css/webworks.css')" />
EscapeUri(string unescapedUri):

Convert unescaped URI into an escaped URI path.

Returns:
Escaped URI as a string.
Example:

Convert http://www.webworks.com/name with spaces.html to http://www.webworks.com/name%20with%20spaces.html.

<xsl:variable name="VarEscapedURI" select="wwuri:EscapeUri('http://www.webworks.com/name with spaces.html')" />
EscapeData(string unescapedString):

Convert unescaped string into an escaped URI data.

Returns:
Escaped string.
Example:

Convert http://www.webworks.com/name with spaces.html to http%3a%2f%2fwww.webworks.com%2fname%20with%20spaces.html.

<xsl:variable name="VarEscapedData" select="wwuri:EscapeData('http://www.webworks.com/name with spaces.html')" />
Unescape(string escapedString):

Convert URI escaped string into unescaped string (%20 to space, etc.).

Returns:
Unescaped string.
Example:

Convert name%20with%20spaces.html to name with spaces.html.

<xsl:variable name="VarUnescape" select="wwuri:Unescape('name%20with%20spaces.html')" />

5   Custom Extensions

The Microsoft XSL transform engine also supports custom extensions defined with script blocks.

DevCenter/Documentation/ExtensionObjects (last edited 2008-10-06 18:01:29 by BenAllums)