Skip to content

Commit 655fada

Browse files
committed
readme updates
1 parent c4624ed commit 655fada

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

README.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,36 @@ Using two XSLT functions, `print()` and `println()`, the result of an XPath expr
88
> `fn:serialize($n, map{'method':'adaptive'})`<br>
99
> The XSLT functions here simply provide more extensibility for features such as coloring and indentation
1010
11-
## Main differences from JSON:
12-
13-
1. XPath sequences are represented with parenthesis like: '(1,2,3,4)'
14-
2. Map keys are enclosed in single-quotes and then only if they are of type xs:string
15-
3. Atomic values are enclosed in single-quotes but then only if they are of type xs:string
16-
4. Boolean values are represented as: true() and false()
17-
5. Nodes are represented by XPath locations - namespace-prefixes are used in the location if declared on the context root element
18-
6. Colorised output via ANSI escape sequences (requires messageEmitter setting - only available for SaxonJ versions prior to 9.9.0.2)
19-
20-
21-
### Sample xsl:message output
22-
The xsl:message output to the VS Code terminal using `ext:print()` and `ext:println()`:
23-
24-
<img src="sample/colorised-xpath.png" width="800px">
11+
---
12+
### Sample Usage
13+
```xml
14+
<xsl:message expand-text="yes">
15+
==== Root element ====
16+
languages-count: {node-name() => ext:print(9,' ')}
17+
colorNodes: {ext:print((*,*/@*),9,' ')}
18+
19+
</xsl:message>
20+
<xsl:copy>
21+
<xsl:message expand-text="yes">
22+
==== data====
23+
context: {ext:print(.,10,' ')}
24+
language: {ext:print($langItems,10,' ')}
25+
</xsl:message>
26+
```
27+
28+
29+
Screenshot from the xsl:message output shown above in the VS Code terminal using `ext:print()` and `ext:println()`:
30+
31+
<img src="sample/colorised-xpath.png" width="500px" style="border-style:solid; border-width:1px;border-color:#808080">
2532

2633
## Key Resource Files
2734
- Source XSLT: `src/xpath-result-serializer.xsl`
2835
- Sample: `sample/test-serializer.xsl`
2936

3037
## Colorising of xsl:message Output with Saxon
3138

32-
If a Saxon version prior to `9.9.0.1` is detected, ANSI escape sequences are included in the outputs of `ext:print()` and `ext:println()` to provide colorisation (see screenshot).
39+
If a Saxon version prior to `9.9.0.1` is detected, ANSI codes are included in the outputs of `ext:print()` and `ext:println()` to provide colorisation (see screenshot).
40+
41+
These ANSI would normally escaped as XML character references in the result. In SaxonJ, prior to v9.9.0.2, the command-line option `-m:net.sf.saxon.serialize.TEXTEmitter` can be used to prevent this XML escaping so xsl:message colors can be seen as intended.
3342

34-
These escape sequences would normally escaped as XML character references in the result. In SaxonJ, prior to v9.9.0.2, the command-line option `-m:net.sf.saxon.serialize.TEXTEmitter` can be used to prevent this XML escaping so xsl:message colors can be seen as intended.
43+
To prevent escaping of ANSI codes with the Saxon API - see the Saxon [Message Output Documentation](https://www.saxonica.com/documentation12/index.html#!using-xsl/stylesheet-output/message-output).

sample/colorised-xpath.png

-67.2 KB
Loading

0 commit comments

Comments
 (0)