Rexsel Editor

There is an (experimental) editor application for MacOS systems. It uses the identical Rexsel Kernel that the CRexsel command line app uses. MacOS may complain that it is a security risk as it claims it comes from a unknown developer — clearly use at your own risk, or Email me for access to the source to build it locally.

Downloading

The MacOS application can be downloaded from here. The editor panel is based on a modified version of CodeEditorView from Manuel Chakravarty (many thanks to him). The modification is just the addition of a Rexsel language configuration for syntax colouring (a single file).

Starting

The initial window when the application is run allows the user to open an existing file or create a new source file. Select a new document.

Initial Window

The editor creates a new document with an initial source file with a simple template. There are three panels.

1: The source code window where you create the Rexsel code. Currently there is no attendant line number for each line. However the position of the cursor is shown below the source panel.

2: The XSL code window where the compiler writes the generated code.

3: The error and symbol table output produced by the compiler.

New Source3 File
Editor Controls

Below the source panel there are several controls:

Theme Select dark or light mode for the editor panel.
Minimap Show/Hide the mini-map panel to the right of the editor window.
Wrap Enable/disable the line wrap for lines wider than the panel width.

The three checkboxes at the bottom of the window mirror the options in the CRexsel command line app.

Line Numbers Show source line number comments interleaved in the output XSL.
Show Undefined Show the undefined variables with the errors, otherwise only show other errors.
Default XLMNS Do not use "xsl:" prefix for XSL tags. The default name space for the document is considered to be "http://www.w3.org/1999/XSL/Transform".
New Source3 File
Compiling

When adding source in the source window the XSL output can be compiled either automatically as the source is entered, or explicitly when the user requires. If the former is required check the "Auto Compile" option (1). The "Generate XSL" is then disabled (2). If the "Auto Compile" is unchecked this button is enabled and the user can explicitly compile the source. Using this feature is useful for entering and compiling large source files as there is delay in producing the code that can be a problem with auto-compile. The compiled source can be saved using the "Save XSL" button (3).

New Source3 File

As an example take one of the Rexsel transform source3 files from the Hop Vine Music site (http://www.hopvine-music.com) — without most of the comment lines.

extracted from assemblePage.rxsl
stylesheet { version "1.0" xmlns "page" "http://www.hsfr.org.uk/Schema/Page" xmlns "link" "http://www.hsfr.org.uk/Schema/Link" xmlns "list" "http://www.hsfr.org.uk/Schema/List" // The page id derived from the sitemap and is usually the file // name without the extension. parameter page // Global variable for the page name. variable gPage "$page" constant gLanguage "'en'" // -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* match using "root" { element "page:page" { attribute "page" { value "$gPage" } attribute "lang" { value "$gLanguage" } apply-templates } } // -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* // -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* match using "//list:list[@id='nav-menu']//link:link[ @type='ref' ]" { element "link:link" { attribute "type" "uri" attribute "ref" { value "concat( @ref, '?lang=', $gLanguage )" } apply-templates } } // ... }

This will compile to (extra indentation manually inserted for clarity)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:page="http://www.hsfr.org.uk/Schema/Page" xmlns:link="http://www.hsfr.org.uk/Schema/Link" xmlns:list="http://www.hsfr.org.uk/Schema/List"> <xsl:param name="page"/> <xsl:variable name="gPage" select="$page"/> <xsl:variable name="gLanguage" select="'en'"/> <xsl:template match="root"> <xsl:element name="page:page"> <xsl:attribute name="page"> <xsl:value-of select="$gPage"/> </xsl:attribute> <xsl:attribute name="lang"> <xsl:value-of select="$gLanguage"/> </xsl:attribute> <xsl:apply-templates /> </xsl:element> </xsl:template> <xsl:template match="//list:list[@id='nav-menu']//link:link[ @type='ref' ]"> <xsl:element name="link:link"> <xsl:attribute name="type"> <xsl:text>uri</xsl:text> </xsl:attribute> <xsl:attribute name="ref"> <xsl:value-of select="concat( @ref, '?lang=', $gLanguage )"/> </xsl:attribute> <xsl:apply-templates /> </xsl:element> </xsl:template> </xsl:stylesheet>

The generated symbol table output is

No Errors Symbols in stylesheet context in line 1, found: 5 symbols [M] "//list:list[@id='nav-menu']//link:link[ @type='ref' ]" in line 34 [M] "root" in line 18 [P] page in line 9 used in line(s) 12 [V] gLanguage in line 14 used in line(s) 24, 38 [V] gPage in line 12 used in line(s) 21
Displaying errors

Consider a simple mistype

match usng "root" { element "page:page" { attribute "page" { value "$gPage"

This will give the error and symbol table

**** (106) Unexpected symbol "usng" in line 18 Check spelling, did you mean "using" ? **** (148) "match" requires "using" in line 18 Check syntax requirements for "match" Symbols in stylesheet context in line 1, found: 5 symbols [M] "" in line 18 [M] "//list:list[@id='nav-menu']//link:link[ @type='ref' ]" in line 34 [P] page in line 9 used in line(s) 12 [V] gLanguage in line 14 used in line(s) 24, 38 [V] gPage in line 12 used in line(s) 21

This is displayed in the source editing panel as

Error notification

showing 2 errors on line 18. Clicking on the error panel expands this to show the errors.

Error expansion
Line numbers etc

Inserting line numbers and using default XML namespace gives

<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:page="http://www.hsfr.org.uk/Schema/Page" xmlns:link="http://www.hsfr.org.uk/Schema/Link" xmlns:list="http://www.hsfr.org.uk/Schema/List"> <!-- Line: 9 --> <param name="page"/> <!-- Line: 12 --> <variable name="gPage" select="$page"/> <!-- Line: 14 --> <variable name="gLanguage" select="'en'"/> <!-- Line: 18 --> <template match="root"> <!-- Line: 19 --> <element name="page:page"> <!-- Line: 20 --> <attribute name="page"> <!-- Line: 21 --> <value-of select="$gPage"/> </attribute> <!-- Line: 23 --> <attribute name="lang"> <!-- Line: 24 --> <value-of select="$gLanguage"/> </attribute> <!-- Line: 27 --> <apply-templates /> </element> </template>
Copyright 2024 Hugh Field-Richards. All Rights Reserved.