DesignLiquido / xslt-processor

A JavaScript XSLT processor without native library dependencies
GNU Lesser General Public License v3.0
94 stars 30 forks source link

Revamping Expression Context, special operator for XPath, etc. #65

Closed leonelsanchesdasilva closed 11 months ago

leonelsanchesdasilva commented 11 months ago

Special thanks to Marco Balestra on this one.

First of all, XPath became a big pain when using <xsl:template> with <xsl:apply-templates> because:

To resolve the issues with <xsl:apply-templates> and relative paths, I created this special axis, self-and-siblings. It seems to solve the problems very well so far, but nothing prevents me to remove it if I find a better approach using pure XPath.

At versions 1.1.x, I was using the input to map the output nodes. It was very convenient, but it doesn't work well in occasions that one match needs to revisit a node that already generated the output. For this reason, I decided to expand the Expression Context to accommodate the input and the output, with input nodes holding a reference to its direct output node.

Some tests are skipped because they are incorrect, considering tests in other XSLT libraries. They should be revisited in the future.

Finally, the <xslt:sort> needs to be called explicitly, and it is not executed by default during <xslt:apply-templates> as before. To solve the output positioning, I created a property called siblingPosition, which it is copied to output nodes, preserving the order while writing the output XML.

github-actions[bot] commented 11 months ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements
69.75% (-1.1% πŸ”»)
1393/1997
🟑 Branches
61.46% (-2.14% πŸ”»)
622/1012
🟑 Functions
68.62% (-1.55% πŸ”»)
199/290
🟑 Lines
70.06% (-0.97% πŸ”»)
1308/1867
Show files with reduced coverage πŸ”»
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------- | | 🟒 | dom/util.ts |
92.86% (-7.14% πŸ”»)
|
40% (-50% πŸ”»)
| 100% |
95.45% (-4.55% πŸ”»)
| | πŸ”΄ | dom/xnode.ts |
36.4% (-1.92% πŸ”»)
|
29.37% (+5.68% πŸ”Ό)
|
48.48% (+0.1% πŸ”Ό)
|
37.44% (-2.17% πŸ”»)
| | 🟒 | dom/functions.ts |
83.9% (-0.72% πŸ”»)
|
78.31% (-2.41% πŸ”»)
| 78.57% |
84.07% (+0.14% πŸ”Ό)
| | 🟑 |
`...` / xml-functions.ts
|
79.43% (-6.18% πŸ”»)
|
67.44% (-8.53% πŸ”»)
|
85.71% (-14.29% πŸ”»)
|
78.29% (-6.08% πŸ”»)
| | πŸ”΄ |
`...` / standard.ts
|
48.35% (-2.75% πŸ”»)
|
33.9% (-10.17% πŸ”»)
|
43.75% (-3.13% πŸ”»)
|
48% (-2.86% πŸ”»)
| | 🟒 |
`...` / step-expr.ts
|
89.06% (+0.26% πŸ”Ό)
|
77.33% (-2.9% πŸ”»)
| 100% |
87.72% (+0.33% πŸ”Ό)
| | 🟒 | xpath/xpath.ts |
88.86% (-0.24% πŸ”»)
|
84.43% (+0.89% πŸ”Ό)
|
91.67% (-1.67% πŸ”»)
|
88.41% (-0.26% πŸ”»)
| | 🟑 | xslt/xslt.ts |
68.98% (+0.31% πŸ”Ό)
|
60.71% (-0.58% πŸ”»)
|
77.78% (-2.99% πŸ”»)
|
69.62% (+0.72% πŸ”Ό)
|

Test suite run success

51 tests passing in 14 suites.

Report generated by πŸ§ͺjest coverage report action from 12fd8e8aa46ebbc92e42201531efb792039f484c