[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] XSLT-driven syntax highlighting for XPath 2.0, XSLT 2.0 and XSD 1.1


Subject: Re: [xsl] XSLT-driven syntax highlighting for XPath 2.0, XSLT 2.0 and XSD 1.1
From: Max Toro <maxtoroq@xxxxxxxxx>
Date: Fri, 28 Dec 2012 21:45:46 -0300

Any plans to host this tool for easy consumption?
--
Max Toro


On Fri, Nov 30, 2012 at 6:39 AM, Philip Fearon <pgfearo@xxxxxxxxxxxxxx> wrote:
> I frequently need to publish documentation in HTML form that has code samples
> which include XPath 2.0 expressions, either standalone or embedded in XSLT 2.0.
> But has anyone else noticed that there aren't many syntax highlighters
> for standalone
> or XML-embedded XPath on the web?
>
> To improve this choice, I've developed an XSLT 2.0 stylesheet that's a
> syntax highlighter
> specially for XPath 2.0, XSLT 2.0, XSD 1.1 (the assert element) and
> also suitable for
> generic XML. The input to the stylesheet (specfied in an XSL
> parameter) is either XML
> or plain-text, the output is an HTML document and a CSS file.
>
> I'm sharing this in the hope that others may also find it useful. Note
> that this is not a
> 'pretty-print' formatter, it is assumed that whitespace formatting is
> in-place and this is
> all preserved in the output (including inter/intra-attribute whitespace etc.).
>
> One main concern with embedded languages (like XPath within XSLT) is
> not to overwhelm
> the reader with highlighted code colors. To alleviate this I've used
> the Solarized[1] color
> theme which has 8 highlight colors (+ 8 base colors) of relatively low
> contrast. Cooler
> colors are used for XML-based syntax and warmer colors for the XPath.
> There's some
> crossover though: for example, to show that an xsl:function 'name'
> attribute is referenced
> from XPath, a warmer color is used.
>
> Features List:
> --------------
> - Open source - maintained on GitHub
> - Processes plain-text or XML files
> - Identifies XML coloring scheme from the root namespace (if XML)
> - Just 1300 or so lines of XSLT in one file - no dependencies
> - Standard XSLT 2.0. No extensions required (developed/tested on
> Saxon-HE and Saxon-CE)
> - Uses 'Solarized' color theme
> - Light or dark color themes
> - Generates the required CSS file also - depending on theme specified
>
> - XPath 2.0 Highlighting:
>           - Supports XPath Comments
>           - All whitespace formatting preserved
>           - No dependency on reserved keywords
>           - Standalone files supported - or embedded in XML
>           - Designed to be extensible to support XPath 3.0
> - XML Highlighting
>           - Built-in XML parser (coded in XSLT) keeps all text, as-is
>           - CDATA preserved intact and highlighted
> - XSLT 2.0 Highlighting
>           - Scheme colors help separate instructions from expressions
>           - Literal Result Elements have different coloring
>           - AVTs or native XPath attributes supported
>           - All whitespace formatting preserved
> - XSD 1.1 Highlighting
>            - Element and Attribute definition elements highlighted
>            - XPath coloring for *test* attribute in *assert* element
>
> Links:
>
> Sample screenshot of XSLT 2.0 using dark color theme:
>
> http://qutoric.com/xslt/xmlspectrum/images/xsl-dark.PNG
>
> The stylesheet 'xmlspectrum.xsl' is on the GitHub project site along
> with samples etc. at:
>
> https://github.com/pgfearo/xmlspectrum
>
> Acknowledgements:
>
> [1 Solarized] http://ethanschoonover.com/solarized
>
> As ever, any feedback on color themes, missing features, issues etc
> would be greatly appreciated. Details on other XSLT stylesheets that
> do the same thing that would also
> be useful to know.
>
> Many thanks,
>
> Phil Fearon
> http://qutoric.com


Current Thread
Keywords