formatting XPath expressions in XSLT 3 text templates
Posted: Sat Apr 13, 2019 1:10 pm
Using XML Editor 21.0, build 2019040204, I am struggling to get some nice formatting of XPath expressions in XSLT 3 text templates.
For instance, imagine I have prototyped some XPath code in the XPath builder e.g.
and now open a new XQuery file and paste that code and use the format and indent button I get a nice formatting and indentation (although the indentation seems to get lost here in the forum when pasting into a code BB block):
However, when I create a new XSLT 3 document and paste the expression into a text template and use the format and indent button I get some rather messy result, the XPath expression is not formatted well:
Is there some way to get a better formatting and indentation of XPath expressions in XSLT text templates?
For instance, imagine I have prototyped some XPath code in the XPath builder e.g.
Code: Select all
serialize(array { let $s := ('a', 'b', 'c', 'd') return for-each-pair($s[position() mod 2 = 1], $s[position() mod 2 = 0], function ($s1,$s2) { [$s2, $s1] }) }, map { 'method' : 'json', 'indent' : true() })
Code: Select all
serialize(array {
let $s := ('a', 'b', 'c', 'd')
return
for-each-pair($s[position() mod 2 = 1], $s[position() mod 2 = 0], function ($s1, $s2) {
[$s2, $s1]
})
}, map {
'method': 'json',
'indent': true()
})
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math"
version="3.0">
<xsl:template name="xsl:initial-template">{serialize(array { let $s := ('a', 'b', 'c', 'd')
return for-each-pair($s[position() mod 2 = 1], $s[position() mod 2 = 0], function ($s1,$s2)
{ [$s2, $s1] }) }, map { 'method' : 'json', 'indent' : true() })}</xsl:template>
</xsl:stylesheet>