-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample code for "XQuery Update Facility Can Simplify XSpec Test Helpe…
…r Functions" (#53)
- Loading branch information
Showing
5 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Sample code for "XQuery Update Facility Can Simplify XSpec Test Helper Functions" | ||
|
||
Example files for XQuery, including dependencies from ../helper-comments folder: | ||
|
||
- `helper-remove-comments-xquf.xqm` | ||
- `helper-remove-comments-xquf.xspec` | ||
- `../helper-comments/test-target.xqm` | ||
- `../helper-comments/helper-remove-comments-xslt.xspec` | ||
|
||
|
||
#### Links to Topic | ||
[XQuery Update Facility Can Simplify XSpec Test Helper Functions](https://medium.com/@xspectacles/xquery-update-facility-can-simplify-xspec-test-helper-functions-803a7b362002) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
xquery version "3.1"; | ||
module namespace frc = "urn:x-xspectacles:functions:helper:remove-comments:xquf"; | ||
|
||
(: | ||
Sample Code for "XQuery Update Facility Can Simplify XSpec Test Helper Functions" | ||
https://medium.com/@xspectacles/xquery-update-facility-can-simplify-xspec-test-helper-functions-803a7b362002 | ||
:) | ||
|
||
(: | ||
This helper file requires the XQuery processor to support the | ||
copy modify expression in XQuery Update Facility 1.0. Processors | ||
with such support include: | ||
* BaseX | ||
* Saxon-EE with XQuery Update explicitly enabled (-update:on) | ||
:) | ||
declare variable $frc:prefix as xs:string := 'TEST NOTE:'; | ||
|
||
(: | ||
Remove certain comments from $node, assumed to be an element or | ||
document node. The comments to remove are those whose | ||
space-normalized content starts with 'TEST NOTE:'. | ||
:) | ||
declare function frc:remove-comments( | ||
$node as node() | ||
) { | ||
copy $node-copy := $node | ||
modify delete node $node-copy//comment() | ||
[starts-with(normalize-space(.), $frc:prefix)] | ||
return | ||
$node-copy | ||
}; | ||
|
||
(: Copyright © 2024 by Amanda Galtman. :) |
20 changes: 20 additions & 0 deletions
20
src/helper-comments-xquf/helper-remove-comments-xquf.xspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description query="urn:x-xspectacles:functions:report" | ||
query-at="../helper-comments/test-target.xqm" | ||
xmlns:frc="urn:x-xspectacles:functions:helper:remove-comments:xquf" | ||
xmlns:rpt="urn:x-xspectacles:functions:report" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec"> | ||
|
||
<!-- | ||
Sample Code for "XQuery Update Facility Can Simplify XSpec Test Helper Functions" | ||
https://medium.com/@xspectacles/xquery-update-facility-can-simplify-xspec-test-helper-functions-803a7b362002 | ||
--> | ||
|
||
<x:helper | ||
query="urn:x-xspectacles:functions:helper:remove-comments:xquf" | ||
query-at="helper-remove-comments-xquf.xqm"/> | ||
|
||
<x:import href="../helper-comments/helper-remove-comments-xslt.xspec"/> | ||
|
||
</x:description> | ||
<!-- Copyright © 2024 by Amanda Galtman. --> |