leptris 1.9.201.0-arm-linux → 1.9.201.2-arm-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Rakefile +52 -12
- data/ext/leptris/native/extconf.rb +85 -0
- data/ext/leptris/native/native.c +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/ffi.rb +13 -0
- data/lib/leptris/xml/native.so +0 -0
- data/vendor-src/libleptris/CHANGELOG.md +8080 -0
- data/vendor-src/libleptris/CLAUDE.md +150 -0
- data/vendor-src/libleptris/CMakeLists.txt +379 -0
- data/vendor-src/libleptris/CMakePresets.json +61 -0
- data/vendor-src/libleptris/CODE_OF_CONDUCT.md +132 -0
- data/vendor-src/libleptris/CONTEXT.md +49 -0
- data/vendor-src/libleptris/LICENSE.md +33 -0
- data/vendor-src/libleptris/README.adoc +1197 -0
- data/vendor-src/libleptris/TODO.assemble/README.md +16 -0
- data/vendor-src/libleptris/TODO.bindings/01-mutation-construction.md +18 -0
- data/vendor-src/libleptris/TODO.bindings/02-incremental-iterparse.md +15 -0
- data/vendor-src/libleptris/TODO.bindings/03-compiled-xpath.md +15 -0
- data/vendor-src/libleptris/TODO.bindings/04-pull-stax-api.md +14 -0
- data/vendor-src/libleptris/TODO.bindings/05-per-parse-options.md +17 -0
- data/vendor-src/libleptris/TODO.bindings/06-serialize-encoding-guarantees.md +14 -0
- data/vendor-src/libleptris/TODO.bindings/README.md +36 -0
- data/vendor-src/libleptris/TODO.concurrency/01-thread-safe-errors.md +19 -0
- data/vendor-src/libleptris/TODO.concurrency/02-export-surface-gate.md +24 -0
- data/vendor-src/libleptris/TODO.concurrency/03-mixed-nodeset-batch.md +14 -0
- data/vendor-src/libleptris/TODO.concurrency/04-canonical-status-message.md +13 -0
- data/vendor-src/libleptris/TODO.concurrency/05-windows-dll-name.md +10 -0
- data/vendor-src/libleptris/TODO.concurrency/06-exslt-pack.md +26 -0
- data/vendor-src/libleptris/TODO.concurrency/07-ns-set-pairs.md +11 -0
- data/vendor-src/libleptris/TODO.concurrency/08-threading-contract.md +45 -0
- data/vendor-src/libleptris/TODO.engine/01-file-sources.md +11 -0
- data/vendor-src/libleptris/TODO.engine/02-compiled-contexts.md +10 -0
- data/vendor-src/libleptris/TODO.engine/03-rust-publish.md +9 -0
- data/vendor-src/libleptris/TODO.engine/04-ruby-release-input.md +8 -0
- data/vendor-src/libleptris/TODO.engine/05-todo-md-refresh.md +7 -0
- data/vendor-src/libleptris/TODO.engine/README.md +16 -0
- data/vendor-src/libleptris/TODO.hygiene/README.md +15 -0
- data/vendor-src/libleptris/TODO.max-perf/00-INDEX.md +22 -0
- data/vendor-src/libleptris/TODO.max-perf/1-simd-html-scanner.md +15 -0
- data/vendor-src/libleptris/TODO.max-perf/10-moxml-plan-followups.md +9 -0
- data/vendor-src/libleptris/TODO.max-perf/2-compiled-dispatch-tokenizer.md +8 -0
- data/vendor-src/libleptris/TODO.max-perf/3-iterparse-fixed-cost.md +5 -0
- data/vendor-src/libleptris/TODO.max-perf/4-compact-node-micro-opts.md +17 -0
- data/vendor-src/libleptris/TODO.max-perf/5-xslt-bench-profiling-rounds.md +13 -0
- data/vendor-src/libleptris/TODO.max-perf/6-language-tails.md +9 -0
- data/vendor-src/libleptris/TODO.max-perf/7-validate-bindings.md +6 -0
- data/vendor-src/libleptris/TODO.max-perf/8-native-xml-diff-consumer.md +5 -0
- data/vendor-src/libleptris/TODO.max-perf/9-prebuilt-gem-matrix.md +14 -0
- data/vendor-src/libleptris/TODO.md +33 -0
- data/vendor-src/libleptris/TODO.transform/README.md +39 -0
- data/vendor-src/libleptris/TODO.validate/README.md +32 -0
- data/vendor-src/libleptris/TODO.xpath2/README.md +91 -0
- data/vendor-src/libleptris/TODO.xslt-full/01-xpath-fn-sequences.md +27 -0
- data/vendor-src/libleptris/TODO.xslt-full/02-xpath-fn-regex.md +13 -0
- data/vendor-src/libleptris/TODO.xslt-full/03-xpath-fn-math.md +10 -0
- data/vendor-src/libleptris/TODO.xslt-full/04-xpath-fn-strings-qname-uri.md +97 -0
- data/vendor-src/libleptris/TODO.xslt-full/05-xpath-fn-dates.md +30 -0
- data/vendor-src/libleptris/TODO.xslt-full/06-xpath-grammar-3x.md +83 -0
- data/vendor-src/libleptris/TODO.xslt-full/07-xpath-function-items.md +124 -0
- data/vendor-src/libleptris/TODO.xslt-full/08-xpath-maps-arrays.md +79 -0
- data/vendor-src/libleptris/TODO.xslt-full/09-xslt-noop-fillins.md +35 -0
- data/vendor-src/libleptris/TODO.xslt-full/10-xslt-tunnel-params.md +9 -0
- data/vendor-src/libleptris/TODO.xslt-full/11-xquery-core.md +119 -0
- data/vendor-src/libleptris/TODO.xslt-full/12-xquery-31.md +65 -0
- data/vendor-src/libleptris/TODO.xslt-full/13-perf-inprocess.md +425 -0
- data/vendor-src/libleptris/TODO.xslt-full/14-html-mode.md +803 -0
- data/vendor-src/libleptris/TODO.xslt-full/15-binding-entries.md +19 -0
- data/vendor-src/libleptris/TODO.xslt-full/16-schematron.md +156 -0
- data/vendor-src/libleptris/TODO.xslt-full/17-xml-diff.md +52 -0
- data/vendor-src/libleptris/TODO.xslt-full/18-compact-nodes.md +278 -0
- data/vendor-src/libleptris/TODO.xslt-full/README.md +26 -0
- data/vendor-src/libleptris/TODO.xslt-full/REMAINING.md +163 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/00-triage.md +171 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/01-fragment-nodes.md +19 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/02-root-node-semantics.md +34 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/03-crashes.md +15 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/04-namespaces.md +14 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/05-number-attrset-sort.md +13 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/06-document-chains.md +10 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/07-charef-serializer.md +9 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/08-perf-gate.md +8 -0
- data/vendor-src/libleptris/TODO.xslt-full/legacy-v19/09-release.md +14 -0
- data/vendor-src/libleptris/VALIDATION.md +151 -0
- data/vendor-src/libleptris/benchmarks/CMakeLists.txt +259 -0
- data/vendor-src/libleptris/benchmarks/README.adoc +228 -0
- data/vendor-src/libleptris/benchmarks/README.md +212 -0
- data/vendor-src/libleptris/benchmarks/common/benchmark.c +252 -0
- data/vendor-src/libleptris/benchmarks/common/benchmark.h +77 -0
- data/vendor-src/libleptris/benchmarks/common/test_data.c +415 -0
- data/vendor-src/libleptris/benchmarks/common/test_data.h +18 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/CMakeLists.txt +184 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_decomp.cpp +110 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_first_access.cpp +261 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_many_attrs.cpp +150 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_memory.cpp +185 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_parse.cpp +270 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_parse_ops.cpp +392 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_sax.c +106 -0
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_write.cpp +351 -0
- data/vendor-src/libleptris/benchmarks/data/attrs.xml +303 -0
- data/vendor-src/libleptris/benchmarks/data/cdata_test.xml +13 -0
- data/vendor-src/libleptris/benchmarks/data/comment_test.xml +15 -0
- data/vendor-src/libleptris/benchmarks/data/deep.xml +205 -0
- data/vendor-src/libleptris/benchmarks/data/generate_attrs.rb +22 -0
- data/vendor-src/libleptris/benchmarks/data/generate_deep.rb +25 -0
- data/vendor-src/libleptris/benchmarks/data/generate_large.rb +33 -0
- data/vendor-src/libleptris/benchmarks/data/generate_wide.rb +18 -0
- data/vendor-src/libleptris/benchmarks/data/large.xml +21003 -0
- data/vendor-src/libleptris/benchmarks/data/large_workflow.xml +4003 -0
- data/vendor-src/libleptris/benchmarks/data/medium.xml +67 -0
- data/vendor-src/libleptris/benchmarks/data/medium_workflow.xml +353 -0
- data/vendor-src/libleptris/benchmarks/data/pi_test.xml +9 -0
- data/vendor-src/libleptris/benchmarks/data/small.xml +10 -0
- data/vendor-src/libleptris/benchmarks/data/small_workflow.xml +36 -0
- data/vendor-src/libleptris/benchmarks/data/wide.xml +5003 -0
- data/vendor-src/libleptris/benchmarks/dom/bench_document_lifecycle.c +69 -0
- data/vendor-src/libleptris/benchmarks/dom/bench_leptris.c +184 -0
- data/vendor-src/libleptris/benchmarks/dom/bench_libxml2.c +176 -0
- data/vendor-src/libleptris/benchmarks/dom/bench_text_borrowed.c +74 -0
- data/vendor-src/libleptris/benchmarks/dom/dom_benchmark_v2.cpp +314 -0
- data/vendor-src/libleptris/benchmarks/fixtures/large.xml +4003 -0
- data/vendor-src/libleptris/benchmarks/fixtures/large_catalog.xml +50003 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2/eve.xml +6 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2/slashdot.rdf +66 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2/wap.xml +27 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/4rects.xml +11 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/a-valid.xml +10 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/a-wf.xml +9 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/bike.xml +41 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/circle.xml +11 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/defs.xml +14 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/desc.xml +14 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/ellipse.xml +10 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/flower2.xml +44 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/gradient.xml +16 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/group01.xml +15 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/group02.xml +13 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/group03.xml +13 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/image-valid.xml +11 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/image-wf.xml +11 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/lin-gradient.xml +16 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/marker.xml +28 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/mask.xml +13 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/mathswitch.xml +32 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/parentns.xml +12 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/path01.xml +5 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/path02.xml +10 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/patternfill.xml +12 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/polyline.xml +9 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/private.xml +19 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/rad-gradient.xml +17 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/rectangle.xml +10 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/richdesc.xml +12 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/script.xml +13 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/structure01.xml +10 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/style.xml +11 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/switch.xml +21 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/symbol-use.xml +28 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/template.xml +9 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/text01.xml +12 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/text02.xml +17 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/text03.xml +8 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/toap01.xml +10 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/toap02.xml +33 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/transform.xml +26 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/trivial.xml +6 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/twin-gradients.xml +19 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/v-template.xml +9 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/viewport-nest.xml +13 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/viewport-transform.xml +46 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/viewport.xml +11 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_svg/wf-template.xml +7 -0
- data/vendor-src/libleptris/benchmarks/fixtures/libxml2_xsdtest.xml +5286 -0
- data/vendor-src/libleptris/benchmarks/fixtures/medium.xml +403 -0
- data/vendor-src/libleptris/benchmarks/fixtures/medium_catalog.xml +3003 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/empty.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/large.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/latintest_latin1.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/latintest_utf8.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/multiline.xml +3 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/small.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/truncation.xml +19 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf16_be.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf16_be_bom.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf16_be_clean.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf16_be_nodecl.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf16_le.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf16_le_bom.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf16_le_clean.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf16_le_nodecl.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf32_be.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf32_be_bom.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf32_be_clean.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf32_be_nodecl.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf32_le.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf32_le_bom.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf32_le_clean.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf32_le_nodecl.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf8.xml +87 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf8_bom.xml +87 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf8_clean.xml +84 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml/utftest_utf8_nodecl.xml +86 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml//321/202/320/265/321/201/321/202.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/empty.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/large.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/latintest_latin1.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/latintest_utf8.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/multiline.xml +3 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/small.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/truncation.xml +19 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf16_be.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf16_be_bom.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf16_be_clean.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf16_be_nodecl.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf16_le.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf16_le_bom.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf16_le_clean.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf16_le_nodecl.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf32_be.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf32_be_bom.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf32_be_clean.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf32_be_nodecl.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf32_le.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf32_le_bom.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf32_le_clean.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf32_le_nodecl.xml +0 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf8.xml +87 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf8_bom.xml +87 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf8_clean.xml +84 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests/utftest_utf8_nodecl.xml +86 -0
- data/vendor-src/libleptris/benchmarks/fixtures/pugixml_tests//321/202/320/265/321/201/321/202.xml +1 -0
- data/vendor-src/libleptris/benchmarks/fixtures/small.xml +38 -0
- data/vendor-src/libleptris/benchmarks/html/bench_html_parse.c +111 -0
- data/vendor-src/libleptris/benchmarks/html/gen_nokogiri_reference.rb +112 -0
- data/vendor-src/libleptris/benchmarks/html/nokogiri_html_parse.rb +64 -0
- data/vendor-src/libleptris/benchmarks/matrix/README.md +71 -0
- data/vendor-src/libleptris/benchmarks/matrix/bench2html.rb +316 -0
- data/vendor-src/libleptris/benchmarks/matrix/bench_matrix.cpp +724 -0
- data/vendor-src/libleptris/benchmarks/modification/bench_leptris_modify.c +211 -0
- data/vendor-src/libleptris/benchmarks/modification/bench_node_creation.c +130 -0
- data/vendor-src/libleptris/benchmarks/results/BENCHMARK_REPORT.md +226 -0
- data/vendor-src/libleptris/benchmarks/results/baseline_report.md +219 -0
- data/vendor-src/libleptris/benchmarks/results/benchmark_20251223_134550.json +13 -0
- data/vendor-src/libleptris/benchmarks/results/benchmark_20260129_225844.json +13 -0
- data/vendor-src/libleptris/benchmarks/results/leptris_dom_output.txt +24 -0
- data/vendor-src/libleptris/benchmarks/results/leptris_modify.json +36 -0
- data/vendor-src/libleptris/benchmarks/results/leptris_modify_optimized.json +36 -0
- data/vendor-src/libleptris/benchmarks/results/leptris_modify_session1.json +36 -0
- data/vendor-src/libleptris/benchmarks/results/leptris_modify_session2.json +36 -0
- data/vendor-src/libleptris/benchmarks/results/leptris_serialize.json +34 -0
- data/vendor-src/libleptris/benchmarks/results/leptris_xpath_output.txt +24 -0
- data/vendor-src/libleptris/benchmarks/results/libxml2_dom_output.txt +24 -0
- data/vendor-src/libleptris/benchmarks/results/libxml2_xpath_output.txt +24 -0
- data/vendor-src/libleptris/benchmarks/results/phase16_session2.json +21 -0
- data/vendor-src/libleptris/benchmarks/results/phase17.5_session1.json +30 -0
- data/vendor-src/libleptris/benchmarks/results/phase17_session1.json +30 -0
- data/vendor-src/libleptris/benchmarks/results/pugixml_dom_output.txt +51 -0
- data/vendor-src/libleptris/benchmarks/results/xpath_axes_leptris.json +318 -0
- data/vendor-src/libleptris/benchmarks/results/xpath_axes_libxml2.json +318 -0
- data/vendor-src/libleptris/benchmarks/results/xpath_functions_leptris.json +222 -0
- data/vendor-src/libleptris/benchmarks/results/xpath_functions_libxml2.json +222 -0
- data/vendor-src/libleptris/benchmarks/sax/bench_iterparse.c +115 -0
- data/vendor-src/libleptris/benchmarks/sax/bench_leptris.c +124 -0
- data/vendor-src/libleptris/benchmarks/sax/bench_libxml2.c +115 -0
- data/vendor-src/libleptris/benchmarks/serialization/bench_leptris_serialize.c +198 -0
- data/vendor-src/libleptris/benchmarks/src/benchmark_base.h +175 -0
- data/vendor-src/libleptris/benchmarks/twins/mutation_leptris.c +37 -0
- data/vendor-src/libleptris/benchmarks/twins/mutation_pugixml.cpp +28 -0
- data/vendor-src/libleptris/benchmarks/twins/parse_leptris.c +35 -0
- data/vendor-src/libleptris/benchmarks/twins/parse_pugixml.cpp +35 -0
- data/vendor-src/libleptris/benchmarks/utils.c +171 -0
- data/vendor-src/libleptris/benchmarks/utils.h +70 -0
- data/vendor-src/libleptris/benchmarks/workflows/bench_dom_modify.c +325 -0
- data/vendor-src/libleptris/benchmarks/workflows/bench_end_to_end.c +529 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_axes.c +411 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_axes_libxml2.c +108 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_diagnostic.c +431 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_functions.c +271 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_functions_libxml2.c +123 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_leptris.c +78 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_libxml2.c +98 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_pugixml.cpp +117 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_scalar_eval.c +86 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_scalar_eval_libxml2.c +70 -0
- data/vendor-src/libleptris/benchmarks/xpath/bench_xslt_transform.c +48 -0
- data/vendor-src/libleptris/benchmarks/xslt/bench_dispatch.c +52 -0
- data/vendor-src/libleptris/benchmarks/xslt/bench_dispatch_heavy.c +82 -0
- data/vendor-src/libleptris/benchmarks/xslt/bench_dispatch_pred.c +34 -0
- data/vendor-src/libleptris/benchmarks/xslt/bench_subtree_copy.c +55 -0
- data/vendor-src/libleptris/benchmarks/xslt/bench_valueof.c +46 -0
- data/vendor-src/libleptris/benchmarks/xslt/heavy_lxml.py +48 -0
- data/vendor-src/libleptris/benchmarks/xslt/scorecard_lxml.py +169 -0
- data/vendor-src/libleptris/bindings/ruby/leptris.gemspec +22 -0
- data/vendor-src/libleptris/bindings/ruby/lib/leptris/document.rb +60 -0
- data/vendor-src/libleptris/bindings/ruby/lib/leptris/element.rb +86 -0
- data/vendor-src/libleptris/bindings/ruby/lib/leptris/error.rb +6 -0
- data/vendor-src/libleptris/bindings/ruby/lib/leptris/node.rb +73 -0
- data/vendor-src/libleptris/bindings/ruby/lib/leptris/sax.rb +189 -0
- data/vendor-src/libleptris/bindings/ruby/lib/leptris/xpath.rb +44 -0
- data/vendor-src/libleptris/bindings/ruby/lib/leptris.rb +137 -0
- data/vendor-src/libleptris/bindings/ruby/spec/leptris_spec.rb +113 -0
- data/vendor-src/libleptris/bindings/ruby/spec/sax_spec.rb +141 -0
- data/vendor-src/libleptris/bindings/ruby/spec/spec_helper.rb +7 -0
- data/vendor-src/libleptris/bindings/ruby/test_full.rb +21 -0
- data/vendor-src/libleptris/bindings/rust/Cargo.lock +7 -0
- data/vendor-src/libleptris/bindings/rust/Cargo.toml +13 -0
- data/vendor-src/libleptris/bindings/rust/README.md +61 -0
- data/vendor-src/libleptris/bindings/rust/build.rs +74 -0
- data/vendor-src/libleptris/bindings/rust/src/ffi.rs +204 -0
- data/vendor-src/libleptris/bindings/rust/src/lib.rs +580 -0
- data/vendor-src/libleptris/bindings/rust/tests/integration.rs +156 -0
- data/vendor-src/libleptris/cli/ARCHITECTURE_REVIEW.md +514 -0
- data/vendor-src/libleptris/cli/CLI_ARCHITECTURE.md +851 -0
- data/vendor-src/libleptris/cli/CMakeLists.txt +46 -0
- data/vendor-src/libleptris/cli/cli.c +115 -0
- data/vendor-src/libleptris/cli/cli.h +232 -0
- data/vendor-src/libleptris/cli/commands/diff.c +208 -0
- data/vendor-src/libleptris/cli/commands/format.c +379 -0
- data/vendor-src/libleptris/cli/commands/parse.c +343 -0
- data/vendor-src/libleptris/cli/commands/validate.c +284 -0
- data/vendor-src/libleptris/cli/commands/version.c +49 -0
- data/vendor-src/libleptris/cli/commands/xpath.c +428 -0
- data/vendor-src/libleptris/cli/commands/xquery.c +188 -0
- data/vendor-src/libleptris/cli/completion/leptris.bash +86 -0
- data/vendor-src/libleptris/cli/completion/leptris.zsh +74 -0
- data/vendor-src/libleptris/cli/error.c +394 -0
- data/vendor-src/libleptris/cli/error.h +360 -0
- data/vendor-src/libleptris/cli/leptris +0 -0
- data/vendor-src/libleptris/cli/main.c +127 -0
- data/vendor-src/libleptris/cli/man/leptris-format.1.adoc +226 -0
- data/vendor-src/libleptris/cli/man/leptris-parse.1.adoc +213 -0
- data/vendor-src/libleptris/cli/man/leptris-xpath.1.adoc +479 -0
- data/vendor-src/libleptris/cli/man/leptris.1.adoc +192 -0
- data/vendor-src/libleptris/cli/options.c +451 -0
- data/vendor-src/libleptris/cli/options.h +378 -0
- data/vendor-src/libleptris/cli/output.c +841 -0
- data/vendor-src/libleptris/cli/output.h +361 -0
- data/vendor-src/libleptris/cmake/FindUtf8proc.cmake +56 -0
- data/vendor-src/libleptris/cmake/leptris-config.cmake.in +14 -0
- data/vendor-src/libleptris/cmake/leptris.pc.in +11 -0
- data/vendor-src/libleptris/cmake/modules/AdocMan.cmake +132 -0
- data/vendor-src/libleptris/docs/ARCHITECTURE_REVIEW.md +280 -0
- data/vendor-src/libleptris/docs/Doxyfile +47 -0
- data/vendor-src/libleptris/docs/FFI.md +165 -0
- data/vendor-src/libleptris/docs/README.md +47 -0
- data/vendor-src/libleptris/docs/ROADMAP-SAXON-PARITY.md +194 -0
- data/vendor-src/libleptris/docs/guide/building.md +199 -0
- data/vendor-src/libleptris/docs/guide/getting-started.md +134 -0
- data/vendor-src/libleptris/docs/guide/parsing.md +315 -0
- data/vendor-src/libleptris/docs/guide/xpath-queries.md +444 -0
- data/vendor-src/libleptris/examples/c/CMakeLists.txt +58 -0
- data/vendor-src/libleptris/examples/c/README.md +345 -0
- data/vendor-src/libleptris/examples/c/basic_example.c +80 -0
- data/vendor-src/libleptris/examples/c/dom_traversal_example.c +58 -0
- data/vendor-src/libleptris/examples/c/error_handling_example.c +121 -0
- data/vendor-src/libleptris/examples/c/namespace_example.c +49 -0
- data/vendor-src/libleptris/examples/c/xpath_example.c +74 -0
- data/vendor-src/libleptris/ports/leptris/portfile.cmake +41 -0
- data/vendor-src/libleptris/ports/leptris/usage +28 -0
- data/vendor-src/libleptris/scripts/check_dll_exports.py +54 -0
- data/vendor-src/libleptris/scripts/check_export_surface.py +84 -0
- data/vendor-src/libleptris/scripts/check_ffi_mirrors.py +163 -0
- data/vendor-src/libleptris/scripts/check_formatting.sh +30 -0
- data/vendor-src/libleptris/scripts/check_shared_exports.sh +120 -0
- data/vendor-src/libleptris/scripts/check_trailing_whitespace.sh +18 -0
- data/vendor-src/libleptris/scripts/gen-api-docs.sh +31 -0
- data/vendor-src/libleptris/scripts/run_static_analysis.sh +16 -0
- data/vendor-src/libleptris/scripts/validate.sh +199 -0
- data/vendor-src/libleptris/scripts/xslt_triage.sh +72 -0
- data/vendor-src/libleptris/src/CMakeLists.txt +597 -0
- data/vendor-src/libleptris/src/include/leptris/descriptor.h +178 -0
- data/vendor-src/libleptris/src/include/leptris/dom/document.h +213 -0
- data/vendor-src/libleptris/src/include/leptris/dom/element.h +435 -0
- data/vendor-src/libleptris/src/include/leptris/dom/serialize.h +133 -0
- data/vendor-src/libleptris/src/include/leptris/dtd.h +178 -0
- data/vendor-src/libleptris/src/include/leptris/error.h +97 -0
- data/vendor-src/libleptris/src/include/leptris/sax/sax.h +584 -0
- data/vendor-src/libleptris/src/include/leptris/types.h +386 -0
- data/vendor-src/libleptris/src/include/leptris/xpath/xpath.h +250 -0
- data/vendor-src/libleptris/src/include/leptris/xquery/xquery.h +80 -0
- data/vendor-src/libleptris/src/include/leptris.h +3701 -0
- data/vendor-src/libleptris/src/leptris/chartype.h +124 -0
- data/vendor-src/libleptris/src/leptris/common/chartype.c +90 -0
- data/vendor-src/libleptris/src/leptris/common/chartype.h +44 -0
- data/vendor-src/libleptris/src/leptris/common/cpu.c +40 -0
- data/vendor-src/libleptris/src/leptris/common/cpu.h +63 -0
- data/vendor-src/libleptris/src/leptris/common/entities.c +329 -0
- data/vendor-src/libleptris/src/leptris/common/entities.h +79 -0
- data/vendor-src/libleptris/src/leptris/common/format_number.c +273 -0
- data/vendor-src/libleptris/src/leptris/common/format_number.h +29 -0
- data/vendor-src/libleptris/src/leptris/common/port.h +171 -0
- data/vendor-src/libleptris/src/leptris/common/simd_text.c +237 -0
- data/vendor-src/libleptris/src/leptris/common/simd_text.h +104 -0
- data/vendor-src/libleptris/src/leptris/common/simd_text_avx2.c +105 -0
- data/vendor-src/libleptris/src/leptris/common/simd_text_neon.c +280 -0
- data/vendor-src/libleptris/src/leptris/common/string_view.c +204 -0
- data/vendor-src/libleptris/src/leptris/common/string_view.h +68 -0
- data/vendor-src/libleptris/src/leptris/common/types_internal.h +31 -0
- data/vendor-src/libleptris/src/leptris/core.c +201 -0
- data/vendor-src/libleptris/src/leptris/descriptor/plan.c +527 -0
- data/vendor-src/libleptris/src/leptris/diff/diff.c +491 -0
- data/vendor-src/libleptris/src/leptris/dom/cdata.c +47 -0
- data/vendor-src/libleptris/src/leptris/dom/cdata.h +73 -0
- data/vendor-src/libleptris/src/leptris/dom/comment.c +48 -0
- data/vendor-src/libleptris/src/leptris/dom/comment.h +74 -0
- data/vendor-src/libleptris/src/leptris/dom/compact.c +397 -0
- data/vendor-src/libleptris/src/leptris/dom/compact.h +307 -0
- data/vendor-src/libleptris/src/leptris/dom/diag.c +58 -0
- data/vendor-src/libleptris/src/leptris/dom/diag.h +75 -0
- data/vendor-src/libleptris/src/leptris/dom/digest.c +255 -0
- data/vendor-src/libleptris/src/leptris/dom/doctype.c +137 -0
- data/vendor-src/libleptris/src/leptris/dom/doctype.h +52 -0
- data/vendor-src/libleptris/src/leptris/dom/document_node.c +13 -0
- data/vendor-src/libleptris/src/leptris/dom/document_node.h +21 -0
- data/vendor-src/libleptris/src/leptris/dom/edges.h +60 -0
- data/vendor-src/libleptris/src/leptris/dom/element.c +1114 -0
- data/vendor-src/libleptris/src/leptris/dom/element.h +1109 -0
- data/vendor-src/libleptris/src/leptris/dom/element_index.c +444 -0
- data/vendor-src/libleptris/src/leptris/dom/element_index.h +135 -0
- data/vendor-src/libleptris/src/leptris/dom/element_modify.c +2185 -0
- data/vendor-src/libleptris/src/leptris/dom/element_query.c +1468 -0
- data/vendor-src/libleptris/src/leptris/dom/entity_ref.c +57 -0
- data/vendor-src/libleptris/src/leptris/dom/entity_ref.h +70 -0
- data/vendor-src/libleptris/src/leptris/dom/node.c +420 -0
- data/vendor-src/libleptris/src/leptris/dom/node.h +170 -0
- data/vendor-src/libleptris/src/leptris/dom/node_public.c +937 -0
- data/vendor-src/libleptris/src/leptris/dom/node_vtable.c +138 -0
- data/vendor-src/libleptris/src/leptris/dom/pi.c +70 -0
- data/vendor-src/libleptris/src/leptris/dom/pi.h +80 -0
- data/vendor-src/libleptris/src/leptris/dom/root_doc_map.c +310 -0
- data/vendor-src/libleptris/src/leptris/dom/root_doc_map.h +30 -0
- data/vendor-src/libleptris/src/leptris/dom/text.c +157 -0
- data/vendor-src/libleptris/src/leptris/dom/text.h +119 -0
- data/vendor-src/libleptris/src/leptris/dtd/content_check.c +300 -0
- data/vendor-src/libleptris/src/leptris/dtd/model.c +533 -0
- data/vendor-src/libleptris/src/leptris/dtd/model.h +354 -0
- data/vendor-src/libleptris/src/leptris/dtd/parser.c +827 -0
- data/vendor-src/libleptris/src/leptris/dtd/resolver.c +354 -0
- data/vendor-src/libleptris/src/leptris/dtd/validator.c +668 -0
- data/vendor-src/libleptris/src/leptris/encoding/encoders.c +346 -0
- data/vendor-src/libleptris/src/leptris/encoding/encoders.h +61 -0
- data/vendor-src/libleptris/src/leptris/encoding/encoding.c +451 -0
- data/vendor-src/libleptris/src/leptris/encoding/encoding.h +118 -0
- data/vendor-src/libleptris/src/leptris/encoding/unicode.c +317 -0
- data/vendor-src/libleptris/src/leptris/encoding/unicode.h +64 -0
- data/vendor-src/libleptris/src/leptris/encoding/utf16.c +204 -0
- data/vendor-src/libleptris/src/leptris/encoding/utf16.h +78 -0
- data/vendor-src/libleptris/src/leptris/encoding/wrapper.c +243 -0
- data/vendor-src/libleptris/src/leptris/error.c +134 -0
- data/vendor-src/libleptris/src/leptris/flat/direct_parse.c +1935 -0
- data/vendor-src/libleptris/src/leptris/flat/direct_parse.h +41 -0
- data/vendor-src/libleptris/src/leptris/html/html_parse.c +8040 -0
- data/vendor-src/libleptris/src/leptris/leptris.c +1264 -0
- data/vendor-src/libleptris/src/leptris/leptris_internal.h +910 -0
- data/vendor-src/libleptris/src/leptris/leptris_memory.c +179 -0
- data/vendor-src/libleptris/src/leptris/leptris_memory.h +180 -0
- data/vendor-src/libleptris/src/leptris/leptris_parse.h +195 -0
- data/vendor-src/libleptris/src/leptris/memory/arena.c +243 -0
- data/vendor-src/libleptris/src/leptris/memory/arena.h +93 -0
- data/vendor-src/libleptris/src/leptris/memory/pool.c +1055 -0
- data/vendor-src/libleptris/src/leptris/memory/pool.h +426 -0
- data/vendor-src/libleptris/src/leptris/rng/parse.c +814 -0
- data/vendor-src/libleptris/src/leptris/rng/rng_internal.h +112 -0
- data/vendor-src/libleptris/src/leptris/rng/rng_public.c +159 -0
- data/vendor-src/libleptris/src/leptris/rng/rng_regex.c +453 -0
- data/vendor-src/libleptris/src/leptris/rng/validate.c +1923 -0
- data/vendor-src/libleptris/src/leptris/sax/iterparse.c +435 -0
- data/vendor-src/libleptris/src/leptris/sax/parser.c +105 -0
- data/vendor-src/libleptris/src/leptris/sax/pull.c +489 -0
- data/vendor-src/libleptris/src/leptris/sax/recorder.c +252 -0
- data/vendor-src/libleptris/src/leptris/sax/sax_internal.h +163 -0
- data/vendor-src/libleptris/src/leptris/sax/streaming.c +1469 -0
- data/vendor-src/libleptris/src/leptris/sch/schematron.c +1588 -0
- data/vendor-src/libleptris/src/leptris/serialize/c14n.c +1143 -0
- data/vendor-src/libleptris/src/leptris/serialize/serialize.c +2333 -0
- data/vendor-src/libleptris/src/leptris/serialize/serialize.h +188 -0
- data/vendor-src/libleptris/src/leptris/simd_helpers.h +447 -0
- data/vendor-src/libleptris/src/leptris/unicode/unicode.c +237 -0
- data/vendor-src/libleptris/src/leptris/unicode/unicode.h +113 -0
- data/vendor-src/libleptris/src/leptris/xinclude/xinclude.c +794 -0
- data/vendor-src/libleptris/src/leptris/xpath/bytecode.h +229 -0
- data/vendor-src/libleptris/src/leptris/xpath/compiler.c +1478 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator.c +1099 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator.h +189 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_axes.c +787 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_internal.h +112 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_operators.c +2138 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_path.c +1312 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_types.c +294 -0
- data/vendor-src/libleptris/src/leptris/xpath/functions.c +2544 -0
- data/vendor-src/libleptris/src/leptris/xpath/functions.h +161 -0
- data/vendor-src/libleptris/src/leptris/xpath/functions_exslt.c +545 -0
- data/vendor-src/libleptris/src/leptris/xpath/functions_ext31.c +4316 -0
- data/vendor-src/libleptris/src/leptris/xpath/lexer.c +636 -0
- data/vendor-src/libleptris/src/leptris/xpath/lexer.h +25 -0
- data/vendor-src/libleptris/src/leptris/xpath/parser.c +2992 -0
- data/vendor-src/libleptris/src/leptris/xpath/parser.h +28 -0
- data/vendor-src/libleptris/src/leptris/xpath/vm.c +2903 -0
- data/vendor-src/libleptris/src/leptris/xpath/xpath_ast_cache.c +319 -0
- data/vendor-src/libleptris/src/leptris/xpath/xpath_compiled.c +263 -0
- data/vendor-src/libleptris/src/leptris/xpath/xpath_internal.h +134 -0
- data/vendor-src/libleptris/src/leptris/xpath/xpath_public.c +1139 -0
- data/vendor-src/libleptris/src/leptris/xpath/xpath_variables.c +410 -0
- data/vendor-src/libleptris/src/leptris/xpath/xpath_variables.h +230 -0
- data/vendor-src/libleptris/src/leptris/xquery/xquery.c +2641 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_exec.c +4887 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_functions.c +1612 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_internal.h +862 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_parse.c +2418 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_pattern.c +441 -0
- data/vendor-src/libleptris/src/leptris/xslt/xslt_public.c +710 -0
- data/vendor-src/libleptris/src/leptris.symvers +16 -0
- data/vendor-src/libleptris/src/man/libleptris.5.adoc +961 -0
- data/vendor-src/libleptris/test/CMakeLists.txt +234 -0
- data/vendor-src/libleptris/test/README.md +59 -0
- data/vendor-src/libleptris/test/abi/test_descriptor.cpp +441 -0
- data/vendor-src/libleptris/test/abi/test_doctype_api.cpp +51 -0
- data/vendor-src/libleptris/test/abi/test_dom_deep_copy.cpp +110 -0
- data/vendor-src/libleptris/test/abi/test_dom_mutation_bugs.cpp +210 -0
- data/vendor-src/libleptris/test/abi/test_header_hygiene.cpp +269 -0
- data/vendor-src/libleptris/test/abi/test_namespace_mutation_and_create.cpp +198 -0
- data/vendor-src/libleptris/test/abi/test_node_get_xpath.cpp +128 -0
- data/vendor-src/libleptris/test/abi/test_nokogiri_api.cpp +392 -0
- data/vendor-src/libleptris/test/abi/test_parse_fragment.cpp +114 -0
- data/vendor-src/libleptris/test/abi/test_previous_sibling_and_c14n_ex.cpp +299 -0
- data/vendor-src/libleptris/test/abi/test_public_surface.cpp +463 -0
- data/vendor-src/libleptris/test/abi/test_serialize_abi.cpp +67 -0
- data/vendor-src/libleptris/test/abi/test_v0_5_14_bugs.cpp +299 -0
- data/vendor-src/libleptris/test/abi/test_xpath_custom_fns.cpp +106 -0
- data/vendor-src/libleptris/test/cli/test_cli.cpp +493 -0
- data/vendor-src/libleptris/test/common/test_simd_spans.cpp +88 -0
- data/vendor-src/libleptris/test/common/test_simd_text.cpp +142 -0
- data/vendor-src/libleptris/test/concurrency/test_concurrency.cpp +218 -0
- data/vendor-src/libleptris/test/diff/test_diff.cpp +244 -0
- data/vendor-src/libleptris/test/dom/test_compact.cpp +339 -0
- data/vendor-src/libleptris/test/dom/test_digest.cpp +111 -0
- data/vendor-src/libleptris/test/dom/test_document_children.cpp +270 -0
- data/vendor-src/libleptris/test/dom/test_dom.cpp +2310 -0
- data/vendor-src/libleptris/test/dom/test_map_lifecycle.cpp +111 -0
- data/vendor-src/libleptris/test/dom/test_node_surface_parity.cpp +268 -0
- data/vendor-src/libleptris/test/dom/test_text_borrowed.cpp +126 -0
- data/vendor-src/libleptris/test/dom/test_vtable.cpp +108 -0
- data/vendor-src/libleptris/test/dtd/test_dtd_validate.cpp +1227 -0
- data/vendor-src/libleptris/test/dtd/test_w3c_conformance.cpp +212 -0
- data/vendor-src/libleptris/test/fixtures/basic.xml +13 -0
- data/vendor-src/libleptris/test/fixtures/cdata.xml +5 -0
- data/vendor-src/libleptris/test/fixtures/malformed.xml +2 -0
- data/vendor-src/libleptris/test/fixtures/namespaces.xml +11 -0
- data/vendor-src/libleptris/test/fixtures/utf16_decl.xml +5 -0
- data/vendor-src/libleptris/test/fuzz/fuzz_parse.c +40 -0
- data/vendor-src/libleptris/test/html/html5lib-redlist.txt +1366 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/LICENSE +21 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/README.md +11 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/adoption01.dat +354 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/adoption02.dat +39 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/blocks.dat +695 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/comments01.dat +217 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/doctype01.dat +474 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/domjs-unsafe.dat +0 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/entities01.dat +943 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/entities02.dat +309 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/foreign-fragment.dat +645 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/html5test-com.dat +301 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/inbody01.dat +54 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/isindex.dat +49 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/main-element.dat +46 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/math.dat +104 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/menuitem-element.dat +240 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/namespace-sensitivity.dat +22 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/noscript01.dat +237 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/pending-spec-changes-plain-text-unsafe.dat +0 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/pending-spec-changes.dat +46 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/plain-text-unsafe.dat +0 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/ruby.dat +302 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/scriptdata01.dat +372 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/search-element.dat +46 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/svg.dat +104 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tables01.dat +308 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/template.dat +1673 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests1.dat +1956 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests10.dat +849 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests11.dat +523 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests12.dat +62 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests14.dat +75 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests15.dat +216 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests16.dat +2602 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests17.dat +179 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests18.dat +558 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests19.dat +1398 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests2.dat +821 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests20.dat +842 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests21.dat +306 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests22.dat +190 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests23.dat +168 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests24.dat +79 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests25.dat +288 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests26.dat +453 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests3.dat +305 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests4.dat +58 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests5.dat +210 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests6.dat +663 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests7.dat +417 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests8.dat +165 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests9.dat +472 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tests_innerHTML_1.dat +843 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/tricky01.dat +336 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/webkit01.dat +785 -0
- data/vendor-src/libleptris/test/html/html5lib-tests/tree-construction/webkit02.dat +554 -0
- data/vendor-src/libleptris/test/html/html5lib_cases.h.in +6 -0
- data/vendor-src/libleptris/test/html/nokogiri-parity-redlist.txt +1183 -0
- data/vendor-src/libleptris/test/html/nokogiri-tree-tests.dat +18107 -0
- data/vendor-src/libleptris/test/html/test_html.cpp +2191 -0
- data/vendor-src/libleptris/test/html/test_html5lib.cpp +831 -0
- data/vendor-src/libleptris/test/memory/test_arena.cpp +252 -0
- data/vendor-src/libleptris/test/memory/test_oom_injection.cpp +170 -0
- data/vendor-src/libleptris/test/memory/test_pool.cpp +331 -0
- data/vendor-src/libleptris/test/memory/test_pool_arena.cpp +180 -0
- data/vendor-src/libleptris/test/parser/test_encoding.cpp +282 -0
- data/vendor-src/libleptris/test/parser/test_large_documents.cpp +346 -0
- data/vendor-src/libleptris/test/parser/test_parser.cpp +565 -0
- data/vendor-src/libleptris/test/parser/test_simd_count.cpp +70 -0
- data/vendor-src/libleptris/test/perf/test_perf.cpp +362 -0
- data/vendor-src/libleptris/test/perf/test_stress_high_doc_count.cpp +67 -0
- data/vendor-src/libleptris/test/rng/include-cases/bad-construct.rng +7 -0
- data/vendor-src/libleptris/test/rng/include-cases/bad-override.rng +6 -0
- data/vendor-src/libleptris/test/rng/include-cases/bad-start-override.rng +5 -0
- data/vendor-src/libleptris/test/rng/include-cases/ext-lib.rng +3 -0
- data/vendor-src/libleptris/test/rng/include-cases/ext-main.rng +7 -0
- data/vendor-src/libleptris/test/rng/include-cases/lib.rng +5 -0
- data/vendor-src/libleptris/test/rng/include-cases/lib2.rng +6 -0
- data/vendor-src/libleptris/test/rng/include-cases/main.rng +4 -0
- data/vendor-src/libleptris/test/rng/include-cases/no-href.rng +4 -0
- data/vendor-src/libleptris/test/rng/include-cases/override.rng +8 -0
- data/vendor-src/libleptris/test/rng/include-cases/self-include.rng +4 -0
- data/vendor-src/libleptris/test/rng/include-cases/start-override.rng +5 -0
- data/vendor-src/libleptris/test/rng/jing-cases/000.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/000.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/000.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/001.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/001.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/001.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/002.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/002.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/002.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/003.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/003.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/003.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/004.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/004.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/004.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/005.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/005.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/005.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/006.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/006.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/006.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/007.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/007.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/007.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/008.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/008.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/008.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/009.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/009.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/009.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/010.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/010.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/010.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/011.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/011.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/011.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/012.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/012.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/012.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/013.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/013.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/013.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/014.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/014.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/014.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/015.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/015.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/015.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/016.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/016.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/016.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/017.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/017.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/017.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/018.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/018.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/018.rng +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/019.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/019.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/019.rng +7 -0
- data/vendor-src/libleptris/test/rng/jing-cases/020-book.rng +4 -0
- data/vendor-src/libleptris/test/rng/jing-cases/020.bad.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/020.ok.xml +1 -0
- data/vendor-src/libleptris/test/rng/jing-cases/020.rng +3 -0
- data/vendor-src/libleptris/test/rng/jing-cases/README.md +32 -0
- data/vendor-src/libleptris/test/rng/jing-cases/jing-ref.json +212 -0
- data/vendor-src/libleptris/test/rng/jing-cases/meta.json +1 -0
- data/vendor-src/libleptris/test/rng/test_rng.cpp +1365 -0
- data/vendor-src/libleptris/test/rng/test_rng_corpus.cpp +133 -0
- data/vendor-src/libleptris/test/rng/test_rng_corpus_msg.cpp +233 -0
- data/vendor-src/libleptris/test/sax/test_iterparse.cpp +203 -0
- data/vendor-src/libleptris/test/sax/test_pull.cpp +214 -0
- data/vendor-src/libleptris/test/sax/test_pull_batch.cpp +201 -0
- data/vendor-src/libleptris/test/sax/test_recorder.cpp +265 -0
- data/vendor-src/libleptris/test/sax/test_sax.cpp +665 -0
- data/vendor-src/libleptris/test/sax/test_streaming.cpp +434 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/README.md +15 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/extends-baseuri-fixup-01.xml +28 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/extends-recursive-01.xml +27 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/include-baseuri-fixup-01.xml +24 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/include-recursive-01.xml +24 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-name-collision-error-01.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-name-collision-error-02.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-name-collision-error-03.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-name-collision-error-04.xml +23 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-name-collision-error-05.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-name-collision-error-06.xml +25 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-pattern-global-01.xml +24 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-reference-undefined-01.xml +18 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-reference-undefined-02.xml +18 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-reference-undefined-03.xml +18 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-reference-undefined-04.xml +19 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-reference-undefined-05.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-reference-undefined-06.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-reference-undefined-07.xml +18 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-rule-global-01.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-rule-global-02.xml +23 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-scope-pattern-01.xml +25 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-scope-phase-01.xml +23 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-scope-rule-01.xml +23 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/let-value-element-content-01.xml +33 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/pattern-abstract-01.xml +22 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/pattern-subordinate-document-01.xml +21 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/pattern-subordinate-document-02.xml +21 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-abstract-01.xml +21 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-abstract-02.xml +23 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-attribute-01.xml +18 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-comment-01.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-element-01.xml +18 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-pi-01.xml +20 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-root-01.xml +18 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-text-01.xml +18 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-variable-01.xml +22 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-variable-02.xml +25 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-context-variable-03.xml +22 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/rule-order-01.xml +21 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/schema-default-phase-01.xml +26 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/schema-default-phase-02.xml +25 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/svrl-diagnostic-01.xml +28 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/svrl-diagnostic-02.xml +25 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/svrl-name-nopath-01.xml +23 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/svrl-name-path-01.xml +23 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/svrl-property-01.xml +28 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/svrl-property-copy-of.xml +26 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/svrl-value-of-01.xml +23 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/xslt-key-01.xml +19 -0
- data/vendor-src/libleptris/test/sch/conformance-cases/xslt-key-element-content-01.xml +21 -0
- data/vendor-src/libleptris/test/sch/test_schematron.cpp +337 -0
- data/vendor-src/libleptris/test/sch/test_schematron_corpus.cpp +421 -0
- data/vendor-src/libleptris/test/serializer/test_c14n.cpp +539 -0
- data/vendor-src/libleptris/test/serializer/test_serialize.cpp +890 -0
- data/vendor-src/libleptris/test/smoke/test_smoke.cpp +41 -0
- data/vendor-src/libleptris/test/xinclude/test_xinclude.cpp +903 -0
- data/vendor-src/libleptris/test/xpath/test_bytecode_vm.cpp +755 -0
- data/vendor-src/libleptris/test/xpath/test_compiled.cpp +171 -0
- data/vendor-src/libleptris/test/xpath/test_exslt.cpp +141 -0
- data/vendor-src/libleptris/test/xpath/test_xpath.cpp +2433 -0
- data/vendor-src/libleptris/test/xpath/test_xpath_conformance.cpp +570 -0
- data/vendor-src/libleptris/test/xpath/test_xslt.cpp +4245 -0
- data/vendor-src/libleptris/test/xquery/books.xml +1 -0
- data/vendor-src/libleptris/test/xquery/qt3/README.md +28 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/concat.xml +878 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/contains.xml +795 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/ends-with.xml +556 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/starts-with.xml +644 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/substring/concepts.xml +1 -0
- data/vendor-src/libleptris/test/xquery/qt3/fn/substring.xml +449 -0
- data/vendor-src/libleptris/test/xquery/test_qt3.cpp +324 -0
- data/vendor-src/libleptris/test/xquery/test_xquery.cpp +768 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/ATTRIBUTION.md +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/array.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/array.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/array.xsl +26 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-1-.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-1-.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-1-.xsl +21 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-10-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-10-.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-10-.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-100.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-100.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-100.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-101.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-101.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-101.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-102-inc.xsl +21 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-102.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-102.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-102.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-103.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-103.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-103.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-104.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-104.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-104.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-105.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-105.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-105.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-106.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-106.xml +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-106.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-107.out +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-107.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-107.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-108.out +25 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-108.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-108.xsl +21 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-109.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-109.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-109.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-11-.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-11-.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-11-.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-110.ent +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-110.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-110.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-110.xsl +20 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-111.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-111.xml +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-111.xsl +45 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-112.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-112.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-112.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-113.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-113.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-113.xsl +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-114.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-114.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-114.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-115.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-115.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-115.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-116.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-116.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-116.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-117.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-117.xml +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-117.xsl +59 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-118.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-118.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-118.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-119.out +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-119.xml +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-119.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-12-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-12-.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-12-.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-120.out +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-120.xml +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-120.xsl +27 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-121.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-121.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-121.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-122.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-122.xml +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-122.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-123.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-123.xml +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-123.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-124.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-124.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-124.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-125.out +351 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-125.xml +118 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-125.xsl +99 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-126.out +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-126.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-126.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-127.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-127.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-127.xsl +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-128.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-128.xml +26 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-128.xsl +26 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-129.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-129.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-129.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-13-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-13-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-13-.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-130-imp1.imp +25 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-130-imp2.imp +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-130-imp3.imp +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-130-imp4.imp +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-130.doc +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-130.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-130.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-130.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-131-imp.imp +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-131.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-131.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-131.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-132.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-132.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-132.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-133.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-133.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-133.xsl +32 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-134.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-134.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-134.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-135.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-135.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-135.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-136.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-136.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-136.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-137.imp +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-137.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-137.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-137.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-138.out +23 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-138.xml +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-138.xsl +28 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-139.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-139.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-139.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-14-.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-14-.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-14-.xsl +23 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-140.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-140.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-140.xsl +32 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-141.out +46 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-141.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-141.xsl +25 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-142.out +35 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-142.xml +65 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-142.xsl +85 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-143.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-143.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-143.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-144.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-144.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-144.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-145.err +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-145.xml +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-145.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147-1.imp +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147-2.imp +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147-3.imp +57 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147-4.imp +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147-5.imp +27 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147-6.imp +31 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147.out +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147.xml +21 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-147.xsl +29 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-148.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-148.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-148.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-149.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-149.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-149.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-15-.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-15-.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-15-.xsl +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-150.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-150.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-150.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-151.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-151.xsl +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-152.out +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-152.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-152.xsl +30 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-153.doc +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-153.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-153.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-153.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-154.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-154.xsl +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-155.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-155.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-155.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-156.err +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-156.imp1.imp +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-156.imp2.imp +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-156.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-156.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-157.err +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-157.out +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-157.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-157.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-158.doc +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-158.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-158.xml +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-158.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-159.out +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-159.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-159.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-16-.out +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-16-.xml +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-16-.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-160.out +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-160.xml +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-160.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-161.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-161.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-161.xsl +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-163.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-163.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-163.xsl +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-164.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-164.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-164.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-165.err +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-165.xml +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-165.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-166.out +15256 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-166.xml +15255 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-166.xsl +131 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-167.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-167.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-167.xsl +20 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-168.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-168.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-168.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-169.imp +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-169.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-169.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-169.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-17-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-17-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-17-.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-170.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-170.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-170.xsl +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-171.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-171.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-171.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-172.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-172.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-172.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-173.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-173.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-173.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-174.err +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-174.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-174.xsl +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-175.err +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-175.out +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-175.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-175.xsl +33 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-176.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-176.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-176.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-177.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-177.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-177.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-178.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-178.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-178.xsl +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-179.out +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-179.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-179.xsl +24 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-18-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-18-.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-18-.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-180.err +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-180.xml +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-180.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-181.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-181.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-181.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-182.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-182.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-182.xsl +21 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-183.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-183.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-183.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-184.err +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-184.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-184.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-186.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-186.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-186.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-187.err +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-187.out +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-187.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-187.xsl +42 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-188-imp.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-188.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-188.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-188.xsl +20 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-189.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-189.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-189.xsl +25 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-19-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-19-.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-19-.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-190-imp.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-190.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-190.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-190.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-191-imp.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-191.err +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-191.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-191.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-192.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-192.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-192.xsl +33 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-193.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-193.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-193.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-194.err +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-194.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-194.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-195.out +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-195.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-195.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-196.out +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-196.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-196.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-197.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-197.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-197.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-198.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-198.xml +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-198.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-199.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-199.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-199.xsl +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-2-.out +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-2-.xml +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-2-.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-20-.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-20-.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-20-.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-200.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-200.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-200.xsl +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-201.err +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-201.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-201.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-202.err +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-202.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-202.xsl +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-203.err +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-203.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-203.xsl +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-204.err +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-204.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-204.xsl +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-205.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-205.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-205.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-206.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-206.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-206.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-207.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-207.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-207.xsl +61 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-208.err +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-208.xml +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-208.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-209.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-209.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-209.xsl +21 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-21-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-21-.xml +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-21-.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-210.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-210.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-210.xsl +20 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-211.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-211.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-211.xsl +26 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-212.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-212.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-212.xsl +25 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-213.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-213.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-213.xsl +26 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-214.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-214.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-214.xsl +25 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-215.err +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-215.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-215.xsl +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-216.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-216.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-216.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-217.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-217.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-217.xsl +24 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-218.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-218.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-218.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-219.out +68 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-219.xml +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-219.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-22-.out +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-22-.xml +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-22-.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-220.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-220.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-220.xsl +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-221.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-221.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-221.xsl +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-222.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-222.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-222.xsl +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-223-imp.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-223-inc.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-223.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-223.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-223.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-224.out +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-224.xml +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-224.xsl +28 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-225.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-225.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-225.xsl +32 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-23-.out +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-23-.xml +21 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-23-.xsl +20 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-24-.out +27 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-24-.xml +2419 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-24-.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-25-.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-25-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-25-.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-26-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-26-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-26-.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-27-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-27-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-27-.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-28-.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-28-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-28-.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-29-.ent +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-29-.out +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-29-.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-29-.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-3-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-3-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-3-.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-30-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-30-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-30-.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-31-.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-31-.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-31-.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-32-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-32-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-32-.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-33-.out +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-33-.xml +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-33-.xsl +29 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-35-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-35-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-35-.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-36-.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-36-.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-36-.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-36-inc.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-37-.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-37-.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-37-.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-37-inc.xsl +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-38-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-38-.xml +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-38-.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-39-.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-39-.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-39-.xsl +34 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-4-.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-4-.xml +38 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-4-.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-40-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-40-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-40-.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-41-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-41-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-41-.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-42-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-42-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-42-.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-43-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-43-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-43-.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-44-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-44-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-44-.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-45-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-45-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-45-.xsl +27 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-46-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-46-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-46-.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-47-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-47-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-47-.xsl +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-48-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-48-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-48-.xsl +24 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-49-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-49-.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-49-.xsl +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-5-.out +954 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-5-.xml +475 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-5-.xsl +158 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-50-.out +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-50-.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-50-.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-52.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-52.xml +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-52.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-53.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-53.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-53.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-54.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-54.xml +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-54.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-55.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-55.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-55.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-56.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-56.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-56.xsl +28 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-57.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-57.xml +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-57.xsl +21 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-58.xsl +274 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-59.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-59.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-59.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-6-.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-6-.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-6-.xsl +32 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-60.err +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-60.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-60.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-60.xsl +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-61.out +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-61.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-61.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-62-inc.xsl +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-62.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-62.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-62.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-63.out +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-63.xml +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-63.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-64.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-64.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-64.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-65.ent +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-65.out +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-65.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-65.xsl +26 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-66.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-66.xml +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-66.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-68.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-68.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-68.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-69.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-69.xml +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-69.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-7-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-7-.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-7-.xsl +11 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-70.out +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-70.xml +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-70.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-71.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-71.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-71.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-72.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-72.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-72.xsl +31 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-73.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-73.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-73.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-74.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-74.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-74.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-75.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-75.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-75.xsl +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-76.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-76.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-76.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-77.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-77.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-77.xsl +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-78.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-78.xml +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-78.xsl +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-79.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-79.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-79.xsl +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-8-.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-8-.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-8-.xsl +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-80.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-80.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-80.xsl +29 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-81.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-81.xml +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-81.xsl +18 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-82.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-82.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-82.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-83.out +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-83.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-83.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-84.out +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-84.xml +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-84.xsl +14 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-86.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-86.xml +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-86.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-87.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-87.xml +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-87.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-88.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-88.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-88.xsl +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-89.out +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-89.xml +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-89.xsl +105 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-9-.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-9-.xml +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-9-.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-90.out +13 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-90.xml +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-90.xsl +35 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-91.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-91.xml +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-91.xsl +8 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-92.out +15 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-92.xml +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-92.xsl +19 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-93-inc.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-93.out +3 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-93.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-93.xsl +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-94.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-94.xml +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-94.xsl +35 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-95.out +4 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-95.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-95.xsl +22 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-96.out +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-96.xml +5 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-96.xsl +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-97.out +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-97.xml +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-97.xsl +32 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-98.out +6 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-98.xml +10 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-98.xsl +31 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-99.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-99.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/bug-99.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/character.out +2 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/character.xml +23 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/character.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/date_add.out +9 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/date_add.xml +1 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/date_add.xsl +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/doc.dtd +7 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/doc.out +16 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/doc.xml +17 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/doc.xsl +62 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/inner.xsl +12 -0
- data/vendor-src/libleptris/test/xslt/libxslt_suite_general/items.xml +34 -0
- data/vendor-src/libleptris/test/xslt/open_cases.txt +0 -0
- data/vendor-src/libleptris/test/xslt/test_libxslt_suite.cpp +398 -0
- data/vendor-src/libleptris/vcpkg.json +29 -0
- data/vendor-src/utf8proc/CMakeLists.txt +133 -0
- data/vendor-src/utf8proc/Doxyfile +2765 -0
- data/vendor-src/utf8proc/LICENSE.md +93 -0
- data/vendor-src/utf8proc/MANIFEST +9 -0
- data/vendor-src/utf8proc/Makefile +203 -0
- data/vendor-src/utf8proc/NEWS.md +479 -0
- data/vendor-src/utf8proc/README.md +143 -0
- data/vendor-src/utf8proc/appveyor.yml +46 -0
- data/vendor-src/utf8proc/bench/Makefile +40 -0
- data/vendor-src/utf8proc/bench/bench.c +56 -0
- data/vendor-src/utf8proc/bench/icu.c +61 -0
- data/vendor-src/utf8proc/bench/unistring.c +60 -0
- data/vendor-src/utf8proc/bench/util.c +39 -0
- data/vendor-src/utf8proc/bench/util.h +22 -0
- data/vendor-src/utf8proc/cmake/utf8proc-config.cmake.in +5 -0
- data/vendor-src/utf8proc/data/Makefile +62 -0
- data/vendor-src/utf8proc/data/Manifest.toml +16 -0
- data/vendor-src/utf8proc/data/Project.toml +2 -0
- data/vendor-src/utf8proc/data/data_generator.jl +498 -0
- data/vendor-src/utf8proc/libutf8proc.pc.cmakein +10 -0
- data/vendor-src/utf8proc/libutf8proc.pc.in +10 -0
- data/vendor-src/utf8proc/lump.md +27 -0
- data/vendor-src/utf8proc/test/app/CMakeLists.txt +6 -0
- data/vendor-src/utf8proc/test/app/app.c +9 -0
- data/vendor-src/utf8proc/test/case.c +76 -0
- data/vendor-src/utf8proc/test/charwidth.c +91 -0
- data/vendor-src/utf8proc/test/custom.c +28 -0
- data/vendor-src/utf8proc/test/fuzz_main.c +54 -0
- data/vendor-src/utf8proc/test/fuzzer.c +97 -0
- data/vendor-src/utf8proc/test/graphemetest.c +136 -0
- data/vendor-src/utf8proc/test/iscase.c +63 -0
- data/vendor-src/utf8proc/test/iterate.c +168 -0
- data/vendor-src/utf8proc/test/maxdecomposition.c +22 -0
- data/vendor-src/utf8proc/test/misc.c +51 -0
- data/vendor-src/utf8proc/test/normtest.c +64 -0
- data/vendor-src/utf8proc/test/ossfuzz.sh +13 -0
- data/vendor-src/utf8proc/test/printproperty.c +68 -0
- data/vendor-src/utf8proc/test/tests.c +60 -0
- data/vendor-src/utf8proc/test/tests.h +27 -0
- data/vendor-src/utf8proc/test/valid.c +41 -0
- data/vendor-src/utf8proc/utf8proc.c +834 -0
- data/vendor-src/utf8proc/utf8proc.h +794 -0
- data/vendor-src/utf8proc/utf8proc_data.c +17141 -0
- data/vendor-src/utf8proc/utils.cmake +20 -0
- metadata +1528 -2
|
@@ -0,0 +1,4316 @@
|
|
|
1
|
+
/* functions_ext31.c — XPath 2.0/3.1 function-library extension
|
|
2
|
+
* families (TODO.xslt-full 01/02/03).
|
|
3
|
+
*
|
|
4
|
+
* MECE with functions.c: the 1.0 core library lives there; the
|
|
5
|
+
* sequence, regex and math families land here and register through
|
|
6
|
+
* xpath_register_fn31 from the standard init (OCP — new families
|
|
7
|
+
* extend the registry without touching 1.0 handlers). Sequence
|
|
8
|
+
* results reuse the synthetic-text nodeset channel the 3.0
|
|
9
|
+
* expression forms established (is_sequence = 1).
|
|
10
|
+
*
|
|
11
|
+
* Ground truth: Saxon-HE 12.7 probes (test Xslt30.FnSequences /
|
|
12
|
+
* FnMath / FnRegex).
|
|
13
|
+
*/
|
|
14
|
+
#include "functions.h"
|
|
15
|
+
#include "evaluator.h"
|
|
16
|
+
#include "evaluator_internal.h"
|
|
17
|
+
#include "../include/leptris.h"
|
|
18
|
+
#include "../dom/element.h"
|
|
19
|
+
#include "../common/format_number.h"
|
|
20
|
+
#include "../unicode/unicode.h"
|
|
21
|
+
#include <time.h>
|
|
22
|
+
#include <limits.h>
|
|
23
|
+
#include <string.h>
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
#include <errno.h>
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
#include <math.h>
|
|
28
|
+
#include <ctype.h>
|
|
29
|
+
|
|
30
|
+
#ifndef _WIN32
|
|
31
|
+
#include <regex.h>
|
|
32
|
+
#define LEPTRIS_HAVE_POSIX_RE 1
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
extern struct leptris_xpath_result* xpath_evaluate(XPathContext* context,
|
|
36
|
+
XPathASTNode* ast);
|
|
37
|
+
extern char* get_node_text(void* node);
|
|
38
|
+
|
|
39
|
+
/* ---- sequence plumbing ---- */
|
|
40
|
+
|
|
41
|
+
static struct leptris_xpath_result* seq_new(void) {
|
|
42
|
+
struct leptris_xpath_result* r = xpath_result_new(XPATH_RESULT_NODESET);
|
|
43
|
+
if (!r) return NULL;
|
|
44
|
+
r->value.nodeset_value = xpath_nodeset_new();
|
|
45
|
+
if (!r->value.nodeset_value) {
|
|
46
|
+
xpath_result_free(r);
|
|
47
|
+
return NULL;
|
|
48
|
+
}
|
|
49
|
+
r->value.nodeset_value->is_sequence = 1;
|
|
50
|
+
r->value.nodeset_value->owns_synthetic_text = 1;
|
|
51
|
+
return r;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static void seq_push_str(struct leptris_xpath_result* seq, const char* s) {
|
|
55
|
+
XPathTextNode* tn =
|
|
56
|
+
xpath_synth_text(s ? s : "", s ? strlen(s) : 0);
|
|
57
|
+
if (tn) xpath_nodeset_add(seq->value.nodeset_value, tn);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static void seq_push_num(struct leptris_xpath_result* seq, double d) {
|
|
61
|
+
char* s = xpath_number_to_string(d);
|
|
62
|
+
seq_push_str(seq, s ? s : "");
|
|
63
|
+
free(s);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Scalar-to-string without the public free contract (owned). */
|
|
67
|
+
static char* scalar_str(const struct leptris_xpath_result* r) {
|
|
68
|
+
if (!r) return leptris_strdup("");
|
|
69
|
+
switch (r->type) {
|
|
70
|
+
case XPATH_RESULT_STRING:
|
|
71
|
+
return leptris_strdup(r->value.string_value
|
|
72
|
+
? r->value.string_value : "");
|
|
73
|
+
case XPATH_RESULT_NUMBER: {
|
|
74
|
+
char* s = xpath_number_to_string(r->value.number_value);
|
|
75
|
+
return s ? s : leptris_strdup("");
|
|
76
|
+
}
|
|
77
|
+
case XPATH_RESULT_BOOLEAN:
|
|
78
|
+
return leptris_strdup(r->value.boolean_value ? "true" : "false");
|
|
79
|
+
default:
|
|
80
|
+
return NULL;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Evaluate args[i] into a malloc'd array of malloc'd item strings.
|
|
85
|
+
* Nodesets contribute one item per node; scalars one item. */
|
|
86
|
+
static char** collect_items(XPathContext* ctx, XPathASTNode** args,
|
|
87
|
+
size_t n, size_t i, size_t* out_n) {
|
|
88
|
+
*out_n = 0;
|
|
89
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[i]);
|
|
90
|
+
if (!r) return NULL;
|
|
91
|
+
char** items = NULL;
|
|
92
|
+
size_t cnt = 0;
|
|
93
|
+
if (r->type == XPATH_RESULT_NODESET && r->value.nodeset_value) {
|
|
94
|
+
XPathNodeSet* ns = r->value.nodeset_value;
|
|
95
|
+
items = (char**)malloc((ns->count ? ns->count : 1) * sizeof(char*));
|
|
96
|
+
if (!items) { xpath_result_free(r); return NULL; }
|
|
97
|
+
for (size_t k = 0; k < ns->count; k++) {
|
|
98
|
+
char* t = get_node_text(ns->nodes[k]);
|
|
99
|
+
items[cnt++] = t ? t : leptris_strdup("");
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
items = (char**)malloc(sizeof(char*));
|
|
103
|
+
if (!items) { xpath_result_free(r); return NULL; }
|
|
104
|
+
items[cnt++] = scalar_str(r);
|
|
105
|
+
}
|
|
106
|
+
xpath_result_free(r);
|
|
107
|
+
*out_n = cnt;
|
|
108
|
+
(void)n;
|
|
109
|
+
return items;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static void free_items(char** items, size_t n) {
|
|
113
|
+
if (!items) return;
|
|
114
|
+
for (size_t i = 0; i < n; i++) free(items[i]);
|
|
115
|
+
free(items);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* Positional helpers (1-based; start may be <= 0, len NaN = to end). */
|
|
119
|
+
static void seq_from_items(struct leptris_xpath_result* seq, char** items,
|
|
120
|
+
size_t n, long start, long len) {
|
|
121
|
+
if (start < 1) start = 1;
|
|
122
|
+
for (long k = start - 1; k < (long)n; k++) {
|
|
123
|
+
if (len >= 0 && k >= start - 1 + len) break;
|
|
124
|
+
seq_push_str(seq, items[k]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* ---- sequence functions ---- */
|
|
129
|
+
|
|
130
|
+
static struct leptris_xpath_result* fn_exists(XPathContext* ctx,
|
|
131
|
+
XPathASTNode** args, size_t n) {
|
|
132
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
133
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
134
|
+
if (!out) { xpath_result_free(r); return NULL; }
|
|
135
|
+
out->value.boolean_value =
|
|
136
|
+
r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value &&
|
|
137
|
+
r->value.nodeset_value->count > 0;
|
|
138
|
+
if (r && r->type != XPATH_RESULT_NODESET && n)
|
|
139
|
+
out->value.boolean_value = 1; /* a scalar is one item */
|
|
140
|
+
xpath_result_free(r);
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static struct leptris_xpath_result* fn_empty(XPathContext* ctx,
|
|
145
|
+
XPathASTNode** args, size_t n) {
|
|
146
|
+
struct leptris_xpath_result* r = fn_exists(ctx, args, n);
|
|
147
|
+
if (!r) return NULL;
|
|
148
|
+
r->value.boolean_value = !r->value.boolean_value;
|
|
149
|
+
return r;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static struct leptris_xpath_result* fn_head(XPathContext* ctx,
|
|
153
|
+
XPathASTNode** args, size_t n) {
|
|
154
|
+
size_t cnt;
|
|
155
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
156
|
+
if (!items) return NULL;
|
|
157
|
+
struct leptris_xpath_result* out = seq_new();
|
|
158
|
+
if (out && cnt) seq_push_str(out, items[0]);
|
|
159
|
+
free_items(items, cnt);
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static struct leptris_xpath_result* fn_tail(XPathContext* ctx,
|
|
164
|
+
XPathASTNode** args, size_t n) {
|
|
165
|
+
size_t cnt;
|
|
166
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
167
|
+
if (!items) return NULL;
|
|
168
|
+
struct leptris_xpath_result* out = seq_new();
|
|
169
|
+
if (out) seq_from_items(out, items, cnt, 2, -1);
|
|
170
|
+
free_items(items, cnt);
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static struct leptris_xpath_result* fn_reverse(XPathContext* ctx,
|
|
175
|
+
XPathASTNode** args, size_t n) {
|
|
176
|
+
size_t cnt;
|
|
177
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
178
|
+
if (!items) return NULL;
|
|
179
|
+
struct leptris_xpath_result* out = seq_new();
|
|
180
|
+
if (out)
|
|
181
|
+
for (size_t k = cnt; k > 0; k--) seq_push_str(out, items[k - 1]);
|
|
182
|
+
free_items(items, cnt);
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* fn:collection() — no default collection is defined in this
|
|
187
|
+
* build: a dynamic error (Saxon FODC0002 parity), catchable. */
|
|
188
|
+
static struct leptris_xpath_result* fn_collection(XPathContext* ctx,
|
|
189
|
+
XPathASTNode** args, size_t n) {
|
|
190
|
+
(void)args;
|
|
191
|
+
(void)n;
|
|
192
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
193
|
+
"No default collection has been defined");
|
|
194
|
+
snprintf(ctx->error_code, sizeof(ctx->error_code), "FODC0002");
|
|
195
|
+
return NULL;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static struct leptris_xpath_result* fn_unordered(XPathContext* ctx,
|
|
199
|
+
XPathASTNode** args, size_t n) {
|
|
200
|
+
size_t cnt;
|
|
201
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
202
|
+
if (!items) return NULL;
|
|
203
|
+
struct leptris_xpath_result* out = seq_new();
|
|
204
|
+
if (out) seq_from_items(out, items, cnt, 1, -1);
|
|
205
|
+
free_items(items, cnt);
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static struct leptris_xpath_result* fn_subsequence(XPathContext* ctx,
|
|
210
|
+
XPathASTNode** args, size_t n) {
|
|
211
|
+
size_t cnt;
|
|
212
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
213
|
+
if (!items) return NULL;
|
|
214
|
+
struct leptris_xpath_result* sv = xpath_evaluate(ctx, args[1]);
|
|
215
|
+
double sd = sv ? leptris_xpath_result_number(sv) : 0;
|
|
216
|
+
double ld = 0;
|
|
217
|
+
if (n >= 3) {
|
|
218
|
+
struct leptris_xpath_result* lv = xpath_evaluate(ctx, args[2]);
|
|
219
|
+
ld = lv ? leptris_xpath_result_number(lv) : 0;
|
|
220
|
+
if (lv) leptris_xpath_result_free(lv);
|
|
221
|
+
}
|
|
222
|
+
if (sv) leptris_xpath_result_free(sv);
|
|
223
|
+
struct leptris_xpath_result* out = seq_new();
|
|
224
|
+
if (out) {
|
|
225
|
+
long start = (long)sd;
|
|
226
|
+
long len = (n >= 3) ? (ld != ld ? -1 : (long)ld) : -1;
|
|
227
|
+
seq_from_items(out, items, cnt, start, len);
|
|
228
|
+
}
|
|
229
|
+
free_items(items, cnt);
|
|
230
|
+
return out;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
static struct leptris_xpath_result* fn_remove(XPathContext* ctx,
|
|
234
|
+
XPathASTNode** args, size_t n) {
|
|
235
|
+
size_t cnt;
|
|
236
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
237
|
+
if (!items) return NULL;
|
|
238
|
+
struct leptris_xpath_result* iv = xpath_evaluate(ctx, args[1]);
|
|
239
|
+
long drop = iv ? (long)leptris_xpath_result_number(iv) : 0;
|
|
240
|
+
if (iv) leptris_xpath_result_free(iv);
|
|
241
|
+
struct leptris_xpath_result* out = seq_new();
|
|
242
|
+
if (out)
|
|
243
|
+
for (size_t k = 0; k < cnt; k++)
|
|
244
|
+
if ((long)(k + 1) != drop) seq_push_str(out, items[k]);
|
|
245
|
+
free_items(items, cnt);
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
static struct leptris_xpath_result* fn_insert_before(XPathContext* ctx,
|
|
250
|
+
XPathASTNode** args, size_t n) {
|
|
251
|
+
size_t cnt;
|
|
252
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
253
|
+
if (!items) return NULL;
|
|
254
|
+
struct leptris_xpath_result* iv = xpath_evaluate(ctx, args[1]);
|
|
255
|
+
long at = iv ? (long)leptris_xpath_result_number(iv) : 1;
|
|
256
|
+
if (iv) leptris_xpath_result_free(iv);
|
|
257
|
+
size_t icnt;
|
|
258
|
+
char** ins = collect_items(ctx, args, n, 2, &icnt);
|
|
259
|
+
struct leptris_xpath_result* out = seq_new();
|
|
260
|
+
if (out && ins) {
|
|
261
|
+
for (long k = 1; k <= (long)(cnt + icnt); k++) {
|
|
262
|
+
if (k == at)
|
|
263
|
+
for (size_t j = 0; j < icnt; j++) seq_push_str(out, ins[j]);
|
|
264
|
+
if (k <= (long)cnt) seq_push_str(out, items[k - 1]);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
free_items(items, cnt);
|
|
268
|
+
free_items(ins, icnt);
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
static struct leptris_xpath_result* fn_index_of(XPathContext* ctx,
|
|
273
|
+
XPathASTNode** args, size_t n) {
|
|
274
|
+
size_t cnt;
|
|
275
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
276
|
+
if (!items) return NULL;
|
|
277
|
+
struct leptris_xpath_result* v = xpath_evaluate(ctx, args[1]);
|
|
278
|
+
char* needle = v ? scalar_str(v) : NULL;
|
|
279
|
+
struct leptris_xpath_result* out = seq_new();
|
|
280
|
+
if (out && needle)
|
|
281
|
+
for (size_t k = 0; k < cnt; k++)
|
|
282
|
+
if (strcmp(items[k], needle) == 0) seq_push_num(out, (double)(k + 1));
|
|
283
|
+
free(needle);
|
|
284
|
+
if (v) leptris_xpath_result_free(v);
|
|
285
|
+
free_items(items, cnt);
|
|
286
|
+
return out;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
static struct leptris_xpath_result* fn_distinct_values(XPathContext* ctx,
|
|
290
|
+
XPathASTNode** args, size_t n) {
|
|
291
|
+
size_t cnt;
|
|
292
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
293
|
+
if (!items) return NULL;
|
|
294
|
+
struct leptris_xpath_result* out = seq_new();
|
|
295
|
+
if (out)
|
|
296
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
297
|
+
int dup = 0;
|
|
298
|
+
for (size_t j = 0; j < k && !dup; j++)
|
|
299
|
+
if (strcmp(items[k], items[j]) == 0) dup = 1;
|
|
300
|
+
if (!dup) seq_push_str(out, items[k]);
|
|
301
|
+
}
|
|
302
|
+
free_items(items, cnt);
|
|
303
|
+
return out;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* Numeric aggregation over items; strings that are not numbers
|
|
307
|
+
* coerce to NaN per XPath number(). */
|
|
308
|
+
static struct leptris_xpath_result* fn_avg_min_max(XPathContext* ctx,
|
|
309
|
+
XPathASTNode** args, size_t n, int which) {
|
|
310
|
+
size_t cnt;
|
|
311
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
312
|
+
if (!items) return NULL;
|
|
313
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
314
|
+
if (!out) { free_items(items, cnt); return NULL; }
|
|
315
|
+
if (!cnt) { out->value.number_value = 0; free_items(items, cnt); return out; }
|
|
316
|
+
double acc = 0, best = 0;
|
|
317
|
+
size_t numeric = 0;
|
|
318
|
+
int first = 1;
|
|
319
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
320
|
+
char* end = NULL;
|
|
321
|
+
double d = strtod(items[k], &end);
|
|
322
|
+
if (items[k][0] == '\0') d = 0; /* empty string -> NaN in spec; treat 0 */
|
|
323
|
+
acc += d;
|
|
324
|
+
if (first) { best = d; first = 0; }
|
|
325
|
+
else if (which == 2 && d < best) best = d; /* min */
|
|
326
|
+
else if (which == 3 && d > best) best = d; /* max */
|
|
327
|
+
numeric++;
|
|
328
|
+
}
|
|
329
|
+
out->value.number_value = (which == 1) ? acc / (double)numeric : best;
|
|
330
|
+
free_items(items, cnt);
|
|
331
|
+
return out;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
static struct leptris_xpath_result* fn_avg(XPathContext* c,
|
|
335
|
+
XPathASTNode** a, size_t n) {
|
|
336
|
+
return fn_avg_min_max(c, a, n, 1);
|
|
337
|
+
}
|
|
338
|
+
static struct leptris_xpath_result* fn_min(XPathContext* c,
|
|
339
|
+
XPathASTNode** a, size_t n) {
|
|
340
|
+
return fn_avg_min_max(c, a, n, 2);
|
|
341
|
+
}
|
|
342
|
+
static struct leptris_xpath_result* fn_max(XPathContext* c,
|
|
343
|
+
XPathASTNode** a, size_t n) {
|
|
344
|
+
return fn_avg_min_max(c, a, n, 3);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/* ---- cardinality checks ---- */
|
|
348
|
+
|
|
349
|
+
static struct leptris_xpath_result* fn_cardinality(XPathContext* ctx,
|
|
350
|
+
XPathASTNode** args, size_t n, int min, int max) {
|
|
351
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
352
|
+
if (!r) return NULL;
|
|
353
|
+
size_t cnt = 1;
|
|
354
|
+
if (r->type == XPATH_RESULT_NODESET)
|
|
355
|
+
cnt = r->value.nodeset_value ? r->value.nodeset_value->count : 0;
|
|
356
|
+
if ((int)cnt < min || (max >= 0 && (int)cnt > max)) {
|
|
357
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
358
|
+
"Cardinality violation: sequence has %zu items", cnt);
|
|
359
|
+
xpath_result_free(r);
|
|
360
|
+
return NULL;
|
|
361
|
+
}
|
|
362
|
+
return r;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
static struct leptris_xpath_result* fn_zero_or_one(XPathContext* c,
|
|
366
|
+
XPathASTNode** a, size_t n) { return fn_cardinality(c, a, n, 0, 1); }
|
|
367
|
+
static struct leptris_xpath_result* fn_one_or_more(XPathContext* c,
|
|
368
|
+
XPathASTNode** a, size_t n) { return fn_cardinality(c, a, n, 1, -1); }
|
|
369
|
+
static struct leptris_xpath_result* fn_exactly_one(XPathContext* c,
|
|
370
|
+
XPathASTNode** a, size_t n) { return fn_cardinality(c, a, n, 1, 1); }
|
|
371
|
+
|
|
372
|
+
/* ---- math ---- */
|
|
373
|
+
|
|
374
|
+
static struct leptris_xpath_result* fn_math1(XPathContext* ctx,
|
|
375
|
+
XPathASTNode** args, size_t n, double (*f)(double)) {
|
|
376
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
377
|
+
if (!r) return NULL;
|
|
378
|
+
double d = leptris_xpath_result_number(r);
|
|
379
|
+
leptris_xpath_result_free(r);
|
|
380
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
381
|
+
if (out && n) out->value.number_value = f(d);
|
|
382
|
+
return out;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
#define MATH1(NAME, EXPR) \
|
|
386
|
+
static double m_##NAME(double x) { return (EXPR); } \
|
|
387
|
+
static struct leptris_xpath_result* fn_##NAME( \
|
|
388
|
+
XPathContext* ctx, XPathASTNode** a, size_t n) { \
|
|
389
|
+
return fn_math1(ctx, a, n, m_##NAME); \
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
MATH1(sqrt, sqrt(x))
|
|
393
|
+
MATH1(exp, exp(x))
|
|
394
|
+
MATH1(exp10, pow(10.0, x))
|
|
395
|
+
MATH1(log, log(x))
|
|
396
|
+
MATH1(log10, log10(x))
|
|
397
|
+
MATH1(sin, sin(x))
|
|
398
|
+
MATH1(cos, cos(x))
|
|
399
|
+
MATH1(tan, tan(x))
|
|
400
|
+
MATH1(asin, asin(x))
|
|
401
|
+
MATH1(acos, acos(x))
|
|
402
|
+
MATH1(atan, atan(x))
|
|
403
|
+
|
|
404
|
+
static struct leptris_xpath_result* fn_pow(XPathContext* ctx,
|
|
405
|
+
XPathASTNode** args, size_t n) {
|
|
406
|
+
struct leptris_xpath_result* a = xpath_evaluate(ctx, args[0]);
|
|
407
|
+
struct leptris_xpath_result* b = xpath_evaluate(ctx, args[1]);
|
|
408
|
+
double x = a ? leptris_xpath_result_number(a) : 0;
|
|
409
|
+
double y = b ? leptris_xpath_result_number(b) : 0;
|
|
410
|
+
if (a) leptris_xpath_result_free(a);
|
|
411
|
+
if (b) leptris_xpath_result_free(b);
|
|
412
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
413
|
+
if (out && n) out->value.number_value = pow(x, y);
|
|
414
|
+
return out;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
static struct leptris_xpath_result* fn_atan2(XPathContext* ctx,
|
|
418
|
+
XPathASTNode** args, size_t n) {
|
|
419
|
+
struct leptris_xpath_result* a = xpath_evaluate(ctx, args[0]);
|
|
420
|
+
struct leptris_xpath_result* b = xpath_evaluate(ctx, args[1]);
|
|
421
|
+
double x = a ? leptris_xpath_result_number(a) : 0;
|
|
422
|
+
double y = b ? leptris_xpath_result_number(b) : 0;
|
|
423
|
+
if (a) leptris_xpath_result_free(a);
|
|
424
|
+
if (b) leptris_xpath_result_free(b);
|
|
425
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
426
|
+
if (out && n) out->value.number_value = atan2(x, y);
|
|
427
|
+
return out;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
static struct leptris_xpath_result* fn_pi(XPathContext* ctx,
|
|
431
|
+
XPathASTNode** args, size_t n) {
|
|
432
|
+
(void)ctx; (void)args; (void)n;
|
|
433
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
434
|
+
if (out) out->value.number_value = 3.141592653589793;
|
|
435
|
+
return out;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
static struct leptris_xpath_result* fn_abs(XPathContext* ctx,
|
|
439
|
+
XPathASTNode** args, size_t n) {
|
|
440
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
441
|
+
if (!r) return NULL;
|
|
442
|
+
double d = leptris_xpath_result_number(r);
|
|
443
|
+
leptris_xpath_result_free(r);
|
|
444
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
445
|
+
if (out && n) out->value.number_value = fabs(d);
|
|
446
|
+
return out;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
static struct leptris_xpath_result* fn_round_half_even(XPathContext* ctx,
|
|
450
|
+
XPathASTNode** args, size_t n) {
|
|
451
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
452
|
+
if (!r) return NULL;
|
|
453
|
+
double v = leptris_xpath_result_number(r);
|
|
454
|
+
leptris_xpath_result_free(r);
|
|
455
|
+
int prec = 0;
|
|
456
|
+
if (n >= 2) {
|
|
457
|
+
struct leptris_xpath_result* p = xpath_evaluate(ctx, args[1]);
|
|
458
|
+
prec = p ? (int)leptris_xpath_result_number(p) : 0;
|
|
459
|
+
if (p) leptris_xpath_result_free(p);
|
|
460
|
+
}
|
|
461
|
+
double scale = pow(10.0, prec);
|
|
462
|
+
double x = v * scale;
|
|
463
|
+
double f = floor(x);
|
|
464
|
+
double diff = x - f;
|
|
465
|
+
double rounded;
|
|
466
|
+
if (diff == 0.5)
|
|
467
|
+
rounded = (((long)f) % 2 == 0) ? f : f + 1; /* tie -> even */
|
|
468
|
+
else
|
|
469
|
+
rounded = floor(x + 0.5);
|
|
470
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
471
|
+
if (out) out->value.number_value = rounded / scale;
|
|
472
|
+
return out;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/* ---- regex trio ---- */
|
|
476
|
+
|
|
477
|
+
#ifdef LEPTRIS_HAVE_POSIX_RE
|
|
478
|
+
static int re_flags(const char* flags) {
|
|
479
|
+
int cflags = REG_EXTENDED;
|
|
480
|
+
for (const char* p = flags ? flags : ""; *p; p++) {
|
|
481
|
+
if (*p == 'i') cflags |= REG_ICASE;
|
|
482
|
+
else if (*p == 'm') cflags |= REG_NEWLINE;
|
|
483
|
+
/* 'x' handled by the caller (pattern rewrite); 's' is a
|
|
484
|
+
* no-op for POSIX (dot excludes newline in ERE). */
|
|
485
|
+
}
|
|
486
|
+
return cflags;
|
|
487
|
+
}
|
|
488
|
+
#endif
|
|
489
|
+
|
|
490
|
+
/* Compile an XPath-flavor pattern to POSIX ERE: translate the
|
|
491
|
+
* shortcut escapes (\d \D \w \W \s \S) to bracket expressions
|
|
492
|
+
* (outside classes) or POSIX classes (inside), then apply the 'x'
|
|
493
|
+
* flag's whitespace strip. Saxon's regex language is XML-Schema
|
|
494
|
+
* flavored; POSIX ERE is the engine underneath (portable engine
|
|
495
|
+
* swap tracked with TODO.xslt-full/02). */
|
|
496
|
+
static char* re_pattern_for(const char* pat, const char* flags) {
|
|
497
|
+
int x = 0;
|
|
498
|
+
for (const char* p = flags ? flags : ""; *p; p++)
|
|
499
|
+
if (*p == 'x') x = 1;
|
|
500
|
+
size_t len = strlen(pat);
|
|
501
|
+
char* out = (char*)malloc(len * 8 + 1);
|
|
502
|
+
if (!out) return NULL;
|
|
503
|
+
size_t o = 0;
|
|
504
|
+
int in_class = 0;
|
|
505
|
+
for (size_t i = 0; i < len; i++) {
|
|
506
|
+
char c = pat[i];
|
|
507
|
+
if (x && !in_class && (c == ' ' || c == '\t' || c == '\n'))
|
|
508
|
+
continue;
|
|
509
|
+
if (c == '\\' && i + 1 < len) {
|
|
510
|
+
char e = pat[i + 1];
|
|
511
|
+
const char* sub = NULL, *incls = NULL;
|
|
512
|
+
switch (e) {
|
|
513
|
+
case 'd': sub = "[0-9]"; incls = "[:digit:]"; break;
|
|
514
|
+
case 'D': sub = "[^0-9]"; incls = "[:^digit:]"; break;
|
|
515
|
+
case 'w': sub = "[_a-zA-Z0-9]";
|
|
516
|
+
incls = "[:alnum:]_"; break;
|
|
517
|
+
case 'W': sub = "[^_a-zA-Z0-9]";
|
|
518
|
+
incls = "[:^alnum:]"; break;
|
|
519
|
+
case 's': sub = "[ \t\r\n]"; incls = "[:space:]"; break;
|
|
520
|
+
case 'S': sub = "[^ \t\r\n]";
|
|
521
|
+
incls = "[:^space:]"; break;
|
|
522
|
+
default:
|
|
523
|
+
out[o++] = c; out[o++] = e; i++;
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
if (in_class) {
|
|
527
|
+
if (e == 'd' || e == 'w' || e == 's')
|
|
528
|
+
{ out[o++] = '['; }
|
|
529
|
+
strcpy(out + o, incls); o += strlen(incls);
|
|
530
|
+
if (e == 'd' || e == 'w' || e == 's')
|
|
531
|
+
{ out[o++] = ']'; }
|
|
532
|
+
} else {
|
|
533
|
+
strcpy(out + o, sub); o += strlen(sub);
|
|
534
|
+
}
|
|
535
|
+
i++;
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
if (c == '[' && (i == 0 || pat[i-1] != '\\')) in_class = 1;
|
|
539
|
+
else if (c == ']' && i > 0 && pat[i-1] != '\\') in_class = 0;
|
|
540
|
+
out[o++] = c;
|
|
541
|
+
}
|
|
542
|
+
out[o] = 0;
|
|
543
|
+
return out;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
static char* re_str_arg_opt(XPathContext* ctx, XPathASTNode** args,
|
|
547
|
+
size_t i);
|
|
548
|
+
|
|
549
|
+
static char* re_str_arg(XPathContext* ctx, XPathASTNode** args, size_t i) {
|
|
550
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[i]);
|
|
551
|
+
if (!r) return NULL;
|
|
552
|
+
/* Node arguments atomize to their string value (#691 comment:
|
|
553
|
+
* matches(//item[1], ...) — the scalar path returned NULL for
|
|
554
|
+
* nodesets). */
|
|
555
|
+
char* s = (r->type == XPATH_RESULT_NODESET)
|
|
556
|
+
? leptris_xpath_result_string(r)
|
|
557
|
+
: scalar_str(r);
|
|
558
|
+
leptris_xpath_result_free(r);
|
|
559
|
+
return s;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
#ifdef LEPTRIS_HAVE_POSIX_RE
|
|
563
|
+
|
|
564
|
+
static struct leptris_xpath_result* fn_matches(XPathContext* ctx,
|
|
565
|
+
XPathASTNode** args, size_t n) {
|
|
566
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
567
|
+
char* pat = re_str_arg(ctx, args, 1);
|
|
568
|
+
char* fl = (n >= 3) ? re_str_arg(ctx, args, 2) : leptris_strdup("");
|
|
569
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
570
|
+
if (!out || !in || !pat) {
|
|
571
|
+
free(in); free(pat); free(fl);
|
|
572
|
+
if (out) { out->value.boolean_value = 0; return out; }
|
|
573
|
+
return NULL;
|
|
574
|
+
}
|
|
575
|
+
char* xp = re_pattern_for(pat, fl);
|
|
576
|
+
regex_t rx;
|
|
577
|
+
if (xp && regcomp(&rx, xp, re_flags(fl)) == 0) {
|
|
578
|
+
out->value.boolean_value = regexec(&rx, in, 0, NULL, 0) == 0;
|
|
579
|
+
regfree(&rx);
|
|
580
|
+
} else {
|
|
581
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
582
|
+
"Invalid regular expression: %s", pat);
|
|
583
|
+
out->value.boolean_value = 0;
|
|
584
|
+
}
|
|
585
|
+
free(xp);
|
|
586
|
+
free(in); free(pat); free(fl);
|
|
587
|
+
return out;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/* fn:replace with $1..$9 capture references. */
|
|
591
|
+
static struct leptris_xpath_result* fn_replace(XPathContext* ctx,
|
|
592
|
+
XPathASTNode** args, size_t n) {
|
|
593
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
594
|
+
char* pat = re_str_arg(ctx, args, 1);
|
|
595
|
+
char* rep = re_str_arg(ctx, args, 2);
|
|
596
|
+
char* fl = (n >= 4) ? re_str_arg(ctx, args, 3) : leptris_strdup("");
|
|
597
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
598
|
+
if (!out || !in || !pat || !rep) {
|
|
599
|
+
if (out) out->value.string_value = leptris_strdup("");
|
|
600
|
+
free(in); free(pat); free(rep); free(fl);
|
|
601
|
+
return out;
|
|
602
|
+
}
|
|
603
|
+
out->value.string_value = leptris_strdup("");
|
|
604
|
+
char* xp = re_pattern_for(pat, fl);
|
|
605
|
+
regex_t rx;
|
|
606
|
+
if (xp && regcomp(&rx, xp, re_flags(fl)) == 0) {
|
|
607
|
+
size_t nm = rx.re_nsub + 1;
|
|
608
|
+
regmatch_t* pm = (regmatch_t*)calloc(nm, sizeof(*pm));
|
|
609
|
+
size_t pos = 0, ilen = strlen(in);
|
|
610
|
+
size_t rlen = strlen(rep);
|
|
611
|
+
while (pos <= ilen && pm) {
|
|
612
|
+
if (regexec(&rx, in + pos, nm, pm, 0) != 0) break;
|
|
613
|
+
regmatch_t* m = &pm[0];
|
|
614
|
+
if (m->rm_so == m->rm_eo && m->rm_so == 0 && pos > 0) {
|
|
615
|
+
/* zero-width match at restart — append one char and
|
|
616
|
+
* continue so the scan terminates. */
|
|
617
|
+
char* grown = (char*)realloc(
|
|
618
|
+
out->value.string_value,
|
|
619
|
+
strlen(out->value.string_value) + 2);
|
|
620
|
+
if (grown) {
|
|
621
|
+
size_t l = strlen(grown);
|
|
622
|
+
grown[l] = in[pos - 1];
|
|
623
|
+
grown[l + 1] = 0;
|
|
624
|
+
out->value.string_value = grown;
|
|
625
|
+
}
|
|
626
|
+
pos++;
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
/* literal before the match */
|
|
630
|
+
{
|
|
631
|
+
size_t pre = (size_t)m->rm_so;
|
|
632
|
+
size_t old = strlen(out->value.string_value);
|
|
633
|
+
char* grown = (char*)realloc(
|
|
634
|
+
out->value.string_value, old + pre + 1);
|
|
635
|
+
if (grown) {
|
|
636
|
+
memcpy(grown + old, in + pos, pre);
|
|
637
|
+
grown[old + pre] = 0;
|
|
638
|
+
out->value.string_value = grown;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
/* replacement with $N splices */
|
|
642
|
+
for (size_t k = 0; k < rlen; k++) {
|
|
643
|
+
if (rep[k] == '$' && k + 1 < rlen && rep[k + 1] >= '1' &&
|
|
644
|
+
rep[k + 1] <= '9') {
|
|
645
|
+
int g = rep[k + 1] - '0';
|
|
646
|
+
if ((size_t)g < nm && pm[g].rm_so >= 0) {
|
|
647
|
+
size_t gl = (size_t)(pm[g].rm_eo - pm[g].rm_so);
|
|
648
|
+
size_t old = strlen(out->value.string_value);
|
|
649
|
+
char* grown = (char*)realloc(
|
|
650
|
+
out->value.string_value, old + gl + 1);
|
|
651
|
+
if (grown) {
|
|
652
|
+
memcpy(grown + old, in + pos + pm[g].rm_so, gl);
|
|
653
|
+
grown[old + gl] = 0;
|
|
654
|
+
out->value.string_value = grown;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
k++;
|
|
658
|
+
} else if (rep[k] == '\\' && k + 1 < rlen) {
|
|
659
|
+
size_t old = strlen(out->value.string_value);
|
|
660
|
+
char* grown = (char*)realloc(
|
|
661
|
+
out->value.string_value, old + 2);
|
|
662
|
+
if (grown) {
|
|
663
|
+
grown[old] = rep[k + 1];
|
|
664
|
+
grown[old + 1] = 0;
|
|
665
|
+
out->value.string_value = grown;
|
|
666
|
+
}
|
|
667
|
+
k++;
|
|
668
|
+
} else {
|
|
669
|
+
size_t old = strlen(out->value.string_value);
|
|
670
|
+
char* grown = (char*)realloc(
|
|
671
|
+
out->value.string_value, old + 2);
|
|
672
|
+
if (grown) {
|
|
673
|
+
grown[old] = rep[k];
|
|
674
|
+
grown[old + 1] = 0;
|
|
675
|
+
out->value.string_value = grown;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
if (m->rm_eo == m->rm_so) {
|
|
680
|
+
/* zero-width: copy one char and advance */
|
|
681
|
+
if (pos + (size_t)m->rm_eo < ilen) {
|
|
682
|
+
size_t old = strlen(out->value.string_value);
|
|
683
|
+
char* grown = (char*)realloc(
|
|
684
|
+
out->value.string_value, old + 2);
|
|
685
|
+
if (grown) {
|
|
686
|
+
grown[old] = in[pos + m->rm_eo];
|
|
687
|
+
grown[old + 1] = 0;
|
|
688
|
+
out->value.string_value = grown;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
pos += (size_t)m->rm_eo + 1;
|
|
692
|
+
} else {
|
|
693
|
+
pos += (size_t)m->rm_eo;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
if (pos <= ilen) {
|
|
697
|
+
size_t old = strlen(out->value.string_value);
|
|
698
|
+
char* grown = (char*)realloc(
|
|
699
|
+
out->value.string_value, old + (ilen - pos) + 1);
|
|
700
|
+
if (grown) {
|
|
701
|
+
memcpy(grown + old, in + pos, ilen - pos);
|
|
702
|
+
grown[old + (ilen - pos)] = 0;
|
|
703
|
+
out->value.string_value = grown;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
free(pm);
|
|
707
|
+
regfree(&rx);
|
|
708
|
+
} else {
|
|
709
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
710
|
+
"Invalid regular expression: %s", pat);
|
|
711
|
+
}
|
|
712
|
+
free(xp);
|
|
713
|
+
free(in); free(pat); free(rep); free(fl);
|
|
714
|
+
return out;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/* fn:tokenize — zero-width matches yield EMPTY tokens (Saxon). */
|
|
718
|
+
static struct leptris_xpath_result* fn_tokenize(XPathContext* ctx,
|
|
719
|
+
XPathASTNode** args, size_t n) {
|
|
720
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
721
|
+
char* pat = re_str_arg(ctx, args, 1);
|
|
722
|
+
char* fl = (n >= 3) ? re_str_arg(ctx, args, 2) : leptris_strdup("");
|
|
723
|
+
struct leptris_xpath_result* out = seq_new();
|
|
724
|
+
if (!out || !in || !pat) { free(in); free(pat); free(fl); return out; }
|
|
725
|
+
char* xp = re_pattern_for(pat, fl);
|
|
726
|
+
regex_t rx;
|
|
727
|
+
if (xp && regcomp(&rx, xp, re_flags(fl)) == 0) {
|
|
728
|
+
size_t nm = rx.re_nsub + 1;
|
|
729
|
+
regmatch_t* pm = (regmatch_t*)calloc(nm, sizeof(*pm));
|
|
730
|
+
size_t pos = 0, ilen = strlen(in);
|
|
731
|
+
while (pos <= ilen && pm) {
|
|
732
|
+
if (regexec(&rx, in + pos, nm, pm, 0) != 0) break;
|
|
733
|
+
regmatch_t* m = &pm[0];
|
|
734
|
+
if (m->rm_eo == m->rm_so && pos == 0) {
|
|
735
|
+
/* zero-width at the very start: empty leading token. */
|
|
736
|
+
seq_push_str(out, "");
|
|
737
|
+
pos++;
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
/* token = text before the match */
|
|
741
|
+
char seg[512];
|
|
742
|
+
size_t pre = (size_t)m->rm_so;
|
|
743
|
+
if (pre < sizeof seg) {
|
|
744
|
+
memcpy(seg, in + pos, pre);
|
|
745
|
+
seg[pre] = 0;
|
|
746
|
+
seq_push_str(out, seg);
|
|
747
|
+
}
|
|
748
|
+
pos += (size_t)m->rm_eo;
|
|
749
|
+
if (m->rm_eo == m->rm_so) pos++;
|
|
750
|
+
}
|
|
751
|
+
if (pos <= ilen) {
|
|
752
|
+
char seg[512];
|
|
753
|
+
size_t rem = ilen - pos;
|
|
754
|
+
if (rem < sizeof seg) {
|
|
755
|
+
memcpy(seg, in + pos, rem);
|
|
756
|
+
seg[rem] = 0;
|
|
757
|
+
seq_push_str(out, seg);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
free(pm);
|
|
761
|
+
regfree(&rx);
|
|
762
|
+
} else {
|
|
763
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
764
|
+
"Invalid regular expression: %s", pat);
|
|
765
|
+
}
|
|
766
|
+
free(xp);
|
|
767
|
+
free(in); free(pat); free(fl);
|
|
768
|
+
return out;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
#else /* !_WIN32 */
|
|
772
|
+
|
|
773
|
+
static struct leptris_xpath_result* re_unavailable(XPathContext* ctx,
|
|
774
|
+
XPathASTNode** args, size_t n) {
|
|
775
|
+
(void)args; (void)n;
|
|
776
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
777
|
+
"Regex functions unavailable in this platform build "
|
|
778
|
+
"(no regex engine) — issue #686 family");
|
|
779
|
+
return NULL;
|
|
780
|
+
}
|
|
781
|
+
#define fn_matches re_unavailable
|
|
782
|
+
#define fn_replace re_unavailable
|
|
783
|
+
#define fn_tokenize re_unavailable
|
|
784
|
+
|
|
785
|
+
#endif
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
/* ---- strings / QNames / URIs (TODO.xslt-full/04) ---- */
|
|
789
|
+
|
|
790
|
+
static const char* k_words_units[] = {
|
|
791
|
+
"zero","one","two","three","four","five","six","seven","eight",
|
|
792
|
+
"nine","ten","eleven","twelve","thirteen","fourteen","fifteen",
|
|
793
|
+
"sixteen","seventeen","eighteen","nineteen"};
|
|
794
|
+
static const char* k_words_tens[] = {
|
|
795
|
+
"","","twenty","thirty","forty","fifty","sixty","seventy",
|
|
796
|
+
"eighty","ninety"};
|
|
797
|
+
|
|
798
|
+
static size_t words999(char* buf, size_t len, long n) {
|
|
799
|
+
if (n >= 100) {
|
|
800
|
+
len += (size_t)snprintf(buf + len, 32, "%s hundred",
|
|
801
|
+
k_words_units[n / 100]);
|
|
802
|
+
n %= 100;
|
|
803
|
+
if (n) len += (size_t)snprintf(buf + len, 8, " ");
|
|
804
|
+
}
|
|
805
|
+
if (n >= 20) {
|
|
806
|
+
len += (size_t)snprintf(buf + len, 32, "%s", k_words_tens[n / 10]);
|
|
807
|
+
n %= 10;
|
|
808
|
+
if (n) len += (size_t)snprintf(buf + len, 8, "-");
|
|
809
|
+
}
|
|
810
|
+
if (n > 0)
|
|
811
|
+
len += (size_t)snprintf(buf + len, 32, "%s", k_words_units[n]);
|
|
812
|
+
return len;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/* fn:format-integer — decimal, 0-pad, a/A, i/I, w/W pictures. */
|
|
816
|
+
static struct leptris_xpath_result* fn_format_integer(XPathContext* ctx,
|
|
817
|
+
XPathASTNode** args, size_t n) {
|
|
818
|
+
struct leptris_xpath_result* v = xpath_evaluate(ctx, args[0]);
|
|
819
|
+
char* pic = re_str_arg(ctx, args, 1);
|
|
820
|
+
long x = v ? (long)leptris_xpath_result_number(v) : 0;
|
|
821
|
+
if (v) leptris_xpath_result_free(v);
|
|
822
|
+
(void)n;
|
|
823
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
824
|
+
if (!out || !pic) {
|
|
825
|
+
if (out) out->value.string_value = leptris_strdup("");
|
|
826
|
+
free(pic);
|
|
827
|
+
return out;
|
|
828
|
+
}
|
|
829
|
+
char buf[256];
|
|
830
|
+
size_t len = 0;
|
|
831
|
+
char p0 = pic[0] ? pic[0] : '0';
|
|
832
|
+
int neg = x < 0;
|
|
833
|
+
long ax = neg ? -x : x;
|
|
834
|
+
if (strchr(pic, 'w') || strchr(pic, 'W')) {
|
|
835
|
+
char wbuf[256] = {0}; size_t wl = 0;
|
|
836
|
+
if (ax == 0) wl = (size_t)snprintf(wbuf, sizeof wbuf, "zero");
|
|
837
|
+
if (ax >= 1000000) {
|
|
838
|
+
wl += (size_t)snprintf(wbuf + wl, 16, "over");
|
|
839
|
+
} else if (ax >= 1000) {
|
|
840
|
+
wl = words999(wbuf, wl, ax / 1000);
|
|
841
|
+
wl += (size_t)snprintf(wbuf + wl, 16, " thousand");
|
|
842
|
+
if (ax % 1000) wl += (size_t)snprintf(wbuf + wl, 8, " ");
|
|
843
|
+
wl = words999(wbuf, wl, ax % 1000);
|
|
844
|
+
} else {
|
|
845
|
+
wl = words999(wbuf, wl, ax);
|
|
846
|
+
}
|
|
847
|
+
if (p0 == 'W') { for (size_t i = 0; i < wl; i++) wbuf[i] = (char)toupper((unsigned char)wbuf[i]); }
|
|
848
|
+
len = (size_t)snprintf(buf, sizeof buf, "%s%s%s",
|
|
849
|
+
neg ? "minus " : "", wbuf, "");
|
|
850
|
+
} else if (p0 == 'a' || p0 == 'A' || p0 == 'i' || p0 == 'I' ||
|
|
851
|
+
p0 == '0' || p0 == '1' || p0 == '#') {
|
|
852
|
+
if (p0 == 'a' || p0 == 'A') {
|
|
853
|
+
/* bijective base-26 */
|
|
854
|
+
char t[32]; size_t tl = 0;
|
|
855
|
+
long a = ax;
|
|
856
|
+
if (a == 0) t[tl++] = 'a';
|
|
857
|
+
while (a > 0) { a--; t[tl++] = (char)('a' + a % 26); a /= 26; }
|
|
858
|
+
if (neg) buf[len++] = '-';
|
|
859
|
+
while (tl) buf[len++] = t[--tl];
|
|
860
|
+
buf[len] = 0;
|
|
861
|
+
if (p0 == 'A')
|
|
862
|
+
for (size_t i = neg ? 1 : 0; i < len; i++)
|
|
863
|
+
buf[i] = (char)toupper((unsigned char)buf[i]);
|
|
864
|
+
} else if (p0 == 'i' || p0 == 'I') {
|
|
865
|
+
static const char* rom[] = {"m","cm","d","cd","c","xc","l",
|
|
866
|
+
"xl","x","ix","v","iv","i"};
|
|
867
|
+
static const long rv[] = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
|
|
868
|
+
if (neg) buf[len++] = '-';
|
|
869
|
+
long a = ax;
|
|
870
|
+
for (int k = 0; k < 13; k++)
|
|
871
|
+
while (a >= rv[k]) {
|
|
872
|
+
len += (size_t)snprintf(buf + len, 8, "%s", rom[k]);
|
|
873
|
+
a -= rv[k];
|
|
874
|
+
}
|
|
875
|
+
buf[len] = 0;
|
|
876
|
+
if (p0 == 'I')
|
|
877
|
+
for (size_t i = neg ? 1 : 0; i < len; i++)
|
|
878
|
+
buf[i] = (char)toupper((unsigned char)buf[i]);
|
|
879
|
+
} else {
|
|
880
|
+
/* decimal; 0-picture pads to the digit count */
|
|
881
|
+
char num[32];
|
|
882
|
+
int nl = snprintf(num, sizeof num, "%ld", ax);
|
|
883
|
+
size_t zeros = 0;
|
|
884
|
+
for (const char* q = pic; *q == '0'; q++) zeros++;
|
|
885
|
+
len = (size_t)snprintf(buf, sizeof buf, "%s%0*ld",
|
|
886
|
+
neg ? "-" : "",
|
|
887
|
+
zeros > (size_t)nl ? (int)zeros : nl, ax);
|
|
888
|
+
}
|
|
889
|
+
} else {
|
|
890
|
+
len = (size_t)snprintf(buf, sizeof buf, "%ld", x);
|
|
891
|
+
}
|
|
892
|
+
out->value.string_value = leptris_strdup(buf);
|
|
893
|
+
free(pic);
|
|
894
|
+
return out;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
static struct leptris_xpath_result* fn_contains_token(XPathContext* ctx,
|
|
898
|
+
XPathASTNode** args, size_t n) {
|
|
899
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
900
|
+
char* tok = re_str_arg(ctx, args, 1);
|
|
901
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
902
|
+
if (!out || !in || !tok) {
|
|
903
|
+
if (out) out->value.boolean_value = 0;
|
|
904
|
+
free(in); free(tok);
|
|
905
|
+
return out;
|
|
906
|
+
}
|
|
907
|
+
out->value.boolean_value = 0;
|
|
908
|
+
const char* p = in;
|
|
909
|
+
while (*p) {
|
|
910
|
+
while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') p++;
|
|
911
|
+
if (!*p) break;
|
|
912
|
+
const char* st = p;
|
|
913
|
+
while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r')
|
|
914
|
+
p++;
|
|
915
|
+
if ((size_t)(p - st) == strlen(tok) &&
|
|
916
|
+
strncmp(st, tok, (size_t)(p - st)) == 0) {
|
|
917
|
+
out->value.boolean_value = 1;
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
free(in); free(tok);
|
|
922
|
+
(void)n;
|
|
923
|
+
return out;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/* Minimal UTF-8 decode/encode (codepoints are UCS). */
|
|
927
|
+
static struct leptris_xpath_result* fn_string_to_codepoints(XPathContext* ctx,
|
|
928
|
+
XPathASTNode** args, size_t n) {
|
|
929
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
930
|
+
struct leptris_xpath_result* out = seq_new();
|
|
931
|
+
if (!out || !in) { free(in); return out; }
|
|
932
|
+
const unsigned char* p = (const unsigned char*)in;
|
|
933
|
+
while (*p) {
|
|
934
|
+
unsigned cp;
|
|
935
|
+
if (*p < 0x80) { cp = *p++; }
|
|
936
|
+
else if ((*p & 0xE0) == 0xC0) { cp = (*p++ & 0x1F) << 6; cp |= (*p++ & 0x3F); }
|
|
937
|
+
else if ((*p & 0xF0) == 0xE0) { cp = (*p++ & 0x0F) << 12; cp |= (*p++ & 0x3F) << 6; cp |= (*p++ & 0x3F); }
|
|
938
|
+
else { cp = (*p++ & 0x07) << 18; cp |= (*p++ & 0x3F) << 12; cp |= (*p++ & 0x3F) << 6; cp |= (*p++ & 0x3F); }
|
|
939
|
+
seq_push_num(out, (double)cp);
|
|
940
|
+
}
|
|
941
|
+
free(in);
|
|
942
|
+
(void)n;
|
|
943
|
+
return out;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
static struct leptris_xpath_result* fn_codepoints_to_string(XPathContext* ctx,
|
|
947
|
+
XPathASTNode** args, size_t n) {
|
|
948
|
+
size_t cnt;
|
|
949
|
+
char** items = collect_items(ctx, args, n, 0, &cnt);
|
|
950
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
951
|
+
if (!out) { free_items(items, cnt); return NULL; }
|
|
952
|
+
out->value.string_value = (char*)calloc(cnt * 5 + 1, 1);
|
|
953
|
+
size_t o = 0;
|
|
954
|
+
if (items)
|
|
955
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
956
|
+
unsigned cp = (unsigned)strtoul(items[k], NULL, 10);
|
|
957
|
+
if (cp < 0x80) out->value.string_value[o++] = (char)cp;
|
|
958
|
+
else if (cp < 0x800) {
|
|
959
|
+
out->value.string_value[o++] = (char)(0xC0 | cp >> 6);
|
|
960
|
+
out->value.string_value[o++] = (char)(0x80 | (cp & 0x3F));
|
|
961
|
+
} else if (cp < 0x10000) {
|
|
962
|
+
out->value.string_value[o++] = (char)(0xE0 | cp >> 12);
|
|
963
|
+
out->value.string_value[o++] = (char)(0x80 | ((cp >> 6) & 0x3F));
|
|
964
|
+
out->value.string_value[o++] = (char)(0x80 | (cp & 0x3F));
|
|
965
|
+
} else {
|
|
966
|
+
out->value.string_value[o++] = (char)(0xF0 | cp >> 18);
|
|
967
|
+
out->value.string_value[o++] = (char)(0x80 | ((cp >> 12) & 0x3F));
|
|
968
|
+
out->value.string_value[o++] = (char)(0x80 | ((cp >> 6) & 0x3F));
|
|
969
|
+
out->value.string_value[o++] = (char)(0x80 | (cp & 0x3F));
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
free_items(items, cnt);
|
|
973
|
+
return out;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
static int uri_escape(char* dst, const char* s, int keep_delims) {
|
|
977
|
+
static const char* hex = "0123456789ABCDEF";
|
|
978
|
+
size_t o = 0;
|
|
979
|
+
for (const unsigned char* p = (const unsigned char*)s; *p; p++) {
|
|
980
|
+
unsigned char c = *p;
|
|
981
|
+
int unres = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
|
|
982
|
+
(c >= '0' && c <= '9') || c == '-' || c == '.' ||
|
|
983
|
+
c == '_' || c == '~';
|
|
984
|
+
int extra = keep_delims && (strchr(";/?:@&=+$,[]-._~!'()*%", c) != NULL);
|
|
985
|
+
if (unres || extra) {
|
|
986
|
+
dst[o++] = (char)c;
|
|
987
|
+
} else {
|
|
988
|
+
dst[o++] = '%';
|
|
989
|
+
dst[o++] = hex[c >> 4];
|
|
990
|
+
dst[o++] = hex[c & 15];
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
dst[o] = 0;
|
|
994
|
+
return (int)o;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
static struct leptris_xpath_result* fn_uri_escape(XPathContext* ctx,
|
|
998
|
+
XPathASTNode** args, size_t n, int keep) {
|
|
999
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
1000
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
1001
|
+
if (!out) { free(in); return NULL; }
|
|
1002
|
+
out->value.string_value = (char*)calloc(strlen(in ? in : "") * 3 + 1, 1);
|
|
1003
|
+
if (in) uri_escape(out->value.string_value, in, keep);
|
|
1004
|
+
free(in);
|
|
1005
|
+
(void)n;
|
|
1006
|
+
return out;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
static struct leptris_xpath_result* fn_encode_for_uri(XPathContext* c,
|
|
1010
|
+
XPathASTNode** a, size_t n) { return fn_uri_escape(c, a, n, 0); }
|
|
1011
|
+
static struct leptris_xpath_result* fn_iri_to_uri(XPathContext* c,
|
|
1012
|
+
XPathASTNode** a, size_t n) { return fn_uri_escape(c, a, n, 1); }
|
|
1013
|
+
|
|
1014
|
+
static struct leptris_xpath_result* fn_escape_html_uri(XPathContext* ctx,
|
|
1015
|
+
XPathASTNode** args, size_t n) {
|
|
1016
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
1017
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
1018
|
+
if (!out) { free(in); return NULL; }
|
|
1019
|
+
size_t cap = (in ? strlen(in) : 0) * 6 + 1;
|
|
1020
|
+
out->value.string_value = (char*)calloc(cap, 1);
|
|
1021
|
+
size_t o = 0;
|
|
1022
|
+
if (in)
|
|
1023
|
+
for (const char* p = in; *p; p++) {
|
|
1024
|
+
unsigned char c = (unsigned char)*p;
|
|
1025
|
+
if (c < 0x80 && !isalnum(c) && !strchr("-_.~", c)) {
|
|
1026
|
+
const char* ent = c == '<' ? "<" : c == '>' ? ">" :
|
|
1027
|
+
c == '&' ? "&" : c == '"' ? """ :
|
|
1028
|
+
c == '\'' ? "'" : NULL;
|
|
1029
|
+
if (ent) { strcpy(out->value.string_value + o, ent); o += strlen(ent); continue; }
|
|
1030
|
+
}
|
|
1031
|
+
if (c < 0x80 && (isalnum(c) || strchr("-_.~", c)))
|
|
1032
|
+
out->value.string_value[o++] = (char)c;
|
|
1033
|
+
else
|
|
1034
|
+
out->value.string_value[o++] = (char)c; /* non-ASCII kept */
|
|
1035
|
+
}
|
|
1036
|
+
free(in);
|
|
1037
|
+
(void)n;
|
|
1038
|
+
return out;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/* QName family — value-level string representation ("prefix:local").
|
|
1042
|
+
* The namespace URI rides a thread-local side channel set by the
|
|
1043
|
+
* QName() constructor (a structured QName value lands with
|
|
1044
|
+
* TODO.xslt-full/07 function items). */
|
|
1045
|
+
#ifdef _WIN32
|
|
1046
|
+
#define LEPTRIS_TLS __declspec(thread)
|
|
1047
|
+
#else
|
|
1048
|
+
#define LEPTRIS_TLS __thread
|
|
1049
|
+
#endif
|
|
1050
|
+
static LEPTRIS_TLS char last_qname_uri[512];
|
|
1051
|
+
static struct leptris_xpath_result* fn_qname(XPathContext* ctx,
|
|
1052
|
+
XPathASTNode** args, size_t n) {
|
|
1053
|
+
char* uri = re_str_arg(ctx, args, 0);
|
|
1054
|
+
char* qn = re_str_arg(ctx, args, 1);
|
|
1055
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
1056
|
+
if (!out) { free(uri); free(qn); return NULL; }
|
|
1057
|
+
out->value.string_value = leptris_strdup(qn ? qn : "");
|
|
1058
|
+
snprintf(last_qname_uri, sizeof(last_qname_uri), "%s", uri ? uri : "");
|
|
1059
|
+
free(uri); free(qn);
|
|
1060
|
+
(void)n;
|
|
1061
|
+
return out;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
static struct leptris_xpath_result* fn_qname_part(XPathContext* ctx,
|
|
1065
|
+
XPathASTNode** args, size_t n, int which) {
|
|
1066
|
+
char* qn = re_str_arg(ctx, args, 0);
|
|
1067
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
1068
|
+
if (!out) { free(qn); return NULL; }
|
|
1069
|
+
const char* colon = qn ? strchr(qn, ':') : NULL;
|
|
1070
|
+
if (which == 1) /* local */
|
|
1071
|
+
out->value.string_value = leptris_strdup(colon ? colon + 1 : (qn ? qn : ""));
|
|
1072
|
+
else if (which == 2) { /* prefix */
|
|
1073
|
+
if (colon) {
|
|
1074
|
+
size_t pl = (size_t)(colon - qn);
|
|
1075
|
+
char* p = (char*)malloc(pl + 1);
|
|
1076
|
+
memcpy(p, qn, pl); p[pl] = 0;
|
|
1077
|
+
out->value.string_value = p;
|
|
1078
|
+
} else
|
|
1079
|
+
out->value.string_value = leptris_strdup("");
|
|
1080
|
+
} else /* namespace uri — from the 2-arg form only */
|
|
1081
|
+
out->value.string_value = leptris_strdup(last_qname_uri);
|
|
1082
|
+
free(qn);
|
|
1083
|
+
(void)n;
|
|
1084
|
+
return out;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
static struct leptris_xpath_result* fn_local_from_qname(XPathContext* c,
|
|
1088
|
+
XPathASTNode** a, size_t n) { return fn_qname_part(c, a, n, 1); }
|
|
1089
|
+
static struct leptris_xpath_result* fn_prefix_from_qname(XPathContext* c,
|
|
1090
|
+
XPathASTNode** a, size_t n) { return fn_qname_part(c, a, n, 2); }
|
|
1091
|
+
static struct leptris_xpath_result* fn_ns_from_qname(XPathContext* c,
|
|
1092
|
+
XPathASTNode** a, size_t n) { return fn_qname_part(c, a, n, 3); }
|
|
1093
|
+
|
|
1094
|
+
static struct leptris_xpath_result* fn_node_name(XPathContext* ctx,
|
|
1095
|
+
XPathASTNode** args, size_t n) {
|
|
1096
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
1097
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
1098
|
+
if (!out) { if (r) leptris_xpath_result_free(r); return NULL; }
|
|
1099
|
+
if (r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value &&
|
|
1100
|
+
r->value.nodeset_value->count) {
|
|
1101
|
+
void* nd = r->value.nodeset_value->nodes[0];
|
|
1102
|
+
if (leptris_node_get_type(nd) == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
1103
|
+
const char* nm = leptris_element_get_name((LeptrisElement)nd);
|
|
1104
|
+
out->value.string_value = leptris_strdup(nm ? nm : "");
|
|
1105
|
+
} else {
|
|
1106
|
+
out->value.string_value = leptris_strdup("");
|
|
1107
|
+
}
|
|
1108
|
+
} else {
|
|
1109
|
+
out->value.string_value = leptris_strdup("");
|
|
1110
|
+
}
|
|
1111
|
+
if (r) leptris_xpath_result_free(r);
|
|
1112
|
+
(void)n;
|
|
1113
|
+
return out;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
/* ---- dates & durations (TODO.xslt-full/05, first slice) ----
|
|
1118
|
+
* Value-level: constructors validate the lexical form lightly and
|
|
1119
|
+
* pass it through; extractors parse ISO 8601 fields. */
|
|
1120
|
+
|
|
1121
|
+
#include <time.h>
|
|
1122
|
+
|
|
1123
|
+
/* fn:doc(uri) — parse the file, return its root as a nodeset
|
|
1124
|
+
* (TODO.xslt-full/11). The document anchors on the eval context
|
|
1125
|
+
* (XPathContext.owned_docs): the nodeset borrows the root element,
|
|
1126
|
+
* so the doc must outlive the result — cleanup frees the anchors. */
|
|
1127
|
+
#include "../dom/document_node.h"
|
|
1128
|
+
static struct leptris_xpath_result* xq_anchor_owned_doc(
|
|
1129
|
+
XPathContext* ctx, struct leptris_document* doc, int fragment);
|
|
1130
|
+
static struct leptris_xpath_result* fn_doc(XPathContext* ctx,
|
|
1131
|
+
XPathASTNode** args, size_t n) {
|
|
1132
|
+
(void)n;
|
|
1133
|
+
char* path = re_str_arg(ctx, args, 0);
|
|
1134
|
+
if (!path) return NULL;
|
|
1135
|
+
LeptrisDocument doc = leptris_parse_file(path, NULL);
|
|
1136
|
+
free(path);
|
|
1137
|
+
if (!doc) {
|
|
1138
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
1139
|
+
"doc(): cannot load document");
|
|
1140
|
+
snprintf(ctx->error_code, sizeof(ctx->error_code),
|
|
1141
|
+
"FODC0002");
|
|
1142
|
+
return NULL;
|
|
1143
|
+
}
|
|
1144
|
+
LeptrisElement root = leptris_document_root(doc);
|
|
1145
|
+
if (!root) {
|
|
1146
|
+
leptris_document_free(doc);
|
|
1147
|
+
return NULL;
|
|
1148
|
+
}
|
|
1149
|
+
struct leptris_xpath_result* out =
|
|
1150
|
+
xq_anchor_owned_doc(ctx, doc, 0);
|
|
1151
|
+
if (!out) leptris_document_free(doc);
|
|
1152
|
+
return out;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/* Anchor a caller-parsed document on the context's owned chain and
|
|
1156
|
+
* return its DOCUMENT NODE (XQuery: parse-xml and
|
|
1157
|
+
* parse-xml-fragment yield a document node, so /root and
|
|
1158
|
+
* absolute paths step from the document level, #692). fragment==1 additionally SPLICES
|
|
1159
|
+
* the wrapper's children to the document level (root = first
|
|
1160
|
+
* element, doc-children = the fragment chain) so absolute
|
|
1161
|
+
* paths hit the fragment nodes. The nodeset borrows; cleanup frees the document
|
|
1162
|
+
* with the context. */
|
|
1163
|
+
static struct leptris_xpath_result* xq_anchor_owned_doc(
|
|
1164
|
+
XPathContext* ctx, struct leptris_document* doc, int fragment) {
|
|
1165
|
+
if (fragment) {
|
|
1166
|
+
LeptrisElement wrap = leptris_document_root(doc);
|
|
1167
|
+
if (wrap) {
|
|
1168
|
+
LeptrisNodeRef c = leptris_node_first_child(
|
|
1169
|
+
leptris_element_as_node(wrap));
|
|
1170
|
+
LeptrisElement first_elem = NULL;
|
|
1171
|
+
LeptrisNodeRef last = NULL;
|
|
1172
|
+
while (c) {
|
|
1173
|
+
LeptrisNodeRef next = leptris_node_get_next_sibling(c);
|
|
1174
|
+
if (leptris_node_get_type(c) == LEPTRIS_NODE_TYPE_ELEMENT &&
|
|
1175
|
+
!first_elem)
|
|
1176
|
+
first_elem = (LeptrisElement)c;
|
|
1177
|
+
if (!last) doc->doc_children_head = c;
|
|
1178
|
+
else leptris_node_set_next_sibling(last, c);
|
|
1179
|
+
last = c;
|
|
1180
|
+
c = next;
|
|
1181
|
+
}
|
|
1182
|
+
doc->doc_children_tail = last;
|
|
1183
|
+
doc->new_dom_root = first_elem;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
if (ctx->n_owned_docs == ctx->cap_owned_docs) {
|
|
1187
|
+
ctx->cap_owned_docs = ctx->cap_owned_docs
|
|
1188
|
+
? ctx->cap_owned_docs * 2 : 4;
|
|
1189
|
+
ctx->owned_docs = (struct leptris_document**)realloc(
|
|
1190
|
+
ctx->owned_docs,
|
|
1191
|
+
ctx->cap_owned_docs * sizeof(struct leptris_document*));
|
|
1192
|
+
if (!ctx->owned_docs) return NULL;
|
|
1193
|
+
}
|
|
1194
|
+
ctx->owned_docs[ctx->n_owned_docs++] = doc;
|
|
1195
|
+
LeptrisNode* dn = leptris_document_get_node(doc);
|
|
1196
|
+
if (!dn) return NULL;
|
|
1197
|
+
struct leptris_xpath_result* out =
|
|
1198
|
+
xpath_result_new(XPATH_RESULT_NODESET);
|
|
1199
|
+
if (!out) return NULL;
|
|
1200
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
1201
|
+
if (!out->value.nodeset_value) {
|
|
1202
|
+
xpath_result_free(out);
|
|
1203
|
+
return NULL;
|
|
1204
|
+
}
|
|
1205
|
+
xpath_nodeset_add(out->value.nodeset_value, dn);
|
|
1206
|
+
return out;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/* fn:parse-xml (arg: XML string) -> document node sequence (#692).
|
|
1210
|
+
* Owned-doc anchored, like doc(). */
|
|
1211
|
+
static struct leptris_xpath_result* fn_parse_xml(
|
|
1212
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
1213
|
+
(void)n;
|
|
1214
|
+
char* src = re_str_arg(ctx, args, 0);
|
|
1215
|
+
if (!src) return NULL;
|
|
1216
|
+
LeptrisDocument doc = leptris_parse_string(src, strlen(src), NULL);
|
|
1217
|
+
free(src);
|
|
1218
|
+
if (!doc) {
|
|
1219
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
1220
|
+
"parse-xml(): invalid XML");
|
|
1221
|
+
snprintf(ctx->error_code, sizeof(ctx->error_code), "FODC0006");
|
|
1222
|
+
return NULL;
|
|
1223
|
+
}
|
|
1224
|
+
return xq_anchor_owned_doc(ctx, doc, 0);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
/* fn:parse-xml-fragment: multiple top-level nodes are legal — the
|
|
1228
|
+
* input is wrapped, and the returned sequence is the wrapper's
|
|
1229
|
+
* CHILDREN (borrowed; the owned doc anchors them). */
|
|
1230
|
+
static struct leptris_xpath_result* fn_parse_xml_fragment(
|
|
1231
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
1232
|
+
(void)n;
|
|
1233
|
+
char* src = re_str_arg(ctx, args, 0);
|
|
1234
|
+
if (!src) return NULL;
|
|
1235
|
+
size_t sl = strlen(src);
|
|
1236
|
+
const char* wrap_open = "<leptris:frag xmlns:leptris='urn:leptris:frag'>";
|
|
1237
|
+
const char* wrap_close = "</leptris:frag>";
|
|
1238
|
+
size_t ol = strlen(wrap_open), cl = strlen(wrap_close);
|
|
1239
|
+
char* wrapped = (char*)malloc(sl + ol + cl + 1);
|
|
1240
|
+
if (!wrapped) { free(src); return NULL; }
|
|
1241
|
+
memcpy(wrapped, wrap_open, ol);
|
|
1242
|
+
memcpy(wrapped + ol, src, sl);
|
|
1243
|
+
free(src);
|
|
1244
|
+
memcpy(wrapped + ol + sl, wrap_close, cl);
|
|
1245
|
+
wrapped[ol + sl + cl] = 0;
|
|
1246
|
+
LeptrisDocument doc = leptris_parse_string(wrapped, ol + sl + cl, NULL);
|
|
1247
|
+
free(wrapped);
|
|
1248
|
+
if (!doc) {
|
|
1249
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
1250
|
+
"parse-xml-fragment(): invalid XML");
|
|
1251
|
+
snprintf(ctx->error_code, sizeof(ctx->error_code), "FODC0006");
|
|
1252
|
+
return NULL;
|
|
1253
|
+
}
|
|
1254
|
+
return xq_anchor_owned_doc(ctx, doc, 1);
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
static struct leptris_xpath_result* fn_passthrough_ctor(XPathContext* ctx,
|
|
1258
|
+
XPathASTNode** args, size_t n) {
|
|
1259
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
1260
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
1261
|
+
if (!out) { free(in); return NULL; }
|
|
1262
|
+
out->value.string_value = in ? in : leptris_strdup("");
|
|
1263
|
+
(void)n;
|
|
1264
|
+
return out;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/* Extract an integer field from an ISO date/dateTime/time/duration
|
|
1268
|
+
* string. which: 1 year 2 month 3 day 4 hours 5 minutes
|
|
1269
|
+
* 6 seconds 7 duration-days 8 duration-hours. */
|
|
1270
|
+
static struct leptris_xpath_result* fn_date_field(XPathContext* ctx,
|
|
1271
|
+
XPathASTNode** args, size_t n, int which) {
|
|
1272
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
1273
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
1274
|
+
if (!out) { free(in); return NULL; }
|
|
1275
|
+
long v = 0;
|
|
1276
|
+
if (in) {
|
|
1277
|
+
int y = 0, mo = 0, d = 0, h = 0, mi = 0;
|
|
1278
|
+
double se = 0;
|
|
1279
|
+
const char* t = strstr(in, "T");
|
|
1280
|
+
long dd = 0, dh = 0, dm = 0;
|
|
1281
|
+
double dsec = 0;
|
|
1282
|
+
if (in[0] == 'P' || (in[0] == '-' && in[1] == 'P')) {
|
|
1283
|
+
/* ISO 8601 duration P[nY][nM][nD][T[nH][nM][nS]]: 'M'
|
|
1284
|
+
* means months before T, minutes after. */
|
|
1285
|
+
const char* q = in + (in[0] == '-' ? 1 : 0) + 1;
|
|
1286
|
+
int in_time = 0;
|
|
1287
|
+
while (*q) {
|
|
1288
|
+
if (*q == 'T') { in_time = 1; q++; continue; }
|
|
1289
|
+
char* end = NULL;
|
|
1290
|
+
double num = strtod(q, &end);
|
|
1291
|
+
if (end == q) break;
|
|
1292
|
+
char unit = *end;
|
|
1293
|
+
if (!in_time) {
|
|
1294
|
+
if (unit == 'D') dd = (long)num;
|
|
1295
|
+
} else {
|
|
1296
|
+
if (unit == 'H') dh = (long)num;
|
|
1297
|
+
else if (unit == 'M') dm = (long)num;
|
|
1298
|
+
else if (unit == 'S') dsec = num;
|
|
1299
|
+
}
|
|
1300
|
+
q = end + 1;
|
|
1301
|
+
}
|
|
1302
|
+
v = (which == 7) ? dd : (which == 8) ? dh
|
|
1303
|
+
: (which == 9) ? dm : (which == 10) ? (long)dsec : 0;
|
|
1304
|
+
if (in[0] == '-') v = -v;
|
|
1305
|
+
} else if (sscanf(in, "%d-%d-%d", &y, &mo, &d) == 3) {
|
|
1306
|
+
if (t) sscanf(t, "T%d:%d:%lf", &h, &mi, &se);
|
|
1307
|
+
else sscanf(in, "%*d-%*d-%*dT%d:%d:%lf", &h, &mi, &se);
|
|
1308
|
+
v = (which == 1) ? y : (which == 2) ? mo : (which == 3) ? d
|
|
1309
|
+
: (which == 4) ? h : (which == 5) ? mi : (which == 6)
|
|
1310
|
+
? (long)se : 0;
|
|
1311
|
+
} else if (sscanf(in, "%d:%d:%lf", &h, &mi, &se) == 3) {
|
|
1312
|
+
v = (which == 4) ? h : (which == 5) ? mi
|
|
1313
|
+
: (which == 6) ? (long)se : 0;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
out->value.number_value = (double)v;
|
|
1317
|
+
free(in);
|
|
1318
|
+
(void)n;
|
|
1319
|
+
return out;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
#define DATE_FIELD(NAME, WHICH) \
|
|
1323
|
+
static struct leptris_xpath_result* fn_##NAME( \
|
|
1324
|
+
XPathContext* ctx, XPathASTNode** a, size_t n) { \
|
|
1325
|
+
return fn_date_field(ctx, a, n, WHICH); \
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
DATE_FIELD(year_from_dt, 1)
|
|
1329
|
+
DATE_FIELD(month_from_dt, 2)
|
|
1330
|
+
DATE_FIELD(day_from_dt, 3)
|
|
1331
|
+
DATE_FIELD(hours_from_t, 4)
|
|
1332
|
+
DATE_FIELD(minutes_from_t, 5)
|
|
1333
|
+
DATE_FIELD(seconds_from_t, 6)
|
|
1334
|
+
DATE_FIELD(days_from_dur, 7)
|
|
1335
|
+
DATE_FIELD(hours_from_dur, 8)
|
|
1336
|
+
DATE_FIELD(minutes_from_dur, 9)
|
|
1337
|
+
DATE_FIELD(seconds_from_dur, 10)
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
/* ---- Lane 05 tail: timezone model + current-* + format-date
|
|
1342
|
+
* family (2026-09-09). Lexical value model: the date/time values
|
|
1343
|
+
* are ISO strings; adjust-* does real instant math via the civil
|
|
1344
|
+
* days algorithm; implicit timezone is fixed UTC (Saxon-HE
|
|
1345
|
+
* parity needs implicit TZ only). ---- */
|
|
1346
|
+
|
|
1347
|
+
static long h_days_from_civil(int y, int m, int d) {
|
|
1348
|
+
y -= m <= 2;
|
|
1349
|
+
long era = (y >= 0 ? y : y - 399) / 400;
|
|
1350
|
+
unsigned yoe = (unsigned)(y - era * 400);
|
|
1351
|
+
unsigned doy = (unsigned)((153 * (m + (m > 2 ? -3 : 9)) + 2) / 5 +
|
|
1352
|
+
d - 1);
|
|
1353
|
+
unsigned doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
|
|
1354
|
+
return era * 146097L + (long)doe - 719468L;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
static void h_civil_from_days(long z, int* y, int* m, int* d) {
|
|
1358
|
+
z += 719468L;
|
|
1359
|
+
long era = (z >= 0 ? z : z - 146096) / 146097;
|
|
1360
|
+
unsigned doe = (unsigned)(z - era * 146097);
|
|
1361
|
+
unsigned yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
|
|
1362
|
+
long yy = (long)yoe + era * 400;
|
|
1363
|
+
unsigned doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
|
|
1364
|
+
unsigned mp = (5 * doy + 2) / 153;
|
|
1365
|
+
unsigned dd = doy - (153 * mp + 2) / 5 + 1;
|
|
1366
|
+
unsigned mm = mp + (mp < 10 ? 3 : -9);
|
|
1367
|
+
*y = (int)(yy + (mm <= 2));
|
|
1368
|
+
*m = (int)mm;
|
|
1369
|
+
*d = (int)dd;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/* Parse a lexical date/time: fields found set the out flags. */
|
|
1373
|
+
static int h_dt_parse(const char* in, int* y, int* mo, int* d,
|
|
1374
|
+
int* h, int* mi, double* se, long* off_min,
|
|
1375
|
+
int* has_off) {
|
|
1376
|
+
*y = *mo = *d = 0;
|
|
1377
|
+
*h = *mi = 0;
|
|
1378
|
+
*se = 0;
|
|
1379
|
+
*off_min = 0;
|
|
1380
|
+
*has_off = 0;
|
|
1381
|
+
const char* t = strstr(in, "T");
|
|
1382
|
+
if (sscanf(in, "%d-%d-%d", y, mo, d) == 3) {
|
|
1383
|
+
if (t) sscanf(t, "T%d:%d:%lf", h, mi, se);
|
|
1384
|
+
} else if (sscanf(in, "%d:%d:%lf", h, mi, se) != 3) {
|
|
1385
|
+
return 0;
|
|
1386
|
+
}
|
|
1387
|
+
const char* z = strrchr(in, 'Z');
|
|
1388
|
+
if (z && !isdigit((unsigned char)z[1])) {
|
|
1389
|
+
*has_off = 1;
|
|
1390
|
+
} else {
|
|
1391
|
+
const char* p = in;
|
|
1392
|
+
while (*p) {
|
|
1393
|
+
if (*p == 'T' || isdigit((unsigned char)*p) ||
|
|
1394
|
+
*p == '-' || *p == ':' || *p == '.') {
|
|
1395
|
+
p++;
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
break;
|
|
1399
|
+
}
|
|
1400
|
+
if ((*p == '+' || *p == '-') && strlen(p) >= 6 &&
|
|
1401
|
+
p[3] == ':') {
|
|
1402
|
+
int oh = 0, om = 0;
|
|
1403
|
+
if (sscanf(p + 1, "%d:%d", &oh, &om) == 2) {
|
|
1404
|
+
*off_min = (*p == '-') ? -(oh * 60 + om)
|
|
1405
|
+
: (oh * 60 + om);
|
|
1406
|
+
*has_off = 1;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
return 1;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
static void h_off_str(long off_min, char* buf, size_t cap) {
|
|
1414
|
+
if (off_min == 0) {
|
|
1415
|
+
snprintf(buf, cap, "Z");
|
|
1416
|
+
} else {
|
|
1417
|
+
snprintf(buf, cap, "%c%02ld:%02ld", off_min < 0 ? '-' : '+',
|
|
1418
|
+
labs(off_min) / 60, labs(off_min) % 60);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
/* Parse a dayTimeDuration lexical form to offset minutes (an
|
|
1423
|
+
* error returns LONG_MIN). */
|
|
1424
|
+
static long h_tz_duration_min(const char* in) {
|
|
1425
|
+
const char* q = in;
|
|
1426
|
+
int neg = 0;
|
|
1427
|
+
if (*q == '-') { neg = 1; q++; }
|
|
1428
|
+
if (*q != 'P') return LONG_MIN;
|
|
1429
|
+
q++;
|
|
1430
|
+
if (*q != 'T') return LONG_MIN;
|
|
1431
|
+
q++;
|
|
1432
|
+
long h = 0, m = 0;
|
|
1433
|
+
double sec = 0;
|
|
1434
|
+
while (*q) {
|
|
1435
|
+
char* end = NULL;
|
|
1436
|
+
double num = strtod(q, &end);
|
|
1437
|
+
if (end == q) return LONG_MIN;
|
|
1438
|
+
if (*end == 'H') h = (long)num;
|
|
1439
|
+
else if (*end == 'M') m = (long)num;
|
|
1440
|
+
else if (*end == 'S') sec = num;
|
|
1441
|
+
else return LONG_MIN;
|
|
1442
|
+
q = end + 1;
|
|
1443
|
+
}
|
|
1444
|
+
if (sec != 0) return LONG_MIN; /* offsets have no seconds */
|
|
1445
|
+
long total = h * 60 + m;
|
|
1446
|
+
if (total > 14 * 60) return LONG_MIN;
|
|
1447
|
+
return neg ? -total : total;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
#define ADJUST_TZ(NAME, WHICH) \
|
|
1451
|
+
static struct leptris_xpath_result* fn_##NAME( \
|
|
1452
|
+
XPathContext* ctx, XPathASTNode** a, size_t n) { \
|
|
1453
|
+
char* in = re_str_arg(ctx, a, 0); \
|
|
1454
|
+
struct leptris_xpath_result* out = \
|
|
1455
|
+
xpath_result_new(XPATH_RESULT_STRING); \
|
|
1456
|
+
if (!out) { free(in); return NULL; } \
|
|
1457
|
+
out->value.string_value = leptris_strdup(""); \
|
|
1458
|
+
if (!in) return out; \
|
|
1459
|
+
int y, mo, d, h, mi; \
|
|
1460
|
+
double se; \
|
|
1461
|
+
long off; \
|
|
1462
|
+
int has_off; \
|
|
1463
|
+
if (!h_dt_parse(in, &y, &mo, &d, &h, &mi, &se, &off, \
|
|
1464
|
+
&has_off)) { free(in); return out; } \
|
|
1465
|
+
long target = 0; \
|
|
1466
|
+
int remove = 0; \
|
|
1467
|
+
if (n >= 2) { \
|
|
1468
|
+
char* tzs = re_str_arg_opt(ctx, a, 1); \
|
|
1469
|
+
if (!tzs) { \
|
|
1470
|
+
remove = 1; \
|
|
1471
|
+
} else { \
|
|
1472
|
+
target = h_tz_duration_min(tzs); \
|
|
1473
|
+
free(tzs); \
|
|
1474
|
+
if (target == LONG_MIN) { free(in); return out; } \
|
|
1475
|
+
} \
|
|
1476
|
+
} \
|
|
1477
|
+
char buf[64]; \
|
|
1478
|
+
if (WHICH == 3) { \
|
|
1479
|
+
/* time: shift modulo the day */ \
|
|
1480
|
+
long tot = h * 3600L + mi * 60L + (long)se; \
|
|
1481
|
+
long shifted = tot + (target - off) * 60; \
|
|
1482
|
+
long day = shifted / 86400; \
|
|
1483
|
+
shifted %= 86400; \
|
|
1484
|
+
if (shifted < 0) { shifted += 86400; day--; } \
|
|
1485
|
+
(void)day; \
|
|
1486
|
+
if (remove) \
|
|
1487
|
+
snprintf(buf, sizeof buf, "%02d:%02d:%02d", \
|
|
1488
|
+
(int)(shifted / 3600), \
|
|
1489
|
+
(int)(shifted % 3600 / 60), \
|
|
1490
|
+
(int)(shifted % 60)); \
|
|
1491
|
+
else { \
|
|
1492
|
+
char ob[8]; \
|
|
1493
|
+
h_off_str(target, ob, sizeof ob); \
|
|
1494
|
+
snprintf(buf, sizeof buf, "%02d:%02d:%02d%s", \
|
|
1495
|
+
(int)(shifted / 3600), \
|
|
1496
|
+
(int)(shifted % 3600 / 60), \
|
|
1497
|
+
(int)(shifted % 60), ob); \
|
|
1498
|
+
} \
|
|
1499
|
+
} else { \
|
|
1500
|
+
/* date / dateTime: instant shift with day rollover */ \
|
|
1501
|
+
long days = (WHICH == 2 || strstr(in, "T") == NULL) \
|
|
1502
|
+
? h_days_from_civil(y, mo, d) \
|
|
1503
|
+
: h_days_from_civil(y, mo, d); \
|
|
1504
|
+
long base = days * 86400L + h * 3600L + mi * 60L + \
|
|
1505
|
+
(long)se - off * 60; \
|
|
1506
|
+
base += target * 60; \
|
|
1507
|
+
long nd = base / 86400; \
|
|
1508
|
+
long rem = base % 86400; \
|
|
1509
|
+
if (rem < 0) { rem += 86400; nd--; } \
|
|
1510
|
+
int ny, nm, ndd; \
|
|
1511
|
+
h_civil_from_days(nd, &ny, &nm, &ndd); \
|
|
1512
|
+
if (WHICH == 2 && !strstr(in, "T")) \
|
|
1513
|
+
snprintf(buf, sizeof buf, "%04d-%02d-%02d", \
|
|
1514
|
+
ny, nm, ndd); \
|
|
1515
|
+
else if (remove) \
|
|
1516
|
+
snprintf(buf, sizeof buf, \
|
|
1517
|
+
"%04d-%02d-%02dT%02d:%02d:%02d", \
|
|
1518
|
+
ny, nm, ndd, (int)(rem / 3600), \
|
|
1519
|
+
(int)(rem % 3600 / 60), (int)(rem % 60)); \
|
|
1520
|
+
else { \
|
|
1521
|
+
char ob[8]; \
|
|
1522
|
+
h_off_str(target, ob, sizeof ob); \
|
|
1523
|
+
snprintf(buf, sizeof buf, \
|
|
1524
|
+
"%04d-%02d-%02dT%02d:%02d:%02d%s", \
|
|
1525
|
+
ny, nm, ndd, (int)(rem / 3600), \
|
|
1526
|
+
(int)(rem % 3600 / 60), (int)(rem % 60), \
|
|
1527
|
+
ob); \
|
|
1528
|
+
} \
|
|
1529
|
+
} \
|
|
1530
|
+
free(out->value.string_value); \
|
|
1531
|
+
out->value.string_value = leptris_strdup(buf); \
|
|
1532
|
+
free(in); \
|
|
1533
|
+
return out; \
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
ADJUST_TZ(adjust_dttz, 1)
|
|
1537
|
+
ADJUST_TZ(adjust_dtetz, 2)
|
|
1538
|
+
ADJUST_TZ(adjust_ttz, 3)
|
|
1539
|
+
|
|
1540
|
+
static const char* const k_month_names[] = {
|
|
1541
|
+
"January", "February", "March", "April", "May", "June", "July",
|
|
1542
|
+
"August", "September", "October", "November", "December"};
|
|
1543
|
+
static const char* const k_day_names[] = {
|
|
1544
|
+
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
|
|
1545
|
+
"Friday", "Saturday"};
|
|
1546
|
+
|
|
1547
|
+
/* format-date/time/dateTime picture subset (XPath 3.1 9.7):
|
|
1548
|
+
* [Y|M|D|d|H|h|m|s] with numeric presentation modifiers (width
|
|
1549
|
+
* from the modifier digits, e.g. 01 / 0001), [MNn]/[DNn] names,
|
|
1550
|
+
* [Z] timezone offset. Unknown markers pass through verbatim. */
|
|
1551
|
+
#define FORMAT_DATE_FN(NAME, WHICH) \
|
|
1552
|
+
static struct leptris_xpath_result* fn_##NAME( \
|
|
1553
|
+
XPathContext* ctx, XPathASTNode** a, size_t n) { \
|
|
1554
|
+
char* in = re_str_arg(ctx, a, 0); \
|
|
1555
|
+
char* pic = re_str_arg(ctx, a, 1); \
|
|
1556
|
+
struct leptris_xpath_result* out = \
|
|
1557
|
+
xpath_result_new(XPATH_RESULT_STRING); \
|
|
1558
|
+
if (!out) { free(in); free(pic); return NULL; } \
|
|
1559
|
+
out->value.string_value = leptris_strdup(""); \
|
|
1560
|
+
int y, mo, d, h, mi; \
|
|
1561
|
+
double se; \
|
|
1562
|
+
long off; \
|
|
1563
|
+
int has_off; \
|
|
1564
|
+
if (!in || !pic || !h_dt_parse(in, &y, &mo, &d, &h, &mi, \
|
|
1565
|
+
&se, &off, &has_off)) { \
|
|
1566
|
+
free(in); free(pic); return out; \
|
|
1567
|
+
} \
|
|
1568
|
+
size_t rcap = strlen(pic) * 4 + 64; \
|
|
1569
|
+
char* res = (char*)calloc(rcap, 1); \
|
|
1570
|
+
size_t rl = 0; \
|
|
1571
|
+
for (const char* p = pic; *p;) { \
|
|
1572
|
+
int nw = 0; \
|
|
1573
|
+
if (*p != '[') { \
|
|
1574
|
+
nw = snprintf(res + rl, rcap - rl, "%c", *p); \
|
|
1575
|
+
p++; \
|
|
1576
|
+
} else { \
|
|
1577
|
+
const char* close = strchr(p, ']'); \
|
|
1578
|
+
if (!close) { \
|
|
1579
|
+
nw = snprintf(res + rl, rcap - rl, "%c", *p); \
|
|
1580
|
+
p++; \
|
|
1581
|
+
} else { \
|
|
1582
|
+
char mark[16]; \
|
|
1583
|
+
size_t ml = (size_t)(close - p - 1); \
|
|
1584
|
+
if (ml >= sizeof mark) ml = sizeof mark - 1; \
|
|
1585
|
+
memcpy(mark, p + 1, ml); \
|
|
1586
|
+
mark[ml] = 0; \
|
|
1587
|
+
p = close + 1; \
|
|
1588
|
+
const char* mod = mark + 1; \
|
|
1589
|
+
char letter = mark[0]; \
|
|
1590
|
+
int w = mod[0] ? (int)strlen(mod) : 1; \
|
|
1591
|
+
if (letter == 'Y') { \
|
|
1592
|
+
nw = snprintf(res + rl, rcap - rl, \
|
|
1593
|
+
"%0*d", w, y); \
|
|
1594
|
+
} else if (letter == 'M' && \
|
|
1595
|
+
strstr(mark, "Nn")) { \
|
|
1596
|
+
nw = snprintf(res + rl, rcap - rl, "%s", \
|
|
1597
|
+
k_month_names[mo >= 1 && \
|
|
1598
|
+
mo <= 12 ? mo - 1 : 0]); \
|
|
1599
|
+
} else if (letter == 'M') { \
|
|
1600
|
+
nw = snprintf(res + rl, rcap - rl, \
|
|
1601
|
+
"%0*d", w, mo); \
|
|
1602
|
+
} else if (letter == 'D' && \
|
|
1603
|
+
strstr(mark, "Nn")) { \
|
|
1604
|
+
long dse = h_days_from_civil(y, mo, d); \
|
|
1605
|
+
int dow = (int)(((dse % 7) + 7 + 4) % 7); \
|
|
1606
|
+
nw = snprintf(res + rl, rcap - rl, "%s", \
|
|
1607
|
+
k_day_names[dow]); \
|
|
1608
|
+
} else if (letter == 'D') { \
|
|
1609
|
+
nw = snprintf(res + rl, rcap - rl, \
|
|
1610
|
+
"%0*d", w, d); \
|
|
1611
|
+
} else if (letter == 'H') { \
|
|
1612
|
+
nw = snprintf(res + rl, rcap - rl, \
|
|
1613
|
+
"%0*d", w, h); \
|
|
1614
|
+
} else if (letter == 'h') { \
|
|
1615
|
+
int hh = h % 12; \
|
|
1616
|
+
if (hh == 0) hh = 12; \
|
|
1617
|
+
nw = snprintf(res + rl, rcap - rl, \
|
|
1618
|
+
"%0*d", w, hh); \
|
|
1619
|
+
} else if (letter == 'm') { \
|
|
1620
|
+
nw = snprintf(res + rl, rcap - rl, \
|
|
1621
|
+
"%0*d", w, mi); \
|
|
1622
|
+
} else if (letter == 's') { \
|
|
1623
|
+
nw = snprintf(res + rl, rcap - rl, \
|
|
1624
|
+
"%0*d", w, (int)se); \
|
|
1625
|
+
} else if (letter == 'Z') { \
|
|
1626
|
+
char ob[8]; \
|
|
1627
|
+
h_off_str(off, ob, sizeof ob); \
|
|
1628
|
+
nw = snprintf(res + rl, rcap - rl, "%s", ob); \
|
|
1629
|
+
} else { \
|
|
1630
|
+
nw = snprintf(res + rl, rcap - rl, \
|
|
1631
|
+
"[%s]", mark); \
|
|
1632
|
+
} \
|
|
1633
|
+
} \
|
|
1634
|
+
} \
|
|
1635
|
+
if (nw > 0 && rl + (size_t)nw < rcap) rl += (size_t)nw; \
|
|
1636
|
+
else if (rl + 1 < rcap) rl = rcap - 1; \
|
|
1637
|
+
} \
|
|
1638
|
+
res[rl] = 0; \
|
|
1639
|
+
free(out->value.string_value); \
|
|
1640
|
+
out->value.string_value = leptris_strdup(res); \
|
|
1641
|
+
free(res); \
|
|
1642
|
+
free(in); free(pic); \
|
|
1643
|
+
(void)n; \
|
|
1644
|
+
return out; \
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
FORMAT_DATE_FN(format_dttz, 1)
|
|
1648
|
+
FORMAT_DATE_FN(format_dtetz, 2)
|
|
1649
|
+
FORMAT_DATE_FN(format_ttz, 3)
|
|
1650
|
+
|
|
1651
|
+
/* current-* : UTC wall clock, Saxon lexical forms. */
|
|
1652
|
+
/* UTC wall clock, portable (MSVC has no gmtime_r). */
|
|
1653
|
+
static struct tm h_utc_now(void) {
|
|
1654
|
+
time_t now = time(NULL);
|
|
1655
|
+
struct tm tmv;
|
|
1656
|
+
#ifdef _WIN32
|
|
1657
|
+
gmtime_s(&tmv, &now);
|
|
1658
|
+
#else
|
|
1659
|
+
gmtime_r(&now, &tmv);
|
|
1660
|
+
#endif
|
|
1661
|
+
return tmv;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
#define CURRENT_FN(NAME, FORM) \
|
|
1665
|
+
static struct leptris_xpath_result* fn_##NAME( \
|
|
1666
|
+
XPathContext* ctx, XPathASTNode** a, size_t n) { \
|
|
1667
|
+
struct leptris_xpath_result* out = \
|
|
1668
|
+
xpath_result_new(XPATH_RESULT_STRING); \
|
|
1669
|
+
if (!out) return NULL; \
|
|
1670
|
+
struct tm tmv = h_utc_now(); \
|
|
1671
|
+
char buf[40]; \
|
|
1672
|
+
strftime(buf, sizeof buf, FORM, &tmv); \
|
|
1673
|
+
out->value.string_value = leptris_strdup(buf); \
|
|
1674
|
+
(void)ctx; (void)a; (void)n; \
|
|
1675
|
+
return out; \
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
CURRENT_FN(current_dt, "%Y-%m-%dT%H:%M:%SZ")
|
|
1679
|
+
CURRENT_FN(current_date, "%Y-%m-%dZ")
|
|
1680
|
+
CURRENT_FN(current_time, "%H:%M:%SZ")
|
|
1681
|
+
|
|
1682
|
+
static struct leptris_xpath_result* fn_implicit_tz(
|
|
1683
|
+
XPathContext* ctx, XPathASTNode** a, size_t n) {
|
|
1684
|
+
struct leptris_xpath_result* out =
|
|
1685
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
1686
|
+
if (!out) return NULL;
|
|
1687
|
+
out->value.string_value = leptris_strdup("PT0S");
|
|
1688
|
+
(void)ctx; (void)a; (void)n;
|
|
1689
|
+
return out;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
/* ---- xs: atomic constructors (TODO.xslt-full/06; Saxon-HE 12.7
|
|
1693
|
+
* ground truth banked /tmp/probe9/g6.xsl) ---- value-level casts:
|
|
1694
|
+
* the numeric family converts through number() with xs:integer
|
|
1695
|
+
* truncating toward zero; xs:boolean follows the XPath boolean()
|
|
1696
|
+
* rules; xs:string/xs:anyURI take the string value (the same shape
|
|
1697
|
+
* as the date passthrough constructors above). */
|
|
1698
|
+
|
|
1699
|
+
static struct leptris_xpath_result* fn_xs_number_ctor(XPathContext* ctx,
|
|
1700
|
+
XPathASTNode** args, size_t n, int integer_only) {
|
|
1701
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
1702
|
+
if (!r) return NULL;
|
|
1703
|
+
double d;
|
|
1704
|
+
if (r->type == XPATH_RESULT_STRING) {
|
|
1705
|
+
/* XSD lexical form (#739): leading/trailing whitespace is
|
|
1706
|
+
* allowed, the rest must convert whole — a silent NaN on
|
|
1707
|
+
* invalid input is the silent-wrong class. */
|
|
1708
|
+
const char* s = r->value.string_value ? r->value.string_value
|
|
1709
|
+
: "";
|
|
1710
|
+
while (isspace((unsigned char)*s)) s++;
|
|
1711
|
+
const char* e = s + strlen(s);
|
|
1712
|
+
while (e > s && isspace((unsigned char)e[-1])) e--;
|
|
1713
|
+
size_t len = (size_t)(e - s);
|
|
1714
|
+
int bad = (!len || len >= 120);
|
|
1715
|
+
char buf[120];
|
|
1716
|
+
if (!bad) {
|
|
1717
|
+
memcpy(buf, s, len);
|
|
1718
|
+
buf[len] = 0;
|
|
1719
|
+
if (integer_only) {
|
|
1720
|
+
const char* p = (buf[0] == '+' || buf[0] == '-')
|
|
1721
|
+
? buf + 1 : buf;
|
|
1722
|
+
bad = !*p || strspn(p, "0123456789") != strlen(p);
|
|
1723
|
+
} else {
|
|
1724
|
+
char* endp = NULL;
|
|
1725
|
+
d = strtod(buf, &endp);
|
|
1726
|
+
bad = !endp || *endp;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
if (bad) {
|
|
1730
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
1731
|
+
"Invalid lexical form for xs:%s",
|
|
1732
|
+
integer_only ? "integer" : "double");
|
|
1733
|
+
leptris_xpath_result_free(r);
|
|
1734
|
+
return NULL;
|
|
1735
|
+
}
|
|
1736
|
+
if (integer_only) {
|
|
1737
|
+
/* int64 fidelity: keep the exact lexical value — a
|
|
1738
|
+
* double roundtrip collapses 999999999999999999 to
|
|
1739
|
+
* 1e+18. Out-of-range lexicals demote to double. */
|
|
1740
|
+
errno = 0;
|
|
1741
|
+
char* endp = NULL;
|
|
1742
|
+
long long iv = strtoll(buf, &endp, 10);
|
|
1743
|
+
if (!errno && endp && !*endp) {
|
|
1744
|
+
leptris_xpath_result_free(r);
|
|
1745
|
+
struct leptris_xpath_result* out =
|
|
1746
|
+
xpath_result_new(XPATH_RESULT_NUMBER);
|
|
1747
|
+
if (!out) return NULL;
|
|
1748
|
+
out->value.number_value = (double)iv;
|
|
1749
|
+
out->is_int = 1;
|
|
1750
|
+
out->int_value = iv;
|
|
1751
|
+
(void)n;
|
|
1752
|
+
return out;
|
|
1753
|
+
}
|
|
1754
|
+
d = strtod(buf, NULL);
|
|
1755
|
+
}
|
|
1756
|
+
} else {
|
|
1757
|
+
d = leptris_xpath_result_number(r);
|
|
1758
|
+
if (integer_only) {
|
|
1759
|
+
d = (d < 0) ? ceil(d) : floor(d);
|
|
1760
|
+
if (d >= -9.2233720368547758e18 &&
|
|
1761
|
+
d <= 9.2233720368547758e18 && d == (double)(long long)d) {
|
|
1762
|
+
long long iv = (long long)d;
|
|
1763
|
+
leptris_xpath_result_free(r);
|
|
1764
|
+
struct leptris_xpath_result* out =
|
|
1765
|
+
xpath_result_new(XPATH_RESULT_NUMBER);
|
|
1766
|
+
if (!out) return NULL;
|
|
1767
|
+
out->value.number_value = d;
|
|
1768
|
+
out->is_int = 1;
|
|
1769
|
+
out->int_value = iv;
|
|
1770
|
+
(void)n;
|
|
1771
|
+
return out;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
leptris_xpath_result_free(r);
|
|
1776
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
1777
|
+
if (!out) return NULL;
|
|
1778
|
+
out->value.number_value = d;
|
|
1779
|
+
(void)n;
|
|
1780
|
+
return out;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
static struct leptris_xpath_result* fn_xs_integer(XPathContext* ctx,
|
|
1784
|
+
XPathASTNode** a, size_t n) {
|
|
1785
|
+
return fn_xs_number_ctor(ctx, a, n, 1);
|
|
1786
|
+
}
|
|
1787
|
+
static struct leptris_xpath_result* fn_xs_double(XPathContext* ctx,
|
|
1788
|
+
XPathASTNode** a, size_t n) {
|
|
1789
|
+
return fn_xs_number_ctor(ctx, a, n, 0);
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
/* ---- integer-subtype constructors (QT3 fn/concat): the same
|
|
1793
|
+
* int64 fidelity as xs:integer, each with its type bounds.
|
|
1794
|
+
* xs:unsignedLong is int64-backed — literals beyond LLONG_MAX
|
|
1795
|
+
* are out of range (documented boundary). ---- */
|
|
1796
|
+
static struct leptris_xpath_result* xs_int_bound(
|
|
1797
|
+
XPathContext* ctx, XPathASTNode** args, size_t n,
|
|
1798
|
+
long long lo, long long hi, const char* tname) {
|
|
1799
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
1800
|
+
if (!r) return NULL;
|
|
1801
|
+
long long iv = 0;
|
|
1802
|
+
int have = 0;
|
|
1803
|
+
if (r->type == XPATH_RESULT_STRING) {
|
|
1804
|
+
const char* s = r->value.string_value ? r->value.string_value
|
|
1805
|
+
: "";
|
|
1806
|
+
while (isspace((unsigned char)*s)) s++;
|
|
1807
|
+
const char* e = s + strlen(s);
|
|
1808
|
+
while (e > s && isspace((unsigned char)e[-1])) e--;
|
|
1809
|
+
const char* p = (s < e && (*s == '+' || *s == '-')) ? s + 1 : s;
|
|
1810
|
+
if (e > p && strspn(p, "0123456789") == (size_t)(e - p) &&
|
|
1811
|
+
(size_t)(e - s) < 40) {
|
|
1812
|
+
char buf[40];
|
|
1813
|
+
memcpy(buf, s, (size_t)(e - s));
|
|
1814
|
+
buf[e - s] = 0;
|
|
1815
|
+
errno = 0;
|
|
1816
|
+
char* endp = NULL;
|
|
1817
|
+
iv = strtoll(buf, &endp, 10);
|
|
1818
|
+
have = !errno && endp && !*endp;
|
|
1819
|
+
}
|
|
1820
|
+
if (!have) {
|
|
1821
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
1822
|
+
"Invalid lexical form for %s", tname);
|
|
1823
|
+
leptris_xpath_result_free(r);
|
|
1824
|
+
return NULL;
|
|
1825
|
+
}
|
|
1826
|
+
} else {
|
|
1827
|
+
double d = leptris_xpath_result_number(r);
|
|
1828
|
+
d = (d < 0) ? ceil(d) : floor(d);
|
|
1829
|
+
if (d >= -9.2233720368547758e18 &&
|
|
1830
|
+
d <= 9.2233720368547758e18 && d == (double)(long long)d) {
|
|
1831
|
+
iv = (long long)d;
|
|
1832
|
+
have = 1;
|
|
1833
|
+
} else {
|
|
1834
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
1835
|
+
"Value out of range for %s", tname);
|
|
1836
|
+
leptris_xpath_result_free(r);
|
|
1837
|
+
return NULL;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
leptris_xpath_result_free(r);
|
|
1841
|
+
if (iv < lo || iv > hi) {
|
|
1842
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
1843
|
+
"Value out of range for %s", tname);
|
|
1844
|
+
return NULL;
|
|
1845
|
+
}
|
|
1846
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
1847
|
+
if (!out) return NULL;
|
|
1848
|
+
out->value.number_value = (double)iv;
|
|
1849
|
+
out->is_int = 1;
|
|
1850
|
+
out->int_value = iv;
|
|
1851
|
+
(void)n;
|
|
1852
|
+
return out;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
#define XS_INT_SUB(FN, LO, HI, TNAME) \
|
|
1856
|
+
static struct leptris_xpath_result* FN( \
|
|
1857
|
+
XPathContext* ctx, XPathASTNode** a, size_t n) { \
|
|
1858
|
+
return xs_int_bound(ctx, a, n, LO, HI, TNAME); \
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
XS_INT_SUB(fn_xs_int, -2147483647LL - 1, 2147483647LL, "xs:int")
|
|
1862
|
+
XS_INT_SUB(fn_xs_long, LLONG_MIN, LLONG_MAX, "xs:long")
|
|
1863
|
+
XS_INT_SUB(fn_xs_short, -32768, 32767, "xs:short")
|
|
1864
|
+
XS_INT_SUB(fn_xs_ushort, 0, 65535, "xs:unsignedShort")
|
|
1865
|
+
XS_INT_SUB(fn_xs_ulong, 0, LLONG_MAX, "xs:unsignedLong")
|
|
1866
|
+
XS_INT_SUB(fn_xs_negint, LLONG_MIN, -1, "xs:negativeInteger")
|
|
1867
|
+
XS_INT_SUB(fn_xs_posint, 1, LLONG_MAX, "xs:positiveInteger")
|
|
1868
|
+
XS_INT_SUB(fn_xs_nonpos, LLONG_MIN, 0, "xs:nonPositiveInteger")
|
|
1869
|
+
XS_INT_SUB(fn_xs_nonneg, 0, LLONG_MAX, "xs:nonNegativeInteger")
|
|
1870
|
+
|
|
1871
|
+
/* xs:decimal: an all-integer lexical keeps int64 fidelity
|
|
1872
|
+
* (QT3 fn/concatdec2args); fractions ride the double ctor. */
|
|
1873
|
+
static struct leptris_xpath_result* fn_xs_decimal(XPathContext* ctx,
|
|
1874
|
+
XPathASTNode** a, size_t n) {
|
|
1875
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, a[0]);
|
|
1876
|
+
if (!r) return NULL;
|
|
1877
|
+
if (r->type == XPATH_RESULT_STRING) {
|
|
1878
|
+
const char* s = r->value.string_value ? r->value.string_value
|
|
1879
|
+
: "";
|
|
1880
|
+
while (isspace((unsigned char)*s)) s++;
|
|
1881
|
+
const char* e = s + strlen(s);
|
|
1882
|
+
while (e > s && isspace((unsigned char)e[-1])) e--;
|
|
1883
|
+
const char* p = (s < e && (*s == '+' || *s == '-')) ? s + 1 : s;
|
|
1884
|
+
int all_digits = e > p &&
|
|
1885
|
+
strspn(p, "0123456789") == (size_t)(e - p);
|
|
1886
|
+
leptris_xpath_result_free(r);
|
|
1887
|
+
if (all_digits)
|
|
1888
|
+
return xs_int_bound(ctx, a, n, LLONG_MIN, LLONG_MAX,
|
|
1889
|
+
"xs:decimal");
|
|
1890
|
+
} else {
|
|
1891
|
+
leptris_xpath_result_free(r);
|
|
1892
|
+
}
|
|
1893
|
+
return fn_xs_number_ctor(ctx, a, n, 0);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
static struct leptris_xpath_result* fn_xs_boolean(XPathContext* ctx,
|
|
1897
|
+
XPathASTNode** args, size_t n) {
|
|
1898
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
1899
|
+
if (!r) return NULL;
|
|
1900
|
+
int b = 0;
|
|
1901
|
+
if (r->type == XPATH_RESULT_NODESET)
|
|
1902
|
+
b = r->value.nodeset_value && r->value.nodeset_value->count > 0;
|
|
1903
|
+
else if (r->type == XPATH_RESULT_STRING) {
|
|
1904
|
+
/* XSD lexical mapping (#739): only true/1/false/0 (with
|
|
1905
|
+
* optional whitespace) cast from a string. */
|
|
1906
|
+
const char* s = r->value.string_value ? r->value.string_value
|
|
1907
|
+
: "";
|
|
1908
|
+
while (isspace((unsigned char)*s)) s++;
|
|
1909
|
+
const char* e = s + strlen(s);
|
|
1910
|
+
while (e > s && isspace((unsigned char)e[-1])) e--;
|
|
1911
|
+
size_t len = (size_t)(e - s);
|
|
1912
|
+
if ((len == 4 && strncmp(s, "true", 4) == 0) ||
|
|
1913
|
+
(len == 1 && *s == '1'))
|
|
1914
|
+
b = 1;
|
|
1915
|
+
else if ((len == 5 && strncmp(s, "false", 5) == 0) ||
|
|
1916
|
+
(len == 1 && *s == '0'))
|
|
1917
|
+
b = 0;
|
|
1918
|
+
else {
|
|
1919
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
1920
|
+
"Cannot cast '%s' to xs:boolean",
|
|
1921
|
+
r->value.string_value);
|
|
1922
|
+
leptris_xpath_result_free(r);
|
|
1923
|
+
return NULL;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
else if (r->type == XPATH_RESULT_BOOLEAN)
|
|
1927
|
+
b = r->value.boolean_value;
|
|
1928
|
+
else {
|
|
1929
|
+
double d = r->value.number_value;
|
|
1930
|
+
b = (d == d) && d != 0; /* NaN casts to false */
|
|
1931
|
+
}
|
|
1932
|
+
leptris_xpath_result_free(r);
|
|
1933
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
1934
|
+
if (out) out->value.boolean_value = b;
|
|
1935
|
+
(void)n;
|
|
1936
|
+
return out;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
/* ---- maps (TODO.xslt-full/08, first slice) ----
|
|
1940
|
+
* Value-level: a map is ONE synthetic text node whose content is
|
|
1941
|
+
* "\x03MAP" + per entry "\x02"key"\x01"value (insertion order) —
|
|
1942
|
+
* the XPATH_OP_MAP_CONSTRUCTOR encoding. Accessors decode here. */
|
|
1943
|
+
|
|
1944
|
+
extern XPathTextNode* xpath_synth_text(const char* content, size_t len);
|
|
1945
|
+
|
|
1946
|
+
/* Entry list + shared encoder — the ONE representation authority
|
|
1947
|
+
* for value-level maps (constructor, xsl:map, and the map:*
|
|
1948
|
+
* combiners all go through it). */
|
|
1949
|
+
typedef struct {
|
|
1950
|
+
char** k;
|
|
1951
|
+
char** v;
|
|
1952
|
+
size_t n, cap;
|
|
1953
|
+
} MapEntries;
|
|
1954
|
+
|
|
1955
|
+
static void map_entries_push(MapEntries* e, const char* k, size_t kn,
|
|
1956
|
+
const char* v, size_t vn) {
|
|
1957
|
+
if (e->n == e->cap) {
|
|
1958
|
+
e->cap = e->cap ? e->cap * 2 : 8;
|
|
1959
|
+
e->k = (char**)realloc(e->k, e->cap * sizeof(char*));
|
|
1960
|
+
e->v = (char**)realloc(e->v, e->cap * sizeof(char*));
|
|
1961
|
+
if (!e->k || !e->v) { e->n = 0; e->cap = 0; return; }
|
|
1962
|
+
}
|
|
1963
|
+
e->k[e->n] = LEPTRIS_ALLOC_N(char, kn + 1);
|
|
1964
|
+
e->v[e->n] = LEPTRIS_ALLOC_N(char, vn + 1);
|
|
1965
|
+
if (!e->k[e->n] || !e->v[e->n]) return;
|
|
1966
|
+
if (kn) memcpy(e->k[e->n], k, kn);
|
|
1967
|
+
e->k[e->n][kn] = '\0';
|
|
1968
|
+
if (vn) memcpy(e->v[e->n], v, vn);
|
|
1969
|
+
e->v[e->n][vn] = '\0';
|
|
1970
|
+
e->n++;
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
static void map_entries_free(MapEntries* e) {
|
|
1974
|
+
for (size_t i = 0; i < e->n; i++) {
|
|
1975
|
+
if (e->k) free(e->k[i]);
|
|
1976
|
+
if (e->v) free(e->v[i]);
|
|
1977
|
+
}
|
|
1978
|
+
free(e->k);
|
|
1979
|
+
free(e->v);
|
|
1980
|
+
e->k = e->v = NULL;
|
|
1981
|
+
e->n = e->cap = 0;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
/* Decode ONE map node's content (after the "\x03MAP" marker). */
|
|
1985
|
+
static void map_entries_decode(MapEntries* e, const char* p) {
|
|
1986
|
+
while (p && *p == '\x02') {
|
|
1987
|
+
const char* ke = strchr(p + 1, '\x01');
|
|
1988
|
+
if (!ke) break;
|
|
1989
|
+
const char* ve = ke + 1;
|
|
1990
|
+
const char* en = ve;
|
|
1991
|
+
while (*en && *en != '\x02') en++;
|
|
1992
|
+
map_entries_push(e, p + 1, (size_t)(ke - (p + 1)),
|
|
1993
|
+
ve, (size_t)(en - ve));
|
|
1994
|
+
p = en;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
/* Evaluate argument i into entries: a single map node, or a
|
|
1999
|
+
* sequence of map nodes (map:merge input). */
|
|
2000
|
+
static void map_entries_arg(XPathContext* ctx, XPathASTNode** args,
|
|
2001
|
+
size_t i, MapEntries* e) {
|
|
2002
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[i]);
|
|
2003
|
+
if (!r) return;
|
|
2004
|
+
if (r->type == XPATH_RESULT_NODESET && r->value.nodeset_value) {
|
|
2005
|
+
for (size_t i = 0; i < r->value.nodeset_value->count; i++) {
|
|
2006
|
+
XPathTextNode* tn =
|
|
2007
|
+
(XPathTextNode*)r->value.nodeset_value->nodes[i];
|
|
2008
|
+
if (tn && tn->content &&
|
|
2009
|
+
strncmp(tn->content, "\x03MAP", 4) == 0)
|
|
2010
|
+
map_entries_decode(e, tn->content + 4);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
leptris_xpath_result_free(r);
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
/* Encode entries into the map representation string ("\x03MAP" +
|
|
2017
|
+
* per entry "\x02"key"\x01"value). Returns malloc'd content. */
|
|
2018
|
+
char* xpath_map_encode(const MapEntries* e) {
|
|
2019
|
+
size_t cap = 32, len = 4;
|
|
2020
|
+
char* buf = (char*)malloc(cap);
|
|
2021
|
+
if (!buf) return NULL;
|
|
2022
|
+
memcpy(buf, "\x03MAP", 4);
|
|
2023
|
+
for (size_t i = 0; i < e->n; i++) {
|
|
2024
|
+
size_t kn = strlen(e->k[i]), vn = strlen(e->v[i]);
|
|
2025
|
+
while (len + kn + vn + 3 > cap) {
|
|
2026
|
+
cap *= 2;
|
|
2027
|
+
char* nb = (char*)realloc(buf, cap);
|
|
2028
|
+
if (!nb) { free(buf); return NULL; }
|
|
2029
|
+
buf = nb;
|
|
2030
|
+
}
|
|
2031
|
+
buf[len++] = '\x02';
|
|
2032
|
+
if (kn) { memcpy(buf + len, e->k[i], kn); len += kn; }
|
|
2033
|
+
buf[len++] = '\x01';
|
|
2034
|
+
if (vn) { memcpy(buf + len, e->v[i], vn); len += vn; }
|
|
2035
|
+
}
|
|
2036
|
+
buf[len] = '\0';
|
|
2037
|
+
return buf;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
/* Encode entries into the map VALUE (nodeset of one synthetic
|
|
2041
|
+
* text node) — the shape map:* results and xsl:map produce. */
|
|
2042
|
+
struct leptris_xpath_result* xpath_map_value(const MapEntries* e) {
|
|
2043
|
+
char* content = xpath_map_encode(e);
|
|
2044
|
+
if (!content) return NULL;
|
|
2045
|
+
XPathNodeSet* out = xpath_nodeset_new();
|
|
2046
|
+
if (!out) { free(content); return NULL; }
|
|
2047
|
+
out->owns_synthetic_text = 1;
|
|
2048
|
+
out->is_sequence = 1;
|
|
2049
|
+
XPathTextNode* tn = xpath_synth_text(content, strlen(content));
|
|
2050
|
+
free(content);
|
|
2051
|
+
if (!tn) { xpath_nodeset_free(out); return NULL; }
|
|
2052
|
+
xpath_nodeset_add(out, tn);
|
|
2053
|
+
struct leptris_xpath_result* r = xpath_result_new(XPATH_RESULT_NODESET);
|
|
2054
|
+
if (!r) { xpath_nodeset_free(out); return NULL; }
|
|
2055
|
+
r->value.nodeset_value = out;
|
|
2056
|
+
return r;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
/* Incremental builder over the shared representation — the XSLT
|
|
2060
|
+
* exec's xsl:map seam (entries arrive one instruction at a time). */
|
|
2061
|
+
void* xpath_map_builder_new(void) {
|
|
2062
|
+
MapEntries* e = (MapEntries*)calloc(1, sizeof(*e));
|
|
2063
|
+
return e;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
void xpath_map_builder_add(void* b, const char* k, const char* v) {
|
|
2067
|
+
MapEntries* e = (MapEntries*)b;
|
|
2068
|
+
if (!e || !k) return;
|
|
2069
|
+
map_entries_push(e, k, strlen(k), v ? v : "", v ? strlen(v) : 0);
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
struct leptris_xpath_result* xpath_map_builder_finish(void* b) {
|
|
2073
|
+
MapEntries* e = (MapEntries*)b;
|
|
2074
|
+
if (!e) return NULL;
|
|
2075
|
+
struct leptris_xpath_result* r = xpath_map_value(e);
|
|
2076
|
+
map_entries_free(e);
|
|
2077
|
+
free(e);
|
|
2078
|
+
return r;
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
static struct leptris_xpath_result* fn_map_get(XPathContext* ctx,
|
|
2082
|
+
XPathASTNode** args, size_t n) {
|
|
2083
|
+
char* key = re_str_arg(ctx, args, 1);
|
|
2084
|
+
char* val = NULL;
|
|
2085
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
2086
|
+
if (r) {
|
|
2087
|
+
if (r->type == XPATH_RESULT_NODESET && r->value.nodeset_value &&
|
|
2088
|
+
r->value.nodeset_value->count > 0) {
|
|
2089
|
+
XPathTextNode* tn =
|
|
2090
|
+
(XPathTextNode*)r->value.nodeset_value->nodes[0];
|
|
2091
|
+
if (tn && tn->content &&
|
|
2092
|
+
strncmp(tn->content, "\x03MAP", 4) == 0) {
|
|
2093
|
+
const char* p = tn->content + 4;
|
|
2094
|
+
while (*p == '\x02') {
|
|
2095
|
+
const char* ke = strchr(p + 1, '\x01');
|
|
2096
|
+
if (!ke) break;
|
|
2097
|
+
size_t klen = (size_t)(ke - (p + 1));
|
|
2098
|
+
const char* ve = ke + 1;
|
|
2099
|
+
const char* en = ve;
|
|
2100
|
+
while (*en && *en != '\x02') en++;
|
|
2101
|
+
if (key && klen == strlen(key) &&
|
|
2102
|
+
memcmp(p + 1, key, klen) == 0) {
|
|
2103
|
+
val = LEPTRIS_ALLOC_N(char,
|
|
2104
|
+
(size_t)(en - ve) + 1);
|
|
2105
|
+
if (val) {
|
|
2106
|
+
memcpy(val, ve, (size_t)(en - ve));
|
|
2107
|
+
val[en - ve] = '\0';
|
|
2108
|
+
}
|
|
2109
|
+
break;
|
|
2110
|
+
}
|
|
2111
|
+
p = en;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
leptris_xpath_result_free(r);
|
|
2116
|
+
}
|
|
2117
|
+
free(key);
|
|
2118
|
+
struct leptris_xpath_result* out =
|
|
2119
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
2120
|
+
if (out) out->value.string_value = val ? val : leptris_strdup("");
|
|
2121
|
+
(void)n;
|
|
2122
|
+
return out;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
static struct leptris_xpath_result* fn_map_size(XPathContext* ctx,
|
|
2126
|
+
XPathASTNode** args, size_t n) {
|
|
2127
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
2128
|
+
size_t count = 0;
|
|
2129
|
+
if (r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value &&
|
|
2130
|
+
r->value.nodeset_value->count > 0) {
|
|
2131
|
+
XPathTextNode* tn = (XPathTextNode*)r->value.nodeset_value->nodes[0];
|
|
2132
|
+
if (tn && tn->content && strncmp(tn->content, "\x03MAP", 4) == 0) {
|
|
2133
|
+
const char* p = tn->content + 4;
|
|
2134
|
+
while (*p == '\x02') {
|
|
2135
|
+
count++;
|
|
2136
|
+
p++;
|
|
2137
|
+
const char* ke = strchr(p, '\x01');
|
|
2138
|
+
if (!ke) break;
|
|
2139
|
+
p = ke + 1;
|
|
2140
|
+
while (*p && *p != '\x02') p++;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
if (r) leptris_xpath_result_free(r);
|
|
2145
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
2146
|
+
if (out) out->value.number_value = (double)count;
|
|
2147
|
+
(void)n;
|
|
2148
|
+
return out;
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
static struct leptris_xpath_result* fn_map_keys(XPathContext* ctx,
|
|
2152
|
+
XPathASTNode** args, size_t n) {
|
|
2153
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NODESET);
|
|
2154
|
+
if (!out) return NULL;
|
|
2155
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
2156
|
+
if (!out->value.nodeset_value) return out;
|
|
2157
|
+
out->value.nodeset_value->owns_synthetic_text = 1;
|
|
2158
|
+
out->value.nodeset_value->is_sequence = 1;
|
|
2159
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
2160
|
+
if (r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value &&
|
|
2161
|
+
r->value.nodeset_value->count > 0) {
|
|
2162
|
+
XPathTextNode* tn = (XPathTextNode*)r->value.nodeset_value->nodes[0];
|
|
2163
|
+
if (tn && tn->content && strncmp(tn->content, "\x03MAP", 4) == 0) {
|
|
2164
|
+
const char* p = tn->content + 4;
|
|
2165
|
+
while (*p == '\x02') {
|
|
2166
|
+
const char* ke = strchr(p + 1, '\x01');
|
|
2167
|
+
if (!ke) break;
|
|
2168
|
+
XPathTextNode* kn =
|
|
2169
|
+
xpath_synth_text(p + 1, (size_t)(ke - (p + 1)));
|
|
2170
|
+
if (kn) xpath_nodeset_add(out->value.nodeset_value, kn);
|
|
2171
|
+
const char* en = ke + 1;
|
|
2172
|
+
while (*en && *en != '\x02') en++;
|
|
2173
|
+
p = en;
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
if (r) leptris_xpath_result_free(r);
|
|
2178
|
+
(void)n;
|
|
2179
|
+
return out;
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
static struct leptris_xpath_result* fn_map_contains(XPathContext* ctx,
|
|
2183
|
+
XPathASTNode** args, size_t n) {
|
|
2184
|
+
struct leptris_xpath_result* got = fn_map_get(ctx, args, n);
|
|
2185
|
+
int found = got && got->type == XPATH_RESULT_STRING &&
|
|
2186
|
+
got->value.string_value &&
|
|
2187
|
+
got->value.string_value[0] != '\0';
|
|
2188
|
+
if (got) leptris_xpath_result_free(got);
|
|
2189
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
2190
|
+
if (out) out->value.boolean_value = found;
|
|
2191
|
+
return out;
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
static struct leptris_xpath_result* fn_map_put(XPathContext* ctx,
|
|
2195
|
+
XPathASTNode** args, size_t n) {
|
|
2196
|
+
char* key = re_str_arg(ctx, args, 1);
|
|
2197
|
+
char* val = (n >= 3) ? re_str_arg(ctx, args, 2) : leptris_strdup("");
|
|
2198
|
+
MapEntries e = {0};
|
|
2199
|
+
map_entries_arg(ctx, args, 0, &e);
|
|
2200
|
+
int replaced = 0;
|
|
2201
|
+
for (size_t i = 0; i < e.n; i++) {
|
|
2202
|
+
if (key && strcmp(e.k[i], key) == 0) {
|
|
2203
|
+
free(e.v[i]);
|
|
2204
|
+
e.v[i] = val ? val : leptris_strdup("");
|
|
2205
|
+
val = NULL; /* ownership moved */
|
|
2206
|
+
replaced = 1;
|
|
2207
|
+
break;
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
if (!replaced && key)
|
|
2211
|
+
map_entries_push(&e, key, strlen(key),
|
|
2212
|
+
val ? val : "", val ? strlen(val) : 0);
|
|
2213
|
+
free(val);
|
|
2214
|
+
free(key);
|
|
2215
|
+
struct leptris_xpath_result* out = xpath_map_value(&e);
|
|
2216
|
+
map_entries_free(&e);
|
|
2217
|
+
return out;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
static struct leptris_xpath_result* fn_map_remove(XPathContext* ctx,
|
|
2221
|
+
XPathASTNode** args, size_t n) {
|
|
2222
|
+
char* key = re_str_arg(ctx, args, 1);
|
|
2223
|
+
MapEntries src = {0};
|
|
2224
|
+
map_entries_arg(ctx, args, 0, &src);
|
|
2225
|
+
MapEntries dst;
|
|
2226
|
+
memset(&dst, 0, sizeof(dst));
|
|
2227
|
+
for (size_t i = 0; i < src.n; i++) {
|
|
2228
|
+
if (key && strcmp(src.k[i], key) == 0) continue;
|
|
2229
|
+
map_entries_push(&dst, src.k[i], strlen(src.k[i]),
|
|
2230
|
+
src.v[i], strlen(src.v[i]));
|
|
2231
|
+
}
|
|
2232
|
+
free(key);
|
|
2233
|
+
struct leptris_xpath_result* out = xpath_map_value(&dst);
|
|
2234
|
+
map_entries_free(&src);
|
|
2235
|
+
map_entries_free(&dst);
|
|
2236
|
+
(void)n;
|
|
2237
|
+
return out;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
/* map:merge: sequence of maps; on duplicate keys the LAST wins. */
|
|
2241
|
+
static struct leptris_xpath_result* fn_map_merge(XPathContext* ctx,
|
|
2242
|
+
XPathASTNode** args, size_t n) {
|
|
2243
|
+
MapEntries e = {0};
|
|
2244
|
+
map_entries_arg(ctx, args, 0, &e);
|
|
2245
|
+
MapEntries dst;
|
|
2246
|
+
memset(&dst, 0, sizeof(dst));
|
|
2247
|
+
for (size_t i = 0; i < e.n; i++) {
|
|
2248
|
+
int last = 1;
|
|
2249
|
+
for (size_t j = i + 1; j < e.n; j++)
|
|
2250
|
+
if (strcmp(e.k[i], e.k[j]) == 0) { last = 0; break; }
|
|
2251
|
+
if (last)
|
|
2252
|
+
map_entries_push(&dst, e.k[i], strlen(e.k[i]),
|
|
2253
|
+
e.v[i], strlen(e.v[i]));
|
|
2254
|
+
}
|
|
2255
|
+
map_entries_free(&e);
|
|
2256
|
+
struct leptris_xpath_result* out = xpath_map_value(&dst);
|
|
2257
|
+
map_entries_free(&dst);
|
|
2258
|
+
(void)n;
|
|
2259
|
+
return out;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
/* ---- arrays (TODO.xslt-full/08C) ----
|
|
2263
|
+
* Value-level arrays ride the map representation with positional
|
|
2264
|
+
* keys "1".."n": every accessor is the map operation with a
|
|
2265
|
+
* formatted index — one representation, two vocabularies. */
|
|
2266
|
+
|
|
2267
|
+
/* Shared lookup core extracted from fn_map_get: evaluates args[0],
|
|
2268
|
+
* returns the entry value for `key` (malloc'd "" when absent). */
|
|
2269
|
+
char* xpath_map_lookup_result(struct leptris_xpath_result* r,
|
|
2270
|
+
const char* key) {
|
|
2271
|
+
char* val = NULL;
|
|
2272
|
+
if (r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value &&
|
|
2273
|
+
r->value.nodeset_value->count > 0) {
|
|
2274
|
+
XPathTextNode* tn =
|
|
2275
|
+
(XPathTextNode*)r->value.nodeset_value->nodes[0];
|
|
2276
|
+
if (tn && tn->content &&
|
|
2277
|
+
strncmp(tn->content, "\x03MAP", 4) == 0) {
|
|
2278
|
+
const char* p = tn->content + 4;
|
|
2279
|
+
while (*p == '\x02') {
|
|
2280
|
+
const char* ke = strchr(p + 1, '\x01');
|
|
2281
|
+
if (!ke) break;
|
|
2282
|
+
const char* ve = ke + 1;
|
|
2283
|
+
const char* en = ve;
|
|
2284
|
+
while (*en && *en != '\x02') en++;
|
|
2285
|
+
if (key && (size_t)(ke - (p + 1)) == strlen(key) &&
|
|
2286
|
+
memcmp(p + 1, key, strlen(key)) == 0) {
|
|
2287
|
+
val = LEPTRIS_ALLOC_N(char, (size_t)(en - ve) + 1);
|
|
2288
|
+
if (val) {
|
|
2289
|
+
memcpy(val, ve, (size_t)(en - ve));
|
|
2290
|
+
val[en - ve] = '\0';
|
|
2291
|
+
}
|
|
2292
|
+
break;
|
|
2293
|
+
}
|
|
2294
|
+
p = en;
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
return val;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
static char* map_lookup_core(XPathContext* ctx, XPathASTNode** args,
|
|
2302
|
+
const char* key) {
|
|
2303
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
2304
|
+
char* val = xpath_map_lookup_result(r, key);
|
|
2305
|
+
if (r) leptris_xpath_result_free(r);
|
|
2306
|
+
return val;
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
static struct leptris_xpath_result* fn_array_get(XPathContext* ctx,
|
|
2310
|
+
XPathASTNode** args, size_t n) {
|
|
2311
|
+
long idx = 1;
|
|
2312
|
+
struct leptris_xpath_result* ir = xpath_evaluate(ctx, args[1]);
|
|
2313
|
+
if (ir) {
|
|
2314
|
+
idx = (long)leptris_xpath_result_number(ir);
|
|
2315
|
+
leptris_xpath_result_free(ir);
|
|
2316
|
+
}
|
|
2317
|
+
char key[24];
|
|
2318
|
+
snprintf(key, sizeof(key), "%ld", idx);
|
|
2319
|
+
char* val = map_lookup_core(ctx, args, key);
|
|
2320
|
+
struct leptris_xpath_result* out =
|
|
2321
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
2322
|
+
if (out) out->value.string_value = val ? val : leptris_strdup("");
|
|
2323
|
+
(void)n;
|
|
2324
|
+
return out;
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
static struct leptris_xpath_result* fn_array_append(XPathContext* ctx,
|
|
2328
|
+
XPathASTNode** args, size_t n) {
|
|
2329
|
+
MapEntries e = {0};
|
|
2330
|
+
map_entries_arg(ctx, args, 0, &e);
|
|
2331
|
+
char key[24];
|
|
2332
|
+
snprintf(key, sizeof(key), "%zu", e.n + 1);
|
|
2333
|
+
char* v = re_str_arg(ctx, args, 1);
|
|
2334
|
+
map_entries_push(&e, key, strlen(key), v ? v : "",
|
|
2335
|
+
v ? strlen(v) : 0);
|
|
2336
|
+
free(v);
|
|
2337
|
+
struct leptris_xpath_result* out = xpath_map_value(&e);
|
|
2338
|
+
map_entries_free(&e);
|
|
2339
|
+
(void)n;
|
|
2340
|
+
return out;
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
static struct leptris_xpath_result* fn_array_put(XPathContext* ctx,
|
|
2344
|
+
XPathASTNode** args, size_t n) {
|
|
2345
|
+
long idx = 1;
|
|
2346
|
+
struct leptris_xpath_result* ir = xpath_evaluate(ctx, args[1]);
|
|
2347
|
+
if (ir) {
|
|
2348
|
+
idx = (long)leptris_xpath_result_number(ir);
|
|
2349
|
+
leptris_xpath_result_free(ir);
|
|
2350
|
+
}
|
|
2351
|
+
char key[24];
|
|
2352
|
+
snprintf(key, sizeof(key), "%ld", idx);
|
|
2353
|
+
MapEntries e = {0};
|
|
2354
|
+
map_entries_arg(ctx, args, 0, &e);
|
|
2355
|
+
char* v = re_str_arg(ctx, args, 2);
|
|
2356
|
+
int replaced = 0;
|
|
2357
|
+
for (size_t i = 0; i < e.n; i++) {
|
|
2358
|
+
if (strcmp(e.k[i], key) == 0) {
|
|
2359
|
+
free(e.v[i]);
|
|
2360
|
+
e.v[i] = v ? v : leptris_strdup("");
|
|
2361
|
+
v = NULL;
|
|
2362
|
+
replaced = 1;
|
|
2363
|
+
break;
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
if (!replaced)
|
|
2367
|
+
map_entries_push(&e, key, strlen(key), v ? v : "",
|
|
2368
|
+
v ? strlen(v) : 0);
|
|
2369
|
+
free(v);
|
|
2370
|
+
struct leptris_xpath_result* out = xpath_map_value(&e);
|
|
2371
|
+
map_entries_free(&e);
|
|
2372
|
+
(void)n;
|
|
2373
|
+
return out;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
/* ---- parse-json (TODO.xslt-full/08D) ----
|
|
2377
|
+
* Compact recursive-descent JSON parser producing the shared
|
|
2378
|
+
* map/array representation: objects → keyed entries, arrays →
|
|
2379
|
+
* positional keys, scalars → their string form (value-level). */
|
|
2380
|
+
|
|
2381
|
+
typedef struct { const char* p; int ok; } JsonScan;
|
|
2382
|
+
|
|
2383
|
+
static void json_ws(JsonScan* s) {
|
|
2384
|
+
while (*s->p == ' ' || *s->p == '\t' || *s->p == '\n' || *s->p == '\r')
|
|
2385
|
+
s->p++;
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
/* Parse a JSON string literal into `out` (malloc'd, escapes
|
|
2389
|
+
* resolved for the common set). */
|
|
2390
|
+
static int json_string(JsonScan* s, char** out) {
|
|
2391
|
+
*out = NULL;
|
|
2392
|
+
if (*s->p != '"') { s->ok = 0; return 0; }
|
|
2393
|
+
s->p++;
|
|
2394
|
+
size_t cap = 16, len = 0;
|
|
2395
|
+
char* b = (char*)malloc(cap);
|
|
2396
|
+
if (!b) { s->ok = 0; return 0; }
|
|
2397
|
+
while (*s->p && *s->p != '"') {
|
|
2398
|
+
char c = *s->p++;
|
|
2399
|
+
if (c == '\\' && *s->p) {
|
|
2400
|
+
char e = *s->p++;
|
|
2401
|
+
if (e == 'n') c = '\n';
|
|
2402
|
+
else if (e == 't') c = '\t';
|
|
2403
|
+
else if (e == 'r') c = '\r';
|
|
2404
|
+
else if (e == 'b') c = '\b';
|
|
2405
|
+
else if (e == 'f') c = '\f';
|
|
2406
|
+
else c = e; /* \\ " / uXXXX (kept verbatim v1) */
|
|
2407
|
+
}
|
|
2408
|
+
if (len + 2 > cap) {
|
|
2409
|
+
cap *= 2;
|
|
2410
|
+
char* nb = (char*)realloc(b, cap);
|
|
2411
|
+
if (!nb) { free(b); s->ok = 0; return 0; }
|
|
2412
|
+
b = nb;
|
|
2413
|
+
}
|
|
2414
|
+
b[len++] = c;
|
|
2415
|
+
}
|
|
2416
|
+
if (*s->p != '"') { free(b); s->ok = 0; return 0; }
|
|
2417
|
+
s->p++;
|
|
2418
|
+
b[len] = '\0';
|
|
2419
|
+
*out = b;
|
|
2420
|
+
return 1;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
/* Member value under `key`: scalars land directly; nested
|
|
2424
|
+
* containers are encoded as value strings (flat maps/arrays are
|
|
2425
|
+
* exact; nested-container RE-building is the documented v1 limit). */
|
|
2426
|
+
static void json_value(JsonScan* s, void* b, const char* key);
|
|
2427
|
+
static struct leptris_xpath_result* json_root(JsonScan* s);
|
|
2428
|
+
|
|
2429
|
+
static void json_value(JsonScan* s, void* b, const char* key) {
|
|
2430
|
+
json_ws(s);
|
|
2431
|
+
if (*s->p == '{' || *s->p == '[') {
|
|
2432
|
+
struct leptris_xpath_result* sub = json_root(s);
|
|
2433
|
+
if (sub) {
|
|
2434
|
+
char* sv = leptris_xpath_result_string(sub);
|
|
2435
|
+
if (b && key) xpath_map_builder_add(b, key, sv ? sv : "");
|
|
2436
|
+
free(sv);
|
|
2437
|
+
leptris_xpath_result_free(sub);
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
s->ok = 0;
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
if (*s->p == '"') {
|
|
2444
|
+
char* v = NULL;
|
|
2445
|
+
if (json_string(s, &v)) {
|
|
2446
|
+
if (b && key) xpath_map_builder_add(b, key, v);
|
|
2447
|
+
free(v);
|
|
2448
|
+
return;
|
|
2449
|
+
}
|
|
2450
|
+
s->ok = 0;
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
const char* st = s->p;
|
|
2454
|
+
while (*s->p && *s->p != ',' && *s->p != '}' && *s->p != ']' &&
|
|
2455
|
+
*s->p != ' ' && *s->p != '\n')
|
|
2456
|
+
s->p++;
|
|
2457
|
+
if (s->p == st) { s->ok = 0; return; }
|
|
2458
|
+
size_t n = (size_t)(s->p - st);
|
|
2459
|
+
char* v = LEPTRIS_ALLOC_N(char, n + 1);
|
|
2460
|
+
if (v) {
|
|
2461
|
+
memcpy(v, st, n);
|
|
2462
|
+
v[n] = '\0';
|
|
2463
|
+
if (b && key) xpath_map_builder_add(b, key, v);
|
|
2464
|
+
free(v);
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
/* Root value: a container's members parse DIRECTLY into the result
|
|
2469
|
+
* (never wrapped under a key — wrapping embedded a whole encoding
|
|
2470
|
+
* inside another, and the size/get delimiter scans then counted the
|
|
2471
|
+
* nested entries too). */
|
|
2472
|
+
static struct leptris_xpath_result* json_root(JsonScan* s) {
|
|
2473
|
+
json_ws(s);
|
|
2474
|
+
if (*s->p == '{' || *s->p == '[') {
|
|
2475
|
+
int obj = (*s->p == '{');
|
|
2476
|
+
s->p++;
|
|
2477
|
+
void* b = xpath_map_builder_new();
|
|
2478
|
+
if (!b) { s->ok = 0; return NULL; }
|
|
2479
|
+
size_t idx = 1;
|
|
2480
|
+
json_ws(s);
|
|
2481
|
+
if ((obj && *s->p != '}') || (!obj && *s->p != ']')) {
|
|
2482
|
+
for (;;) {
|
|
2483
|
+
json_ws(s);
|
|
2484
|
+
char k[32];
|
|
2485
|
+
if (obj) {
|
|
2486
|
+
char* ks = NULL;
|
|
2487
|
+
if (!json_string(s, &ks)) break;
|
|
2488
|
+
snprintf(k, sizeof(k), "%s", ks);
|
|
2489
|
+
free(ks);
|
|
2490
|
+
json_ws(s);
|
|
2491
|
+
if (*s->p == ':') s->p++;
|
|
2492
|
+
} else {
|
|
2493
|
+
snprintf(k, sizeof(k), "%zu", idx++);
|
|
2494
|
+
}
|
|
2495
|
+
json_value(s, b, k);
|
|
2496
|
+
json_ws(s);
|
|
2497
|
+
if (*s->p == ',') { s->p++; continue; }
|
|
2498
|
+
break;
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
if ((obj && *s->p == '}') || (!obj && *s->p == ']')) s->p++;
|
|
2502
|
+
else s->ok = 0;
|
|
2503
|
+
return xpath_map_builder_finish(b);
|
|
2504
|
+
}
|
|
2505
|
+
if (*s->p == '"') {
|
|
2506
|
+
char* v = NULL;
|
|
2507
|
+
struct leptris_xpath_result* out = NULL;
|
|
2508
|
+
if (json_string(s, &v)) {
|
|
2509
|
+
out = xpath_result_new(XPATH_RESULT_STRING);
|
|
2510
|
+
if (out) out->value.string_value = v;
|
|
2511
|
+
else free(v);
|
|
2512
|
+
}
|
|
2513
|
+
return out;
|
|
2514
|
+
}
|
|
2515
|
+
const char* st = s->p;
|
|
2516
|
+
while (*s->p && *s->p != ' ' && *s->p != '\n' && *s->p != '}' &&
|
|
2517
|
+
*s->p != ']' && *s->p != ',')
|
|
2518
|
+
s->p++;
|
|
2519
|
+
if (s->p == st) { s->ok = 0; return NULL; }
|
|
2520
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
2521
|
+
if (out) {
|
|
2522
|
+
out->value.string_value = LEPTRIS_ALLOC_N(
|
|
2523
|
+
char, (size_t)(s->p - st) + 1);
|
|
2524
|
+
if (out->value.string_value) {
|
|
2525
|
+
memcpy(out->value.string_value, st, (size_t)(s->p - st));
|
|
2526
|
+
out->value.string_value[s->p - st] = '\0';
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
return out;
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
static struct leptris_xpath_result* fn_parse_json(XPathContext* ctx,
|
|
2533
|
+
XPathASTNode** args, size_t n) {
|
|
2534
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
2535
|
+
struct leptris_xpath_result* out = NULL;
|
|
2536
|
+
if (in) {
|
|
2537
|
+
JsonScan s = { in, 1 };
|
|
2538
|
+
out = json_root(&s);
|
|
2539
|
+
free(in);
|
|
2540
|
+
}
|
|
2541
|
+
if (!out) {
|
|
2542
|
+
out = xpath_result_new(XPATH_RESULT_NODESET);
|
|
2543
|
+
if (out) out->value.nodeset_value = xpath_nodeset_new();
|
|
2544
|
+
}
|
|
2545
|
+
(void)n;
|
|
2546
|
+
return out;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
/* json-to-xml (08 final slice): canonical fn: vocabulary. Values
|
|
2550
|
+
* classify by lexical form; the XML is built as text and parsed
|
|
2551
|
+
* into a scratch doc; the ROOT ELEMENT rides the nodeset. */
|
|
2552
|
+
static void xml_esc(char** buf, size_t* len, size_t* cap,
|
|
2553
|
+
const char* s) {
|
|
2554
|
+
for (const char* p = s ? s : ""; *p; p++) {
|
|
2555
|
+
const char* rep = NULL;
|
|
2556
|
+
if (*p == '&') rep = "&";
|
|
2557
|
+
else if (*p == '<') rep = "<";
|
|
2558
|
+
else if (*p == '>') rep = ">";
|
|
2559
|
+
else if (*p == '"') rep = """;
|
|
2560
|
+
size_t need = rep ? strlen(rep) : 1;
|
|
2561
|
+
while (*len + need + 1 > *cap) {
|
|
2562
|
+
*cap *= 2;
|
|
2563
|
+
char* nb = (char*)realloc(*buf, *cap);
|
|
2564
|
+
if (!nb) return;
|
|
2565
|
+
*buf = nb;
|
|
2566
|
+
}
|
|
2567
|
+
if (rep) { memcpy(*buf + *len, rep, need); *len += need; }
|
|
2568
|
+
else (*buf)[(*len)++] = *p;
|
|
2569
|
+
}
|
|
2570
|
+
(*buf)[*len] = '\0';
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
static void xml_add(char** buf, size_t* len, size_t* cap,
|
|
2574
|
+
const char* s) {
|
|
2575
|
+
size_t need = strlen(s);
|
|
2576
|
+
while (*len + need + 1 > *cap) {
|
|
2577
|
+
*cap *= 2;
|
|
2578
|
+
char* nb = (char*)realloc(*buf, *cap);
|
|
2579
|
+
if (!nb) return;
|
|
2580
|
+
*buf = nb;
|
|
2581
|
+
}
|
|
2582
|
+
memcpy(*buf + *len, s, need);
|
|
2583
|
+
*len += need;
|
|
2584
|
+
(*buf)[*len] = '\0';
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
static const char* jtype_of(const char* v) {
|
|
2588
|
+
if (!v || !*v) return "string";
|
|
2589
|
+
if (strcmp(v, "true") == 0 || strcmp(v, "false") == 0)
|
|
2590
|
+
return "boolean";
|
|
2591
|
+
if (strcmp(v, "null") == 0) return "null";
|
|
2592
|
+
char* end = NULL;
|
|
2593
|
+
strtod(v, &end);
|
|
2594
|
+
return (end && *end == '\0') ? "number" : "string";
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
static struct leptris_xpath_result* fn_json_to_xml(
|
|
2598
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
2599
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
2600
|
+
struct leptris_xpath_result* out =
|
|
2601
|
+
xpath_result_new(XPATH_RESULT_NODESET);
|
|
2602
|
+
if (!out) { free(in); return NULL; }
|
|
2603
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
2604
|
+
if (!out->value.nodeset_value) { free(in); return out; }
|
|
2605
|
+
if (!in) return out;
|
|
2606
|
+
JsonScan s = { in, 1 };
|
|
2607
|
+
struct leptris_xpath_result* root = json_root(&s);
|
|
2608
|
+
free(in);
|
|
2609
|
+
if (!root) return out;
|
|
2610
|
+
size_t cap = 256, len = 0;
|
|
2611
|
+
char* xml = (char*)malloc(cap);
|
|
2612
|
+
if (!xml) { leptris_xpath_result_free(root); return out; }
|
|
2613
|
+
xml[0] = '\0';
|
|
2614
|
+
if (root->type == XPATH_RESULT_STRING &&
|
|
2615
|
+
root->value.string_value) {
|
|
2616
|
+
const char* ty = jtype_of(root->value.string_value);
|
|
2617
|
+
xml_add(&xml, &len, &cap, "<string>");
|
|
2618
|
+
xml_esc(&xml, &len, &cap, root->value.string_value);
|
|
2619
|
+
xml_add(&xml, &len, &cap, "</string>");
|
|
2620
|
+
(void)ty;
|
|
2621
|
+
} else if (root->type == XPATH_RESULT_NODESET &&
|
|
2622
|
+
root->value.nodeset_value &&
|
|
2623
|
+
root->value.nodeset_value->count > 0) {
|
|
2624
|
+
XPathTextNode* tn =
|
|
2625
|
+
(XPathTextNode*)root->value.nodeset_value->nodes[0];
|
|
2626
|
+
MapEntries e = {0};
|
|
2627
|
+
if (tn && tn->content &&
|
|
2628
|
+
strncmp(tn->content, "\x03MAP", 4) == 0)
|
|
2629
|
+
map_entries_decode(&e, tn->content + 4);
|
|
2630
|
+
xml_add(&xml, &len, &cap,
|
|
2631
|
+
"<map xmlns=\"http://www.w3.org/2005/xpath-functions\">");
|
|
2632
|
+
for (size_t i = 0; i < e.n; i++) {
|
|
2633
|
+
const char* tag = jtype_of(e.v[i]);
|
|
2634
|
+
xml_add(&xml, &len, &cap, "<");
|
|
2635
|
+
xml_add(&xml, &len, &cap, tag);
|
|
2636
|
+
xml_add(&xml, &len, &cap, " key=\"");
|
|
2637
|
+
xml_esc(&xml, &len, &cap, e.k[i]);
|
|
2638
|
+
xml_add(&xml, &len, &cap, "\">");
|
|
2639
|
+
xml_esc(&xml, &len, &cap, e.v[i]);
|
|
2640
|
+
xml_add(&xml, &len, &cap, "</");
|
|
2641
|
+
xml_add(&xml, &len, &cap, tag);
|
|
2642
|
+
xml_add(&xml, &len, &cap, ">");
|
|
2643
|
+
}
|
|
2644
|
+
xml_add(&xml, &len, &cap, "</map>");
|
|
2645
|
+
map_entries_free(&e);
|
|
2646
|
+
}
|
|
2647
|
+
leptris_xpath_result_free(root);
|
|
2648
|
+
LeptrisDocument doc = leptris_parse_string(xml, len, NULL);
|
|
2649
|
+
free(xml);
|
|
2650
|
+
if (doc) {
|
|
2651
|
+
LeptrisElement rel = leptris_document_root(doc);
|
|
2652
|
+
if (rel) xpath_nodeset_add(out->value.nodeset_value,
|
|
2653
|
+
(LeptrisNodeRef)rel);
|
|
2654
|
+
}
|
|
2655
|
+
(void)n;
|
|
2656
|
+
return out;
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
/* ---- registration (OCP: one call from the standard init) ---- */
|
|
2660
|
+
|
|
2661
|
+
void xpath_register_fn31(XPathFunctionRegistry* registry);
|
|
2662
|
+
|
|
2663
|
+
/* xml-to-json (08): walk the canonical fn: vocabulary back into
|
|
2664
|
+
* the shared map representation — members add under @key; nested
|
|
2665
|
+
* map/array elements recurse; scalars take the element text. */
|
|
2666
|
+
static void fnxml_walk(LeptrisElement el, void* b);
|
|
2667
|
+
|
|
2668
|
+
static void fnxml_children(LeptrisElement el, void* b) {
|
|
2669
|
+
for (LeptrisElement c = leptris_element_first_child_any(el); c;
|
|
2670
|
+
c = (LeptrisElement)leptris_element_next_sibling_any(c)) {
|
|
2671
|
+
if (leptris_node_get_type((LeptrisNodeRef)c) ==
|
|
2672
|
+
LEPTRIS_NODE_TYPE_ELEMENT)
|
|
2673
|
+
fnxml_walk(c, b);
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
static void fnxml_walk(LeptrisElement el, void* b) {
|
|
2678
|
+
const char* name = leptris_element_name(el);
|
|
2679
|
+
if (!name) return;
|
|
2680
|
+
const char* key = leptris_element_attribute(el, "key");
|
|
2681
|
+
if (strcmp(name, "map") == 0 || strcmp(name, "array") == 0) {
|
|
2682
|
+
void* sub = xpath_map_builder_new();
|
|
2683
|
+
fnxml_children(el, sub);
|
|
2684
|
+
struct leptris_xpath_result* r = xpath_map_builder_finish(sub);
|
|
2685
|
+
if (r) {
|
|
2686
|
+
char* sv = leptris_xpath_result_string(r);
|
|
2687
|
+
if (b && key) xpath_map_builder_add(b, key, sv ? sv : "");
|
|
2688
|
+
free(sv);
|
|
2689
|
+
leptris_xpath_result_free(r);
|
|
2690
|
+
}
|
|
2691
|
+
return;
|
|
2692
|
+
}
|
|
2693
|
+
const char* t = leptris_element_text(el);
|
|
2694
|
+
if (b && key) xpath_map_builder_add(b, key, t ? t : "");
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
static struct leptris_xpath_result* fn_xml_to_json(
|
|
2698
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
2699
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
2700
|
+
struct leptris_xpath_result* out =
|
|
2701
|
+
xpath_result_new(XPATH_RESULT_NODESET);
|
|
2702
|
+
if (!out) { if (r) leptris_xpath_result_free(r); return NULL; }
|
|
2703
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
2704
|
+
if (!out->value.nodeset_value) {
|
|
2705
|
+
if (r) leptris_xpath_result_free(r);
|
|
2706
|
+
return out;
|
|
2707
|
+
}
|
|
2708
|
+
if (r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value) {
|
|
2709
|
+
for (size_t i = 0; i < r->value.nodeset_value->count; i++) {
|
|
2710
|
+
LeptrisNodeRef nd = r->value.nodeset_value->nodes[i];
|
|
2711
|
+
if (!nd || leptris_node_get_type(nd) !=
|
|
2712
|
+
LEPTRIS_NODE_TYPE_ELEMENT)
|
|
2713
|
+
continue;
|
|
2714
|
+
void* b = xpath_map_builder_new();
|
|
2715
|
+
fnxml_children((LeptrisElement)nd, b);
|
|
2716
|
+
struct leptris_xpath_result* m = xpath_map_builder_finish(b);
|
|
2717
|
+
if (m && m->value.nodeset_value &&
|
|
2718
|
+
m->value.nodeset_value->count > 0) {
|
|
2719
|
+
/* Ownership transfer: m's nodeset OWNS the synthetic
|
|
2720
|
+
* map node — moving the pointer to `out` without
|
|
2721
|
+
* disowning left a dangling free (map:get read a
|
|
2722
|
+
* freed node and found nothing). */
|
|
2723
|
+
xpath_nodeset_add(out->value.nodeset_value,
|
|
2724
|
+
m->value.nodeset_value->nodes[0]);
|
|
2725
|
+
m->value.nodeset_value->count = 0;
|
|
2726
|
+
m->value.nodeset_value->owns_synthetic_text = 0;
|
|
2727
|
+
out->value.nodeset_value->owns_synthetic_text = 1;
|
|
2728
|
+
out->value.nodeset_value->is_sequence = 1;
|
|
2729
|
+
}
|
|
2730
|
+
if (m) leptris_xpath_result_free(m);
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
if (r) leptris_xpath_result_free(r);
|
|
2734
|
+
(void)n;
|
|
2735
|
+
return out;
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
/* fn:serialize (08 final): method json over the shared map
|
|
2739
|
+
* representation — keys double-quoted, values escaped when their
|
|
2740
|
+
* lexical form is not number/boolean/null. Other methods are v1
|
|
2741
|
+
* string() of the item (the XML method is document-level). */
|
|
2742
|
+
static void json_out(char** buf, size_t* len, size_t* cap,
|
|
2743
|
+
const char* s) {
|
|
2744
|
+
for (const char* p = s ? s : ""; *p; p++) {
|
|
2745
|
+
const char* rep = NULL;
|
|
2746
|
+
if ((unsigned char)*p == '"') rep = "\\\"";
|
|
2747
|
+
else if (*p == '\\') rep = "\\\\";
|
|
2748
|
+
else if (*p == '\n') rep = "\\n";
|
|
2749
|
+
else if (*p == '\t') rep = "\\t";
|
|
2750
|
+
else if (*p == '\r') rep = "\\r";
|
|
2751
|
+
size_t need = rep ? strlen(rep) : 1;
|
|
2752
|
+
while (*len + need + 1 > *cap) {
|
|
2753
|
+
*cap *= 2;
|
|
2754
|
+
char* nb = (char*)realloc(*buf, *cap);
|
|
2755
|
+
if (!nb) return;
|
|
2756
|
+
*buf = nb;
|
|
2757
|
+
}
|
|
2758
|
+
if (rep) { memcpy(*buf + *len, rep, need); *len += need; }
|
|
2759
|
+
else (*buf)[(*len)++] = *p;
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
static struct leptris_xpath_result* fn_serialize(XPathContext* ctx,
|
|
2764
|
+
XPathASTNode** args, size_t n) {
|
|
2765
|
+
struct leptris_xpath_result* item = xpath_evaluate(ctx, args[0]);
|
|
2766
|
+
if (!item) return NULL;
|
|
2767
|
+
int json = (n >= 2);
|
|
2768
|
+
char* method = NULL;
|
|
2769
|
+
if (n >= 2) {
|
|
2770
|
+
char* key = leptris_strdup("method");
|
|
2771
|
+
struct leptris_xpath_result* opt =
|
|
2772
|
+
xpath_evaluate(ctx, args[1]);
|
|
2773
|
+
char* m = xpath_map_lookup_result(opt, key);
|
|
2774
|
+
free(key);
|
|
2775
|
+
if (opt) leptris_xpath_result_free(opt);
|
|
2776
|
+
json = m && strcmp(m, "json") == 0;
|
|
2777
|
+
free(m);
|
|
2778
|
+
(void)method;
|
|
2779
|
+
}
|
|
2780
|
+
if (!json) {
|
|
2781
|
+
/* v1: non-json methods take the string value. */
|
|
2782
|
+
char* sv = leptris_xpath_result_string(item);
|
|
2783
|
+
leptris_xpath_result_free(item);
|
|
2784
|
+
struct leptris_xpath_result* out =
|
|
2785
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
2786
|
+
if (out) out->value.string_value = sv ? sv : leptris_strdup("");
|
|
2787
|
+
return out;
|
|
2788
|
+
}
|
|
2789
|
+
MapEntries e = {0};
|
|
2790
|
+
if (item->type == XPATH_RESULT_NODESET && item->value.nodeset_value &&
|
|
2791
|
+
item->value.nodeset_value->count > 0) {
|
|
2792
|
+
XPathTextNode* tn =
|
|
2793
|
+
(XPathTextNode*)item->value.nodeset_value->nodes[0];
|
|
2794
|
+
if (tn && tn->content &&
|
|
2795
|
+
strncmp(tn->content, "\x03MAP", 4) == 0)
|
|
2796
|
+
map_entries_decode(&e, tn->content + 4);
|
|
2797
|
+
}
|
|
2798
|
+
leptris_xpath_result_free(item);
|
|
2799
|
+
size_t cap = 64, len = 1;
|
|
2800
|
+
char* buf = (char*)malloc(cap);
|
|
2801
|
+
if (!buf) { map_entries_free(&e); return NULL; }
|
|
2802
|
+
buf[0] = '{';
|
|
2803
|
+
for (size_t i = 0; i < e.n; i++) {
|
|
2804
|
+
if (i) {
|
|
2805
|
+
while (len + 2 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); }
|
|
2806
|
+
buf[len++] = ',';
|
|
2807
|
+
}
|
|
2808
|
+
while (len + 4 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); }
|
|
2809
|
+
buf[len++] = '"';
|
|
2810
|
+
json_out(&buf, &len, &cap, e.k[i]);
|
|
2811
|
+
while (len + 4 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); }
|
|
2812
|
+
buf[len++] = '"';
|
|
2813
|
+
buf[len++] = ':';
|
|
2814
|
+
const char* ty = jtype_of(e.v[i]);
|
|
2815
|
+
if (strcmp(ty, "string") == 0) {
|
|
2816
|
+
while (len + 2 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); }
|
|
2817
|
+
buf[len++] = '"';
|
|
2818
|
+
json_out(&buf, &len, &cap, e.v[i]);
|
|
2819
|
+
while (len + 2 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); }
|
|
2820
|
+
buf[len++] = '"';
|
|
2821
|
+
} else {
|
|
2822
|
+
json_out(&buf, &len, &cap, e.v[i]);
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
while (len + 2 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); }
|
|
2826
|
+
buf[len++] = '}';
|
|
2827
|
+
buf[len] = '\0';
|
|
2828
|
+
map_entries_free(&e);
|
|
2829
|
+
struct leptris_xpath_result* out =
|
|
2830
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
2831
|
+
if (!out) { free(buf); return NULL; }
|
|
2832
|
+
out->value.string_value = buf;
|
|
2833
|
+
return out;
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
/* ---- function items: metadata + HOF combiners (TODO 07B) ---- */
|
|
2837
|
+
|
|
2838
|
+
/* Shared call seam (evaluator_operators.c): dispatch a closure
|
|
2839
|
+
* content string with string arguments. */
|
|
2840
|
+
extern struct leptris_xpath_result* xpath_call_function_item(
|
|
2841
|
+
XPathContext* ctx, const char* cc, char** argv, size_t argc);
|
|
2842
|
+
|
|
2843
|
+
/* Closure content of a function-item argument (first sequence
|
|
2844
|
+
* member's text), or NULL. Caller frees. */
|
|
2845
|
+
static char* fn_item_content(XPathContext* ctx, XPathASTNode** args,
|
|
2846
|
+
size_t i) {
|
|
2847
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[i]);
|
|
2848
|
+
if (!r) return NULL;
|
|
2849
|
+
char* out = NULL;
|
|
2850
|
+
if (r->type == XPATH_RESULT_NODESET && r->value.nodeset_value &&
|
|
2851
|
+
r->value.nodeset_value->count > 0) {
|
|
2852
|
+
out = get_node_text(r->value.nodeset_value->nodes[0]);
|
|
2853
|
+
}
|
|
2854
|
+
xpath_result_free(r);
|
|
2855
|
+
return out;
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
static int fn_result_truthy(const struct leptris_xpath_result* r) {
|
|
2859
|
+
if (!r) return 0;
|
|
2860
|
+
switch (r->type) {
|
|
2861
|
+
case XPATH_RESULT_BOOLEAN:
|
|
2862
|
+
return r->value.boolean_value;
|
|
2863
|
+
case XPATH_RESULT_NUMBER:
|
|
2864
|
+
return r->value.number_value != 0.0 &&
|
|
2865
|
+
!isnan(r->value.number_value);
|
|
2866
|
+
case XPATH_RESULT_STRING:
|
|
2867
|
+
return r->value.string_value && r->value.string_value[0];
|
|
2868
|
+
case XPATH_RESULT_NODESET:
|
|
2869
|
+
return r->value.nodeset_value &&
|
|
2870
|
+
r->value.nodeset_value->count > 0;
|
|
2871
|
+
default:
|
|
2872
|
+
return 0;
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
/* fn:function-lookup(name, arity): the named function as an item,
|
|
2877
|
+
* or the empty sequence. The name may carry an fn: prefix (the
|
|
2878
|
+
* XPath 3.x argument is a QName in the fn namespace). */
|
|
2879
|
+
static struct leptris_xpath_result* fn_function_lookup(
|
|
2880
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
2881
|
+
(void)n;
|
|
2882
|
+
struct leptris_xpath_result* nr = xpath_evaluate(ctx, args[0]);
|
|
2883
|
+
if (!nr) return NULL;
|
|
2884
|
+
char* name = scalar_str(nr);
|
|
2885
|
+
xpath_result_free(nr);
|
|
2886
|
+
if (!name) return NULL;
|
|
2887
|
+
|
|
2888
|
+
double arity = 0;
|
|
2889
|
+
struct leptris_xpath_result* ar = xpath_evaluate(ctx, args[1]);
|
|
2890
|
+
if (ar) {
|
|
2891
|
+
if (ar->type == XPATH_RESULT_NUMBER) {
|
|
2892
|
+
arity = ar->value.number_value;
|
|
2893
|
+
} else {
|
|
2894
|
+
char* s = scalar_str(ar);
|
|
2895
|
+
if (s) { arity = atof(s); free(s); }
|
|
2896
|
+
}
|
|
2897
|
+
xpath_result_free(ar);
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
const char* bare = name;
|
|
2901
|
+
if (strncmp(bare, "fn:", 3) == 0) bare += 3;
|
|
2902
|
+
|
|
2903
|
+
struct leptris_xpath_result* out = seq_new();
|
|
2904
|
+
if (out) {
|
|
2905
|
+
XPathFunctionDef* def = ctx->function_registry
|
|
2906
|
+
? xpath_function_registry_get(ctx->function_registry, bare)
|
|
2907
|
+
: NULL;
|
|
2908
|
+
if (def && arity >= (double)def->min_args &&
|
|
2909
|
+
(def->max_args < 0 || arity <= (double)def->max_args)) {
|
|
2910
|
+
char ref[192];
|
|
2911
|
+
snprintf(ref, sizeof(ref), "\x03" "FR%s#%ld", bare,
|
|
2912
|
+
arity < 0 ? 0 : (long)arity);
|
|
2913
|
+
seq_push_str(out, ref);
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
free(name);
|
|
2917
|
+
return out;
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
/* fn:function-name($f): fn:local-name for named references; the
|
|
2921
|
+
* empty sequence for anonymous closures. */
|
|
2922
|
+
static struct leptris_xpath_result* fn_function_name(
|
|
2923
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
2924
|
+
(void)n;
|
|
2925
|
+
char* cc = fn_item_content(ctx, args, 0);
|
|
2926
|
+
struct leptris_xpath_result* out;
|
|
2927
|
+
if (cc && strncmp(cc, "\x03" "FR", 3) == 0) {
|
|
2928
|
+
const char* nm = cc + 3;
|
|
2929
|
+
const char* hash = strchr(nm, '#');
|
|
2930
|
+
size_t len = hash ? (size_t)(hash - nm) : strlen(nm);
|
|
2931
|
+
out = xpath_result_new(XPATH_RESULT_STRING);
|
|
2932
|
+
if (out) {
|
|
2933
|
+
char* buf = LEPTRIS_ALLOC_N(char, len + 4);
|
|
2934
|
+
if (buf) {
|
|
2935
|
+
memcpy(buf, "fn:", 3);
|
|
2936
|
+
memcpy(buf + 3, nm, len);
|
|
2937
|
+
buf[3 + len] = 0;
|
|
2938
|
+
out->value.string_value = buf;
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
} else {
|
|
2942
|
+
out = seq_new();
|
|
2943
|
+
}
|
|
2944
|
+
free(cc);
|
|
2945
|
+
return out;
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
/* fn:function-arity($f): #N for named references; the closure's
|
|
2949
|
+
* parameter count for inline functions. */
|
|
2950
|
+
static struct leptris_xpath_result* fn_function_arity(
|
|
2951
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
2952
|
+
(void)n;
|
|
2953
|
+
char* cc = fn_item_content(ctx, args, 0);
|
|
2954
|
+
if (!cc) return NULL;
|
|
2955
|
+
double arity = 0;
|
|
2956
|
+
if (strncmp(cc, "\x03" "FR", 3) == 0) {
|
|
2957
|
+
const char* hash = strchr(cc + 3, '#');
|
|
2958
|
+
arity = hash ? atof(hash + 1) : 0;
|
|
2959
|
+
} else if (strncmp(cc, "\x03" "FN", 3) == 0) {
|
|
2960
|
+
const char* p = cc + 4;
|
|
2961
|
+
const char* pe = strchr(p, '\x02');
|
|
2962
|
+
if (pe && pe > p) {
|
|
2963
|
+
arity = 1;
|
|
2964
|
+
for (const char* q = p; q < pe; q++)
|
|
2965
|
+
if (*q == '\x01') arity++;
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
free(cc);
|
|
2969
|
+
struct leptris_xpath_result* out =
|
|
2970
|
+
xpath_result_new(XPATH_RESULT_NUMBER);
|
|
2971
|
+
if (out) out->value.number_value = arity;
|
|
2972
|
+
return out;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
/* fn:for-each(sequence, $f) */
|
|
2976
|
+
static struct leptris_xpath_result* fn_for_each(XPathContext* ctx,
|
|
2977
|
+
XPathASTNode** args, size_t n) {
|
|
2978
|
+
(void)n;
|
|
2979
|
+
size_t cnt;
|
|
2980
|
+
char** items = collect_items(ctx, args, 1, 0, &cnt);
|
|
2981
|
+
if (!items) return NULL;
|
|
2982
|
+
char* cc = fn_item_content(ctx, args, 1);
|
|
2983
|
+
struct leptris_xpath_result* out = seq_new();
|
|
2984
|
+
if (cc && out) {
|
|
2985
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
2986
|
+
char* argv[1] = { items[k] };
|
|
2987
|
+
struct leptris_xpath_result* r =
|
|
2988
|
+
xpath_call_function_item(ctx, cc, argv, 1);
|
|
2989
|
+
if (r) {
|
|
2990
|
+
char* s = xpath_to_string(r);
|
|
2991
|
+
seq_push_str(out, s ? s : "");
|
|
2992
|
+
free(s);
|
|
2993
|
+
xpath_result_free(r);
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
free(cc);
|
|
2998
|
+
free_items(items, cnt);
|
|
2999
|
+
return out;
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
/* fn:filter(sequence, $f) — members whose mapped result is truthy */
|
|
3003
|
+
static struct leptris_xpath_result* fn_filter(XPathContext* ctx,
|
|
3004
|
+
XPathASTNode** args, size_t n) {
|
|
3005
|
+
(void)n;
|
|
3006
|
+
size_t cnt;
|
|
3007
|
+
char** items = collect_items(ctx, args, 1, 0, &cnt);
|
|
3008
|
+
if (!items) return NULL;
|
|
3009
|
+
char* cc = fn_item_content(ctx, args, 1);
|
|
3010
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3011
|
+
if (cc && out) {
|
|
3012
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
3013
|
+
char* argv[1] = { items[k] };
|
|
3014
|
+
struct leptris_xpath_result* r =
|
|
3015
|
+
xpath_call_function_item(ctx, cc, argv, 1);
|
|
3016
|
+
if (r) {
|
|
3017
|
+
if (fn_result_truthy(r)) seq_push_str(out, items[k]);
|
|
3018
|
+
xpath_result_free(r);
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
free(cc);
|
|
3023
|
+
free_items(items, cnt);
|
|
3024
|
+
return out;
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
/* fn:fold-left(sequence, zero, $f) — f(acc, item) left to right */
|
|
3028
|
+
static struct leptris_xpath_result* fn_fold_left(XPathContext* ctx,
|
|
3029
|
+
XPathASTNode** args, size_t n) {
|
|
3030
|
+
(void)n;
|
|
3031
|
+
size_t cnt;
|
|
3032
|
+
char** items = collect_items(ctx, args, 1, 0, &cnt);
|
|
3033
|
+
if (!items) return NULL;
|
|
3034
|
+
char* cc = fn_item_content(ctx, args, 2);
|
|
3035
|
+
struct leptris_xpath_result* zr = xpath_evaluate(ctx, args[1]);
|
|
3036
|
+
char* acc = zr ? xpath_to_string(zr) : NULL;
|
|
3037
|
+
if (zr) xpath_result_free(zr);
|
|
3038
|
+
if (!acc) acc = leptris_strdup("");
|
|
3039
|
+
if (cc && acc) {
|
|
3040
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
3041
|
+
char* argv[2] = { acc, items[k] };
|
|
3042
|
+
struct leptris_xpath_result* r =
|
|
3043
|
+
xpath_call_function_item(ctx, cc, argv, 2);
|
|
3044
|
+
char* ns = r ? xpath_to_string(r) : NULL;
|
|
3045
|
+
if (r) xpath_result_free(r);
|
|
3046
|
+
free(acc);
|
|
3047
|
+
acc = ns ? ns : leptris_strdup("");
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
struct leptris_xpath_result* out =
|
|
3051
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
3052
|
+
if (!out) { free(acc); acc = NULL; }
|
|
3053
|
+
if (out) out->value.string_value = acc;
|
|
3054
|
+
else free(acc);
|
|
3055
|
+
free(cc);
|
|
3056
|
+
free_items(items, cnt);
|
|
3057
|
+
return out;
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
/* fn:fold-right(sequence, zero, $f) — f(item, acc) right to left */
|
|
3061
|
+
static struct leptris_xpath_result* fn_fold_right(XPathContext* ctx,
|
|
3062
|
+
XPathASTNode** args, size_t n) {
|
|
3063
|
+
(void)n;
|
|
3064
|
+
size_t cnt;
|
|
3065
|
+
char** items = collect_items(ctx, args, 1, 0, &cnt);
|
|
3066
|
+
if (!items) return NULL;
|
|
3067
|
+
char* cc = fn_item_content(ctx, args, 2);
|
|
3068
|
+
struct leptris_xpath_result* zr = xpath_evaluate(ctx, args[1]);
|
|
3069
|
+
char* acc = zr ? xpath_to_string(zr) : NULL;
|
|
3070
|
+
if (zr) xpath_result_free(zr);
|
|
3071
|
+
if (!acc) acc = leptris_strdup("");
|
|
3072
|
+
if (cc && acc) {
|
|
3073
|
+
for (size_t k = cnt; k > 0; k--) {
|
|
3074
|
+
char* argv[2] = { items[k - 1], acc };
|
|
3075
|
+
struct leptris_xpath_result* r =
|
|
3076
|
+
xpath_call_function_item(ctx, cc, argv, 2);
|
|
3077
|
+
char* ns = r ? xpath_to_string(r) : NULL;
|
|
3078
|
+
if (r) xpath_result_free(r);
|
|
3079
|
+
free(acc);
|
|
3080
|
+
acc = ns ? ns : leptris_strdup("");
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
struct leptris_xpath_result* out =
|
|
3084
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
3085
|
+
if (out) out->value.string_value = acc;
|
|
3086
|
+
else free(acc);
|
|
3087
|
+
free(cc);
|
|
3088
|
+
free_items(items, cnt);
|
|
3089
|
+
return out;
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
|
|
3093
|
+
/* fn:sort(seq, key?, collation?) — lane 07 tail: codepoint order,
|
|
3094
|
+
* stable; an optional key function item computes the sort key
|
|
3095
|
+
* per item; the collation argument is accepted and ignored
|
|
3096
|
+
* (codepoint collation). */
|
|
3097
|
+
static struct leptris_xpath_result* fn_sort_seq(XPathContext* ctx,
|
|
3098
|
+
XPathASTNode** args, size_t n) {
|
|
3099
|
+
size_t c = 0;
|
|
3100
|
+
char** xs = collect_items(ctx, args, 1, 0, &c);
|
|
3101
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3102
|
+
if (!xs || !out) {
|
|
3103
|
+
free_items(xs, c);
|
|
3104
|
+
return out;
|
|
3105
|
+
}
|
|
3106
|
+
char** keys = NULL;
|
|
3107
|
+
if (n >= 2) {
|
|
3108
|
+
char* cc = fn_item_content(ctx, args, 1);
|
|
3109
|
+
if (cc) {
|
|
3110
|
+
keys = (char**)calloc(c, sizeof(char*));
|
|
3111
|
+
for (size_t k = 0; k < c; k++) {
|
|
3112
|
+
char* argv[1] = { xs[k] };
|
|
3113
|
+
struct leptris_xpath_result* r =
|
|
3114
|
+
xpath_call_function_item(ctx, cc, argv, 1);
|
|
3115
|
+
if (r) {
|
|
3116
|
+
keys[k] = xpath_to_string(r);
|
|
3117
|
+
xpath_result_free(r);
|
|
3118
|
+
}
|
|
3119
|
+
if (!keys[k]) keys[k] = leptris_strdup("");
|
|
3120
|
+
}
|
|
3121
|
+
free(cc);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
/* stable insertion sort by key (or the item itself) */
|
|
3125
|
+
for (size_t i = 1; i < c; i++) {
|
|
3126
|
+
char* it = xs[i];
|
|
3127
|
+
char* kt = keys ? keys[i] : it;
|
|
3128
|
+
size_t j = i;
|
|
3129
|
+
while (j > 0 &&
|
|
3130
|
+
strcmp(keys ? keys[j - 1] : xs[j - 1], kt) > 0) {
|
|
3131
|
+
xs[j] = xs[j - 1];
|
|
3132
|
+
if (keys) keys[j] = keys[j - 1];
|
|
3133
|
+
j--;
|
|
3134
|
+
}
|
|
3135
|
+
xs[j] = it;
|
|
3136
|
+
if (keys) keys[j] = kt;
|
|
3137
|
+
}
|
|
3138
|
+
for (size_t k = 0; k < c; k++) seq_push_str(out, xs[k]);
|
|
3139
|
+
if (keys) {
|
|
3140
|
+
for (size_t k = 0; k < c; k++) free(keys[k]);
|
|
3141
|
+
free(keys);
|
|
3142
|
+
}
|
|
3143
|
+
free_items(xs, c);
|
|
3144
|
+
return out;
|
|
3145
|
+
}
|
|
3146
|
+
|
|
3147
|
+
/* fn:for-each-pair(seq1, seq2, $f) — zip; the shorter input wins */
|
|
3148
|
+
static struct leptris_xpath_result* fn_for_each_pair(XPathContext* ctx,
|
|
3149
|
+
XPathASTNode** args, size_t n) {
|
|
3150
|
+
(void)n;
|
|
3151
|
+
size_t c1, c2;
|
|
3152
|
+
char** xs = collect_items(ctx, args, 1, 0, &c1);
|
|
3153
|
+
if (!xs) return NULL;
|
|
3154
|
+
char** ys = collect_items(ctx, args, 1, 1, &c2);
|
|
3155
|
+
char* cc = fn_item_content(ctx, args, 2);
|
|
3156
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3157
|
+
if (cc && out) {
|
|
3158
|
+
size_t cnt = c1 < c2 ? c1 : c2;
|
|
3159
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
3160
|
+
char* argv[2] = { xs[k], ys[k] };
|
|
3161
|
+
struct leptris_xpath_result* r =
|
|
3162
|
+
xpath_call_function_item(ctx, cc, argv, 2);
|
|
3163
|
+
if (r) {
|
|
3164
|
+
char* s = xpath_to_string(r);
|
|
3165
|
+
seq_push_str(out, s ? s : "");
|
|
3166
|
+
free(s);
|
|
3167
|
+
xpath_result_free(r);
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
free(cc);
|
|
3172
|
+
free_items(xs, c1);
|
|
3173
|
+
free_items(ys, c2);
|
|
3174
|
+
return out;
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
/* fn:apply($f, array) — call with the array's members as the
|
|
3178
|
+
* argument list. */
|
|
3179
|
+
static struct leptris_xpath_result* fn_apply(XPathContext* ctx,
|
|
3180
|
+
XPathASTNode** args, size_t n) {
|
|
3181
|
+
(void)n;
|
|
3182
|
+
char* cc = fn_item_content(ctx, args, 0);
|
|
3183
|
+
if (!cc) return NULL;
|
|
3184
|
+
MapEntries e = {0};
|
|
3185
|
+
map_entries_arg(ctx, args, 1, &e);
|
|
3186
|
+
struct leptris_xpath_result* out = NULL;
|
|
3187
|
+
if (e.n) {
|
|
3188
|
+
char** argv = (char**)calloc(e.n, sizeof(char*));
|
|
3189
|
+
if (argv) {
|
|
3190
|
+
size_t argc = 0;
|
|
3191
|
+
for (size_t i = 0; i < e.n; i++) {
|
|
3192
|
+
long idx = strtol(e.k[i], NULL, 10);
|
|
3193
|
+
if (idx >= 1 && (size_t)idx <= e.n)
|
|
3194
|
+
argv[idx - 1] = e.v[i];
|
|
3195
|
+
}
|
|
3196
|
+
for (size_t i = 0; i < e.n; i++)
|
|
3197
|
+
if (argv[i]) argv[argc++] = argv[i];
|
|
3198
|
+
out = xpath_call_function_item(ctx, cc, argv, argc);
|
|
3199
|
+
free(argv);
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
map_entries_free(&e);
|
|
3203
|
+
free(cc);
|
|
3204
|
+
return out;
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
/* map:for-each(map, $f) — f(key, value) per entry, in entry order */
|
|
3208
|
+
static struct leptris_xpath_result* fn_map_for_each(XPathContext* ctx,
|
|
3209
|
+
XPathASTNode** args, size_t n) {
|
|
3210
|
+
(void)n;
|
|
3211
|
+
MapEntries e = {0};
|
|
3212
|
+
map_entries_arg(ctx, args, 0, &e);
|
|
3213
|
+
char* cc = fn_item_content(ctx, args, 1);
|
|
3214
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3215
|
+
if (cc && out) {
|
|
3216
|
+
for (size_t i = 0; i < e.n; i++) {
|
|
3217
|
+
char* argv[2] = { e.k[i], e.v[i] };
|
|
3218
|
+
struct leptris_xpath_result* r =
|
|
3219
|
+
xpath_call_function_item(ctx, cc, argv, 2);
|
|
3220
|
+
if (r) {
|
|
3221
|
+
char* s = xpath_to_string(r);
|
|
3222
|
+
seq_push_str(out, s ? s : "");
|
|
3223
|
+
free(s);
|
|
3224
|
+
xpath_result_free(r);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
free(cc);
|
|
3229
|
+
map_entries_free(&e);
|
|
3230
|
+
return out;
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
/* Array members in positional order: entries keyed 1..n. */
|
|
3234
|
+
static char** array_members_arg(XPathContext* ctx, XPathASTNode** args,
|
|
3235
|
+
size_t i, size_t* out_n) {
|
|
3236
|
+
*out_n = 0;
|
|
3237
|
+
MapEntries e = {0};
|
|
3238
|
+
map_entries_arg(ctx, args, i, &e);
|
|
3239
|
+
if (!e.n) { map_entries_free(&e); return NULL; }
|
|
3240
|
+
char** members = (char**)calloc(e.n, sizeof(char*));
|
|
3241
|
+
if (!members) { map_entries_free(&e); return NULL; }
|
|
3242
|
+
for (size_t j = 0; j < e.n; j++) {
|
|
3243
|
+
long idx = strtol(e.k[j], NULL, 10);
|
|
3244
|
+
if (idx >= 1 && (size_t)idx <= e.n && !members[idx - 1])
|
|
3245
|
+
members[idx - 1] = leptris_strdup(e.v[j]);
|
|
3246
|
+
}
|
|
3247
|
+
/* map_entries_free zeroes e.n — capture it first. */
|
|
3248
|
+
size_t n_members = e.n;
|
|
3249
|
+
map_entries_free(&e);
|
|
3250
|
+
size_t cnt = 0;
|
|
3251
|
+
for (size_t j = 0; j < n_members; j++)
|
|
3252
|
+
if (members[j]) members[cnt++] = members[j];
|
|
3253
|
+
if (!cnt) { free(members); return NULL; }
|
|
3254
|
+
*out_n = cnt;
|
|
3255
|
+
return members;
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
/* array:for-each(array, $f) */
|
|
3259
|
+
static struct leptris_xpath_result* fn_array_for_each(XPathContext* ctx,
|
|
3260
|
+
XPathASTNode** args, size_t n) {
|
|
3261
|
+
(void)n;
|
|
3262
|
+
size_t cnt;
|
|
3263
|
+
char** items = array_members_arg(ctx, args, 0, &cnt);
|
|
3264
|
+
if (!items) return seq_new();
|
|
3265
|
+
char* cc = fn_item_content(ctx, args, 1);
|
|
3266
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3267
|
+
if (cc && out) {
|
|
3268
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
3269
|
+
char* argv[1] = { items[k] };
|
|
3270
|
+
struct leptris_xpath_result* r =
|
|
3271
|
+
xpath_call_function_item(ctx, cc, argv, 1);
|
|
3272
|
+
if (r) {
|
|
3273
|
+
char* s = xpath_to_string(r);
|
|
3274
|
+
seq_push_str(out, s ? s : "");
|
|
3275
|
+
free(s);
|
|
3276
|
+
xpath_result_free(r);
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
free(cc);
|
|
3281
|
+
free_items(items, cnt);
|
|
3282
|
+
return out;
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
/* array:filter(array, $f) — members whose mapped result is truthy */
|
|
3286
|
+
static struct leptris_xpath_result* fn_array_filter(XPathContext* ctx,
|
|
3287
|
+
XPathASTNode** args, size_t n) {
|
|
3288
|
+
(void)n;
|
|
3289
|
+
size_t cnt;
|
|
3290
|
+
char** items = array_members_arg(ctx, args, 0, &cnt);
|
|
3291
|
+
if (!items) return seq_new();
|
|
3292
|
+
char* cc = fn_item_content(ctx, args, 1);
|
|
3293
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3294
|
+
if (cc && out) {
|
|
3295
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
3296
|
+
char* argv[1] = { items[k] };
|
|
3297
|
+
struct leptris_xpath_result* r =
|
|
3298
|
+
xpath_call_function_item(ctx, cc, argv, 1);
|
|
3299
|
+
if (r) {
|
|
3300
|
+
if (fn_result_truthy(r)) seq_push_str(out, items[k]);
|
|
3301
|
+
xpath_result_free(r);
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
free(cc);
|
|
3306
|
+
free_items(items, cnt);
|
|
3307
|
+
return out;
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
/* array:fold-left(array, zero, $f) — f(acc, member), left to right */
|
|
3311
|
+
static struct leptris_xpath_result* fn_array_fold_left(XPathContext* ctx,
|
|
3312
|
+
XPathASTNode** args, size_t n) {
|
|
3313
|
+
(void)n;
|
|
3314
|
+
size_t cnt;
|
|
3315
|
+
char** items = array_members_arg(ctx, args, 0, &cnt);
|
|
3316
|
+
if (!items) return NULL;
|
|
3317
|
+
char* cc = fn_item_content(ctx, args, 2);
|
|
3318
|
+
struct leptris_xpath_result* zr = xpath_evaluate(ctx, args[1]);
|
|
3319
|
+
char* acc = zr ? xpath_to_string(zr) : NULL;
|
|
3320
|
+
if (zr) xpath_result_free(zr);
|
|
3321
|
+
if (!acc) acc = leptris_strdup("");
|
|
3322
|
+
if (cc && acc) {
|
|
3323
|
+
for (size_t k = 0; k < cnt; k++) {
|
|
3324
|
+
char* argv[2] = { acc, items[k] };
|
|
3325
|
+
struct leptris_xpath_result* r =
|
|
3326
|
+
xpath_call_function_item(ctx, cc, argv, 2);
|
|
3327
|
+
char* ns = r ? xpath_to_string(r) : NULL;
|
|
3328
|
+
if (r) xpath_result_free(r);
|
|
3329
|
+
free(acc);
|
|
3330
|
+
acc = ns ? ns : leptris_strdup("");
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
struct leptris_xpath_result* out =
|
|
3334
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
3335
|
+
if (out) out->value.string_value = acc;
|
|
3336
|
+
else free(acc);
|
|
3337
|
+
free(cc);
|
|
3338
|
+
free_items(items, cnt);
|
|
3339
|
+
return out;
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
/* array:fold-right(array, zero, $f) — f(member, acc), right to left */
|
|
3343
|
+
static struct leptris_xpath_result* fn_array_fold_right(XPathContext* ctx,
|
|
3344
|
+
XPathASTNode** args, size_t n) {
|
|
3345
|
+
(void)n;
|
|
3346
|
+
size_t cnt;
|
|
3347
|
+
char** items = array_members_arg(ctx, args, 0, &cnt);
|
|
3348
|
+
if (!items) return NULL;
|
|
3349
|
+
char* cc = fn_item_content(ctx, args, 2);
|
|
3350
|
+
struct leptris_xpath_result* zr = xpath_evaluate(ctx, args[1]);
|
|
3351
|
+
char* acc = zr ? xpath_to_string(zr) : NULL;
|
|
3352
|
+
if (zr) xpath_result_free(zr);
|
|
3353
|
+
if (!acc) acc = leptris_strdup("");
|
|
3354
|
+
if (cc && acc) {
|
|
3355
|
+
for (size_t k = cnt; k > 0; k--) {
|
|
3356
|
+
char* argv[2] = { items[k - 1], acc };
|
|
3357
|
+
struct leptris_xpath_result* r =
|
|
3358
|
+
xpath_call_function_item(ctx, cc, argv, 2);
|
|
3359
|
+
char* ns = r ? xpath_to_string(r) : NULL;
|
|
3360
|
+
if (r) xpath_result_free(r);
|
|
3361
|
+
free(acc);
|
|
3362
|
+
acc = ns ? ns : leptris_strdup("");
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
struct leptris_xpath_result* out =
|
|
3366
|
+
xpath_result_new(XPATH_RESULT_STRING);
|
|
3367
|
+
if (out) out->value.string_value = acc;
|
|
3368
|
+
else free(acc);
|
|
3369
|
+
free(cc);
|
|
3370
|
+
free_items(items, cnt);
|
|
3371
|
+
return out;
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
/* ---- sequence/doc tail (#691) ---- */
|
|
3375
|
+
|
|
3376
|
+
/* First node of args[i], or the context node when the argument is
|
|
3377
|
+
* absent. Nodes are document-owned; the nodeset container holding
|
|
3378
|
+
* them may be freed after the pointer is taken. */
|
|
3379
|
+
static void* node_arg_or_ctx(XPathContext* ctx, XPathASTNode** args,
|
|
3380
|
+
size_t n, size_t i) {
|
|
3381
|
+
if (n > i) {
|
|
3382
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[i]);
|
|
3383
|
+
void* nd = NULL;
|
|
3384
|
+
if (r && r->type == XPATH_RESULT_NODESET &&
|
|
3385
|
+
r->value.nodeset_value && r->value.nodeset_value->count)
|
|
3386
|
+
nd = r->value.nodeset_value->nodes[0];
|
|
3387
|
+
leptris_xpath_result_free(r);
|
|
3388
|
+
if (nd) return nd;
|
|
3389
|
+
}
|
|
3390
|
+
return ctx->context_node;
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
static struct leptris_xpath_result* fn_innermost(XPathContext* ctx,
|
|
3394
|
+
XPathASTNode** args, size_t n) {
|
|
3395
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
3396
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NODESET);
|
|
3397
|
+
if (!out) { leptris_xpath_result_free(r); return NULL; }
|
|
3398
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
3399
|
+
if (!out->value.nodeset_value) {
|
|
3400
|
+
xpath_result_free(out);
|
|
3401
|
+
leptris_xpath_result_free(r);
|
|
3402
|
+
return NULL;
|
|
3403
|
+
}
|
|
3404
|
+
if (r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value) {
|
|
3405
|
+
XPathNodeSet* src = r->value.nodeset_value;
|
|
3406
|
+
for (size_t i = 0; i < src->count; i++) {
|
|
3407
|
+
int covered = 0;
|
|
3408
|
+
for (LeptrisElement p = leptris_node_parent(src->nodes[i]);
|
|
3409
|
+
p && !covered;
|
|
3410
|
+
p = leptris_node_parent((LeptrisNodeRef)p))
|
|
3411
|
+
for (size_t j = 0; j < src->count; j++)
|
|
3412
|
+
if (src->nodes[j] == (void*)p) { covered = 1; break; }
|
|
3413
|
+
if (!covered)
|
|
3414
|
+
xpath_nodeset_add(out->value.nodeset_value, src->nodes[i]);
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
leptris_xpath_result_free(r);
|
|
3418
|
+
(void)n;
|
|
3419
|
+
return out;
|
|
3420
|
+
}
|
|
3421
|
+
|
|
3422
|
+
static struct leptris_xpath_result* fn_outermost(XPathContext* ctx,
|
|
3423
|
+
XPathASTNode** args, size_t n) {
|
|
3424
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
3425
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NODESET);
|
|
3426
|
+
if (!out) { leptris_xpath_result_free(r); return NULL; }
|
|
3427
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
3428
|
+
if (!out->value.nodeset_value) {
|
|
3429
|
+
xpath_result_free(out);
|
|
3430
|
+
leptris_xpath_result_free(r);
|
|
3431
|
+
return NULL;
|
|
3432
|
+
}
|
|
3433
|
+
if (r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value) {
|
|
3434
|
+
XPathNodeSet* src = r->value.nodeset_value;
|
|
3435
|
+
char* covered = (char*)calloc(src->count ? src->count : 1, 1);
|
|
3436
|
+
if (!covered) {
|
|
3437
|
+
leptris_xpath_result_free(r);
|
|
3438
|
+
return out;
|
|
3439
|
+
}
|
|
3440
|
+
/* A node is dropped when some set member sits below it:
|
|
3441
|
+
* walk every member's ancestor chain and mark matches. */
|
|
3442
|
+
for (size_t j = 0; j < src->count; j++)
|
|
3443
|
+
for (LeptrisElement p = leptris_node_parent(src->nodes[j]); p;
|
|
3444
|
+
p = leptris_node_parent((LeptrisNodeRef)p))
|
|
3445
|
+
for (size_t i = 0; i < src->count; i++)
|
|
3446
|
+
if (src->nodes[i] == (void*)p) covered[i] = 1;
|
|
3447
|
+
for (size_t i = 0; i < src->count; i++)
|
|
3448
|
+
if (!covered[i])
|
|
3449
|
+
xpath_nodeset_add(out->value.nodeset_value, src->nodes[i]);
|
|
3450
|
+
free(covered);
|
|
3451
|
+
}
|
|
3452
|
+
leptris_xpath_result_free(r);
|
|
3453
|
+
(void)n;
|
|
3454
|
+
return out;
|
|
3455
|
+
}
|
|
3456
|
+
|
|
3457
|
+
static struct leptris_xpath_result* fn_has_children(XPathContext* ctx,
|
|
3458
|
+
XPathASTNode** args, size_t n) {
|
|
3459
|
+
void* nd = node_arg_or_ctx(ctx, args, n, 0);
|
|
3460
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
3461
|
+
if (!out) return NULL;
|
|
3462
|
+
out->value.boolean_value = nd && leptris_node_first_child(nd) != NULL;
|
|
3463
|
+
return out;
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
static struct leptris_xpath_result* fn_nilled(XPathContext* ctx,
|
|
3467
|
+
XPathASTNode** args, size_t n) {
|
|
3468
|
+
void* nd = node_arg_or_ctx(ctx, args, n, 0);
|
|
3469
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
3470
|
+
if (!out) return NULL;
|
|
3471
|
+
out->value.boolean_value = 0;
|
|
3472
|
+
if (nd && leptris_node_get_type(nd) == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
3473
|
+
const char* v = leptris_element_attribute((LeptrisElement)nd,
|
|
3474
|
+
"xsi:nil");
|
|
3475
|
+
out->value.boolean_value = v && strcmp(v, "true") == 0;
|
|
3476
|
+
}
|
|
3477
|
+
return out;
|
|
3478
|
+
}
|
|
3479
|
+
|
|
3480
|
+
static int path_append(char** b, size_t* len, size_t* cap,
|
|
3481
|
+
const char* s) {
|
|
3482
|
+
size_t sl = strlen(s);
|
|
3483
|
+
if (*len + sl + 1 > *cap) {
|
|
3484
|
+
size_t nc = *cap ? *cap : 64;
|
|
3485
|
+
while (nc < *len + sl + 1) nc *= 2;
|
|
3486
|
+
char* g = (char*)realloc(*b, nc);
|
|
3487
|
+
if (!g) return 0;
|
|
3488
|
+
*b = g;
|
|
3489
|
+
*cap = nc;
|
|
3490
|
+
}
|
|
3491
|
+
memcpy(*b + *len, s, sl);
|
|
3492
|
+
*len += sl;
|
|
3493
|
+
return 1;
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
static struct leptris_xpath_result* fn_path(XPathContext* ctx,
|
|
3497
|
+
XPathASTNode** args, size_t n) {
|
|
3498
|
+
void* nd = node_arg_or_ctx(ctx, args, n, 0);
|
|
3499
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
3500
|
+
if (!out) return NULL;
|
|
3501
|
+
out->value.string_value = leptris_strdup("");
|
|
3502
|
+
if (!nd || leptris_node_get_type(nd) != LEPTRIS_NODE_TYPE_ELEMENT)
|
|
3503
|
+
return out;
|
|
3504
|
+
/* Climb to the root, then emit downward with same-name
|
|
3505
|
+
* position predicates where siblings repeat the name. */
|
|
3506
|
+
LeptrisElement chain[256];
|
|
3507
|
+
size_t depth = 0;
|
|
3508
|
+
for (LeptrisElement e = (LeptrisElement)nd; e && depth < 256;
|
|
3509
|
+
e = leptris_node_parent((LeptrisNodeRef)e))
|
|
3510
|
+
chain[depth++] = e;
|
|
3511
|
+
char* b = NULL;
|
|
3512
|
+
size_t bl = 0, bc = 0;
|
|
3513
|
+
for (size_t i = depth; i-- > 0;) {
|
|
3514
|
+
const char* nm = leptris_element_get_name(chain[i]);
|
|
3515
|
+
path_append(&b, &bl, &bc, "/");
|
|
3516
|
+
path_append(&b, &bl, &bc, nm ? nm : "*");
|
|
3517
|
+
size_t same = 0, pos = 0;
|
|
3518
|
+
for (LeptrisNodeRef s = leptris_node_first_child(
|
|
3519
|
+
(LeptrisNodeRef)leptris_node_parent((LeptrisNodeRef)chain[i]));
|
|
3520
|
+
s; s = leptris_node_next_sibling(s)) {
|
|
3521
|
+
if (leptris_node_get_type(s) != LEPTRIS_NODE_TYPE_ELEMENT)
|
|
3522
|
+
continue;
|
|
3523
|
+
const char* snm = leptris_element_get_name((LeptrisElement)s);
|
|
3524
|
+
if (!nm || (snm && strcmp(snm, nm) == 0)) {
|
|
3525
|
+
same++;
|
|
3526
|
+
if (s == (LeptrisNodeRef)chain[i]) pos = same;
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
if (same > 1) {
|
|
3530
|
+
char idx[32];
|
|
3531
|
+
snprintf(idx, sizeof(idx), "[%zu]", pos);
|
|
3532
|
+
path_append(&b, &bl, &bc, idx);
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
if (b) {
|
|
3536
|
+
free(out->value.string_value);
|
|
3537
|
+
b[bl] = 0;
|
|
3538
|
+
out->value.string_value = b;
|
|
3539
|
+
}
|
|
3540
|
+
return out;
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
/* In-memory documents carry no base or document URI. */
|
|
3544
|
+
static struct leptris_xpath_result* fn_base_uri(XPathContext* ctx,
|
|
3545
|
+
XPathASTNode** args, size_t n) {
|
|
3546
|
+
node_arg_or_ctx(ctx, args, n, 0);
|
|
3547
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
3548
|
+
if (!out) return NULL;
|
|
3549
|
+
out->value.string_value = leptris_strdup("");
|
|
3550
|
+
return out;
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
static struct leptris_xpath_result* fn_uri_constant(XPathContext* ctx,
|
|
3554
|
+
XPathASTNode** args, size_t n) {
|
|
3555
|
+
(void)ctx; (void)args; (void)n;
|
|
3556
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
3557
|
+
if (!out) return NULL;
|
|
3558
|
+
out->value.string_value = leptris_strdup("");
|
|
3559
|
+
return out;
|
|
3560
|
+
}
|
|
3561
|
+
|
|
3562
|
+
static struct leptris_xpath_result* fn_doc_available(XPathContext* ctx,
|
|
3563
|
+
XPathASTNode** args, size_t n) {
|
|
3564
|
+
char* path = re_str_arg(ctx, args, 0);
|
|
3565
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
3566
|
+
if (!out) { free(path); return NULL; }
|
|
3567
|
+
out->value.boolean_value = 0;
|
|
3568
|
+
if (path) {
|
|
3569
|
+
LeptrisDocument d = leptris_parse_file(path, NULL);
|
|
3570
|
+
if (d) {
|
|
3571
|
+
out->value.boolean_value = 1;
|
|
3572
|
+
leptris_document_free(d);
|
|
3573
|
+
}
|
|
3574
|
+
free(path);
|
|
3575
|
+
}
|
|
3576
|
+
(void)n;
|
|
3577
|
+
return out;
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
static struct leptris_xpath_result* fn_json_doc(XPathContext* ctx,
|
|
3581
|
+
XPathASTNode** args, size_t n) {
|
|
3582
|
+
(void)n;
|
|
3583
|
+
char* path = re_str_arg(ctx, args, 0);
|
|
3584
|
+
if (!path) return NULL;
|
|
3585
|
+
FILE* f = fopen(path, "rb");
|
|
3586
|
+
free(path);
|
|
3587
|
+
struct leptris_xpath_result* out = NULL;
|
|
3588
|
+
if (f) {
|
|
3589
|
+
fseek(f, 0, SEEK_END);
|
|
3590
|
+
long sz = ftell(f);
|
|
3591
|
+
fseek(f, 0, SEEK_SET);
|
|
3592
|
+
char* buf = (char*)malloc(sz > 0 ? (size_t)sz + 1 : 1);
|
|
3593
|
+
if (buf) {
|
|
3594
|
+
size_t got = fread(buf, 1, (size_t)sz, f);
|
|
3595
|
+
buf[got] = 0;
|
|
3596
|
+
JsonScan s = { buf, 1 };
|
|
3597
|
+
out = json_root(&s);
|
|
3598
|
+
free(buf);
|
|
3599
|
+
}
|
|
3600
|
+
fclose(f);
|
|
3601
|
+
}
|
|
3602
|
+
if (!out) {
|
|
3603
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
3604
|
+
"json-doc(): cannot load JSON");
|
|
3605
|
+
snprintf(ctx->error_code, sizeof(ctx->error_code), "FODC0002");
|
|
3606
|
+
return NULL;
|
|
3607
|
+
}
|
|
3608
|
+
return out;
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
/* ---- scalar tail (#691 slice 2) ---- */
|
|
3612
|
+
|
|
3613
|
+
/* Like re_str_arg, but an EMPTY SEQUENCE argument yields NULL
|
|
3614
|
+
* (fn:compare's empty-operand rule; re_str_arg stringifies empty
|
|
3615
|
+
* nodesets to ""). */
|
|
3616
|
+
static char* re_str_arg_opt(XPathContext* ctx, XPathASTNode** args,
|
|
3617
|
+
size_t i) {
|
|
3618
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[i]);
|
|
3619
|
+
if (!r) return NULL;
|
|
3620
|
+
if (r->type == XPATH_RESULT_NODESET &&
|
|
3621
|
+
(!r->value.nodeset_value || r->value.nodeset_value->count == 0)) {
|
|
3622
|
+
leptris_xpath_result_free(r);
|
|
3623
|
+
return NULL;
|
|
3624
|
+
}
|
|
3625
|
+
char* s = (r->type == XPATH_RESULT_NODESET)
|
|
3626
|
+
? leptris_xpath_result_string(r)
|
|
3627
|
+
: scalar_str(r);
|
|
3628
|
+
leptris_xpath_result_free(r);
|
|
3629
|
+
return s;
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
static struct leptris_xpath_result* fn_compare(XPathContext* ctx,
|
|
3633
|
+
XPathASTNode** args, size_t n) {
|
|
3634
|
+
char* a = re_str_arg_opt(ctx, args, 0);
|
|
3635
|
+
char* b = re_str_arg_opt(ctx, args, 1);
|
|
3636
|
+
struct leptris_xpath_result* out = NULL;
|
|
3637
|
+
if (a && b) { /* an empty operand yields the empty sequence */
|
|
3638
|
+
out = xpath_result_new(XPATH_RESULT_NUMBER);
|
|
3639
|
+
if (out)
|
|
3640
|
+
out->value.number_value =
|
|
3641
|
+
strcmp(a, b) < 0 ? -1 : strcmp(a, b) > 0 ? 1 : 0;
|
|
3642
|
+
} else {
|
|
3643
|
+
out = xpath_result_new(XPATH_RESULT_NODESET);
|
|
3644
|
+
if (out) out->value.nodeset_value = xpath_nodeset_new();
|
|
3645
|
+
}
|
|
3646
|
+
free(a);
|
|
3647
|
+
free(b);
|
|
3648
|
+
(void)n;
|
|
3649
|
+
return out;
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3652
|
+
static struct leptris_xpath_result* fn_codepoint_equal(XPathContext* ctx,
|
|
3653
|
+
XPathASTNode** args, size_t n) {
|
|
3654
|
+
char* a = re_str_arg(ctx, args, 0);
|
|
3655
|
+
char* b = re_str_arg(ctx, args, 1);
|
|
3656
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
3657
|
+
if (!out) { free(a); free(b); return NULL; }
|
|
3658
|
+
out->value.boolean_value =
|
|
3659
|
+
a && b && strcmp(a, b) == 0; /* empty operand -> false */
|
|
3660
|
+
free(a);
|
|
3661
|
+
free(b);
|
|
3662
|
+
(void)n;
|
|
3663
|
+
return out;
|
|
3664
|
+
}
|
|
3665
|
+
|
|
3666
|
+
#ifdef LEPTRIS_HAS_UTF8PROC
|
|
3667
|
+
static struct leptris_xpath_result* fn_normalize_unicode(XPathContext* ctx,
|
|
3668
|
+
XPathASTNode** args, size_t n) {
|
|
3669
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
3670
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
3671
|
+
if (!out) { free(in); return NULL; }
|
|
3672
|
+
out->value.string_value = in;
|
|
3673
|
+
if (n >= 2) {
|
|
3674
|
+
char* form = re_str_arg(ctx, args, 1);
|
|
3675
|
+
leptris_unicode_normalization_t f = LEPTRIS_UNICODE_NFC;
|
|
3676
|
+
if (form) {
|
|
3677
|
+
if (strcmp(form, "NFD") == 0) f = LEPTRIS_UNICODE_NFD;
|
|
3678
|
+
else if (strcmp(form, "NFKC") == 0) f = LEPTRIS_UNICODE_NFKC;
|
|
3679
|
+
else if (strcmp(form, "NFKD") == 0) f = LEPTRIS_UNICODE_NFKD;
|
|
3680
|
+
free(form);
|
|
3681
|
+
}
|
|
3682
|
+
size_t ol = 0;
|
|
3683
|
+
char* norm = leptris_unicode_normalize(in ? in : "",
|
|
3684
|
+
in ? strlen(in) : 0, f, &ol);
|
|
3685
|
+
if (norm) {
|
|
3686
|
+
free(in);
|
|
3687
|
+
out->value.string_value = norm;
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
return out;
|
|
3691
|
+
}
|
|
3692
|
+
#endif
|
|
3693
|
+
|
|
3694
|
+
static struct leptris_xpath_result* fn_resolve_qname(XPathContext* ctx,
|
|
3695
|
+
XPathASTNode** args, size_t n) {
|
|
3696
|
+
char* qn = re_str_arg(ctx, args, 0);
|
|
3697
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
3698
|
+
if (!out) { free(qn); return NULL; }
|
|
3699
|
+
out->value.string_value = leptris_strdup(qn ? qn : "");
|
|
3700
|
+
LeptrisElement e = NULL;
|
|
3701
|
+
if (n >= 2) {
|
|
3702
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[1]);
|
|
3703
|
+
if (r && r->type == XPATH_RESULT_NODESET &&
|
|
3704
|
+
r->value.nodeset_value && r->value.nodeset_value->count) {
|
|
3705
|
+
void* nd = r->value.nodeset_value->nodes[0];
|
|
3706
|
+
if (leptris_node_get_type(nd) == LEPTRIS_NODE_TYPE_ELEMENT)
|
|
3707
|
+
e = (LeptrisElement)nd;
|
|
3708
|
+
}
|
|
3709
|
+
leptris_xpath_result_free(r);
|
|
3710
|
+
}
|
|
3711
|
+
if (qn) {
|
|
3712
|
+
const char* colon = strchr(qn, ':');
|
|
3713
|
+
char prefix[128];
|
|
3714
|
+
const char* uri = NULL;
|
|
3715
|
+
if (colon) {
|
|
3716
|
+
size_t pl = (size_t)(colon - qn);
|
|
3717
|
+
if (pl < sizeof(prefix)) {
|
|
3718
|
+
memcpy(prefix, qn, pl);
|
|
3719
|
+
prefix[pl] = 0;
|
|
3720
|
+
uri = e ? leptris_element_namespace_for_prefix(e, prefix)
|
|
3721
|
+
: NULL;
|
|
3722
|
+
}
|
|
3723
|
+
} else {
|
|
3724
|
+
uri = e ? leptris_element_namespace_for_prefix(e, "") : NULL;
|
|
3725
|
+
}
|
|
3726
|
+
snprintf(last_qname_uri, sizeof(last_qname_uri), "%s",
|
|
3727
|
+
uri ? uri : "");
|
|
3728
|
+
}
|
|
3729
|
+
free(qn);
|
|
3730
|
+
return out;
|
|
3731
|
+
}
|
|
3732
|
+
|
|
3733
|
+
static struct leptris_xpath_result* fn_environment_variable(
|
|
3734
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
3735
|
+
char* name = re_str_arg(ctx, args, 0);
|
|
3736
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
3737
|
+
if (!out) { free(name); return NULL; }
|
|
3738
|
+
const char* v = name ? getenv(name) : NULL;
|
|
3739
|
+
out->value.string_value = leptris_strdup(v ? v : "");
|
|
3740
|
+
free(name);
|
|
3741
|
+
(void)n;
|
|
3742
|
+
return out;
|
|
3743
|
+
}
|
|
3744
|
+
|
|
3745
|
+
#ifdef _WIN32
|
|
3746
|
+
extern char** _environ; /* MSVC CRT (MBCS build) */
|
|
3747
|
+
#define LEPTRIS_ENVIRON _environ
|
|
3748
|
+
#else
|
|
3749
|
+
extern char** environ;
|
|
3750
|
+
#define LEPTRIS_ENVIRON environ
|
|
3751
|
+
#endif
|
|
3752
|
+
|
|
3753
|
+
static struct leptris_xpath_result* fn_available_env_vars(XPathContext* ctx,
|
|
3754
|
+
XPathASTNode** args, size_t n) {
|
|
3755
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3756
|
+
if (!out) return NULL;
|
|
3757
|
+
for (char** e = LEPTRIS_ENVIRON; e && *e; e++) {
|
|
3758
|
+
const char* eq = strchr(*e, '=');
|
|
3759
|
+
if (!eq) continue;
|
|
3760
|
+
size_t nl = (size_t)(eq - *e);
|
|
3761
|
+
char* name = (char*)malloc(nl + 1);
|
|
3762
|
+
if (!name) continue;
|
|
3763
|
+
memcpy(name, *e, nl);
|
|
3764
|
+
name[nl] = 0;
|
|
3765
|
+
seq_push_str(out, name);
|
|
3766
|
+
free(name);
|
|
3767
|
+
}
|
|
3768
|
+
(void)ctx; (void)args; (void)n;
|
|
3769
|
+
return out;
|
|
3770
|
+
}
|
|
3771
|
+
|
|
3772
|
+
/* #691 stragglers: the unparsed-text family over a raw file read
|
|
3773
|
+
* (same loader json-doc uses) and the empty catalog uri-collection. */
|
|
3774
|
+
static char* read_file_text(const char* path, size_t* out_len) {
|
|
3775
|
+
FILE* f = fopen(path, "rb");
|
|
3776
|
+
if (!f) return NULL;
|
|
3777
|
+
fseek(f, 0, SEEK_END);
|
|
3778
|
+
long sz = ftell(f);
|
|
3779
|
+
fseek(f, 0, SEEK_SET);
|
|
3780
|
+
char* buf = (char*)malloc(sz > 0 ? (size_t)sz + 1 : 1);
|
|
3781
|
+
if (!buf) { fclose(f); return NULL; }
|
|
3782
|
+
size_t got = fread(buf, 1, (size_t)sz, f);
|
|
3783
|
+
buf[got] = 0;
|
|
3784
|
+
fclose(f);
|
|
3785
|
+
if (out_len) *out_len = got;
|
|
3786
|
+
return buf;
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
static struct leptris_xpath_result* fn_unparsed_text(XPathContext* ctx,
|
|
3790
|
+
XPathASTNode** args, size_t n) {
|
|
3791
|
+
char* path = re_str_arg(ctx, args, 0);
|
|
3792
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
3793
|
+
if (!out) { free(path); return NULL; }
|
|
3794
|
+
out->value.string_value = leptris_strdup("");
|
|
3795
|
+
if (path) {
|
|
3796
|
+
size_t len = 0;
|
|
3797
|
+
char* buf = read_file_text(path, &len);
|
|
3798
|
+
free(path);
|
|
3799
|
+
if (!buf) {
|
|
3800
|
+
xpath_result_free(out);
|
|
3801
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
3802
|
+
"unparsed-text(): cannot load text");
|
|
3803
|
+
snprintf(ctx->error_code, sizeof(ctx->error_code), "FODC0002");
|
|
3804
|
+
return NULL;
|
|
3805
|
+
}
|
|
3806
|
+
free(out->value.string_value);
|
|
3807
|
+
out->value.string_value = buf;
|
|
3808
|
+
}
|
|
3809
|
+
(void)n;
|
|
3810
|
+
return out;
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
static struct leptris_xpath_result* fn_unparsed_text_lines(
|
|
3814
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
3815
|
+
char* path = re_str_arg(ctx, args, 0);
|
|
3816
|
+
if (!path) return NULL;
|
|
3817
|
+
size_t len = 0;
|
|
3818
|
+
char* buf = read_file_text(path, &len);
|
|
3819
|
+
free(path);
|
|
3820
|
+
if (!buf) {
|
|
3821
|
+
snprintf(ctx->error_msg, sizeof(ctx->error_msg),
|
|
3822
|
+
"unparsed-text-lines(): cannot load text");
|
|
3823
|
+
snprintf(ctx->error_code, sizeof(ctx->error_code), "FODC0002");
|
|
3824
|
+
return NULL;
|
|
3825
|
+
}
|
|
3826
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3827
|
+
if (!out) { free(buf); return NULL; }
|
|
3828
|
+
char* p = buf;
|
|
3829
|
+
while (p < buf + len) {
|
|
3830
|
+
char* nl = (char*)memchr(p, '\n', (size_t)(buf + len - p));
|
|
3831
|
+
char* end = nl ? nl : buf + len;
|
|
3832
|
+
char saved = *end;
|
|
3833
|
+
*end = 0;
|
|
3834
|
+
seq_push_str(out, p);
|
|
3835
|
+
*end = saved;
|
|
3836
|
+
p = nl ? nl + 1 : buf + len;
|
|
3837
|
+
}
|
|
3838
|
+
if (len > 0 && buf[len - 1] == '\n' && out->value.nodeset_value &&
|
|
3839
|
+
out->value.nodeset_value->count)
|
|
3840
|
+
out->value.nodeset_value->count--; /* no trailing empty line */
|
|
3841
|
+
free(buf);
|
|
3842
|
+
(void)n;
|
|
3843
|
+
return out;
|
|
3844
|
+
}
|
|
3845
|
+
|
|
3846
|
+
static struct leptris_xpath_result* fn_unparsed_text_available(
|
|
3847
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
3848
|
+
char* path = re_str_arg(ctx, args, 0);
|
|
3849
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_BOOLEAN);
|
|
3850
|
+
if (!out) { free(path); return NULL; }
|
|
3851
|
+
out->value.boolean_value = 0;
|
|
3852
|
+
if (path) {
|
|
3853
|
+
size_t len = 0;
|
|
3854
|
+
char* buf = read_file_text(path, &len);
|
|
3855
|
+
if (buf) {
|
|
3856
|
+
out->value.boolean_value = 1;
|
|
3857
|
+
free(buf);
|
|
3858
|
+
}
|
|
3859
|
+
free(path);
|
|
3860
|
+
}
|
|
3861
|
+
(void)n;
|
|
3862
|
+
return out;
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
static struct leptris_xpath_result* fn_uri_collection(XPathContext* ctx,
|
|
3866
|
+
XPathASTNode** args, size_t n) {
|
|
3867
|
+
struct leptris_xpath_result* out = seq_new();
|
|
3868
|
+
(void)ctx; (void)args; (void)n;
|
|
3869
|
+
return out;
|
|
3870
|
+
}
|
|
3871
|
+
|
|
3872
|
+
/* #691: fn:random-number-generator. The map carries 'number'
|
|
3873
|
+
* only — 'next' and 'permute' are function-item closures (the
|
|
3874
|
+
* value-level model has no per-call callable state; tracked in
|
|
3875
|
+
* TODO.xslt-full/04). Seeded calls are deterministic (xorshift64*
|
|
3876
|
+
* over an FNV-1a of the seed); unseeded calls mix the clock. */
|
|
3877
|
+
static struct leptris_xpath_result* fn_random_number_generator(
|
|
3878
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
3879
|
+
char* seed = (n >= 1) ? re_str_arg(ctx, args, 0) : NULL;
|
|
3880
|
+
unsigned long long st;
|
|
3881
|
+
if (seed) {
|
|
3882
|
+
st = 1469598103934665603ULL;
|
|
3883
|
+
for (const char* p = seed; *p; p++) {
|
|
3884
|
+
st ^= (unsigned char)*p;
|
|
3885
|
+
st *= 1099511628211ULL;
|
|
3886
|
+
}
|
|
3887
|
+
} else {
|
|
3888
|
+
st = (unsigned long long)time(NULL) * 6364136223846793005ULL
|
|
3889
|
+
^ (unsigned long long)(uintptr_t)ctx;
|
|
3890
|
+
}
|
|
3891
|
+
st ^= st >> 12; st ^= st << 25; st ^= st >> 27;
|
|
3892
|
+
st *= 2685821657736338717ULL;
|
|
3893
|
+
double v = (double)(st >> 11) / 9007199254740992.0;
|
|
3894
|
+
|
|
3895
|
+
char numbuf[64];
|
|
3896
|
+
snprintf(numbuf, sizeof(numbuf), "%.17g", v);
|
|
3897
|
+
char* content = (char*)malloc(12 + strlen(numbuf) + 1);
|
|
3898
|
+
struct leptris_xpath_result* out =
|
|
3899
|
+
xpath_result_new(XPATH_RESULT_NODESET);
|
|
3900
|
+
if (!content || !out) {
|
|
3901
|
+
free(content);
|
|
3902
|
+
xpath_result_free(out);
|
|
3903
|
+
free(seed);
|
|
3904
|
+
return NULL;
|
|
3905
|
+
}
|
|
3906
|
+
sprintf(content, "\x03MAP\x02number\x01%s", numbuf);
|
|
3907
|
+
XPathTextNode* tn = xpath_synth_text(content, strlen(content));
|
|
3908
|
+
free(content);
|
|
3909
|
+
free(seed);
|
|
3910
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
3911
|
+
if (!out->value.nodeset_value || !tn) {
|
|
3912
|
+
xpath_result_free(out);
|
|
3913
|
+
return NULL;
|
|
3914
|
+
}
|
|
3915
|
+
out->value.nodeset_value->owns_synthetic_text = 1;
|
|
3916
|
+
out->value.nodeset_value->is_sequence = 1;
|
|
3917
|
+
xpath_nodeset_add(out->value.nodeset_value, tn);
|
|
3918
|
+
return out;
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3921
|
+
/* #691: fn:format-number outside XSLT — the shared JDK pattern
|
|
3922
|
+
* core under the DEFAULT decimal format (named decimal formats
|
|
3923
|
+
* need the xsl:decimal-format context the XSLT bridge supplies). */
|
|
3924
|
+
static struct leptris_xpath_result* fn_format_number_plain(
|
|
3925
|
+
XPathContext* ctx, XPathASTNode** args, size_t n) {
|
|
3926
|
+
struct leptris_xpath_result* v = xpath_evaluate(ctx, args[0]);
|
|
3927
|
+
if (!v) return NULL;
|
|
3928
|
+
double num = leptris_xpath_result_number(v);
|
|
3929
|
+
leptris_xpath_result_free(v);
|
|
3930
|
+
char* pat = re_str_arg(ctx, args, 1);
|
|
3931
|
+
char* out_s = pat ? leptris_format_number_core(num, pat,
|
|
3932
|
+
leptris_format_number_default()) : NULL;
|
|
3933
|
+
free(pat);
|
|
3934
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_STRING);
|
|
3935
|
+
if (!out) { free(out_s); return NULL; }
|
|
3936
|
+
out->value.string_value = out_s ? out_s : leptris_strdup("");
|
|
3937
|
+
(void)n;
|
|
3938
|
+
return out;
|
|
3939
|
+
}
|
|
3940
|
+
|
|
3941
|
+
/* Anchor a constructed-node document on the SOURCE document
|
|
3942
|
+
* (#691): plain leptris_xpath_eval frees the context before the
|
|
3943
|
+
* result is consumed, so the ctx owned_docs chain cannot carry
|
|
3944
|
+
* constructed nodes; the source doc's lifetime is the only owner
|
|
3945
|
+
* that outlives the result. */
|
|
3946
|
+
static int xq_anchor_on_source(XPathContext* ctx,
|
|
3947
|
+
struct leptris_document* anchored) {
|
|
3948
|
+
struct leptris_document* src = ctx->document;
|
|
3949
|
+
if (!src) {
|
|
3950
|
+
leptris_document_free(anchored);
|
|
3951
|
+
return -1;
|
|
3952
|
+
}
|
|
3953
|
+
if (src->n_anchored_docs == src->cap_anchored_docs) {
|
|
3954
|
+
size_t nc = src->cap_anchored_docs
|
|
3955
|
+
? src->cap_anchored_docs * 2 : 4;
|
|
3956
|
+
struct leptris_document** grown = (struct leptris_document**)
|
|
3957
|
+
realloc(src->anchored_docs, nc * sizeof(*grown));
|
|
3958
|
+
if (!grown) {
|
|
3959
|
+
leptris_document_free(anchored);
|
|
3960
|
+
return -1;
|
|
3961
|
+
}
|
|
3962
|
+
src->anchored_docs = grown;
|
|
3963
|
+
src->cap_anchored_docs = nc;
|
|
3964
|
+
}
|
|
3965
|
+
src->anchored_docs[src->n_anchored_docs++] = anchored;
|
|
3966
|
+
return 0;
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3969
|
+
/* #691: fn:snapshot — detached deep copies of the input elements
|
|
3970
|
+
* on a fresh document anchored on the SOURCE tree. */
|
|
3971
|
+
static struct leptris_xpath_result* fn_snapshot(XPathContext* ctx,
|
|
3972
|
+
XPathASTNode** args, size_t n) {
|
|
3973
|
+
struct leptris_xpath_result* r = xpath_evaluate(ctx, args[0]);
|
|
3974
|
+
struct leptris_xpath_result* out = xpath_result_new(XPATH_RESULT_NODESET);
|
|
3975
|
+
if (!out) { leptris_xpath_result_free(r); return NULL; }
|
|
3976
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
3977
|
+
if (!out->value.nodeset_value) {
|
|
3978
|
+
xpath_result_free(out);
|
|
3979
|
+
leptris_xpath_result_free(r);
|
|
3980
|
+
return NULL;
|
|
3981
|
+
}
|
|
3982
|
+
if (r && r->type == XPATH_RESULT_NODESET && r->value.nodeset_value &&
|
|
3983
|
+
r->value.nodeset_value->count) {
|
|
3984
|
+
LeptrisDocument doc = leptris_document_create();
|
|
3985
|
+
LeptrisElement wrap = doc ? leptris_element_create(doc, "snapshot")
|
|
3986
|
+
: NULL;
|
|
3987
|
+
if (wrap) {
|
|
3988
|
+
XPathNodeSet* src = r->value.nodeset_value;
|
|
3989
|
+
for (size_t i = 0; i < src->count; i++) {
|
|
3990
|
+
void* nd = src->nodes[i];
|
|
3991
|
+
if (leptris_node_get_type(nd) != LEPTRIS_NODE_TYPE_ELEMENT)
|
|
3992
|
+
continue;
|
|
3993
|
+
LeptrisElement c = leptris_element_append_copy(
|
|
3994
|
+
wrap, (LeptrisElement)nd);
|
|
3995
|
+
if (c) xpath_nodeset_add(out->value.nodeset_value, c);
|
|
3996
|
+
}
|
|
3997
|
+
if (xq_anchor_on_source(ctx, doc) != 0) {
|
|
3998
|
+
xpath_result_free(out);
|
|
3999
|
+
leptris_xpath_result_free(r);
|
|
4000
|
+
return NULL;
|
|
4001
|
+
}
|
|
4002
|
+
} else if (doc) {
|
|
4003
|
+
leptris_document_free(doc);
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
leptris_xpath_result_free(r);
|
|
4007
|
+
(void)n;
|
|
4008
|
+
return out;
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
#ifdef LEPTRIS_HAVE_POSIX_RE
|
|
4012
|
+
/* #691: fn:analyze-string — the fn:match / fn:non-match element
|
|
4013
|
+
* model (fn:group children carry @nr) built on a fresh document
|
|
4014
|
+
* anchored on the SOURCE tree (the anchor chain snapshot shipped).
|
|
4015
|
+
* POSIX regex with the same flag translation fn:matches uses. */
|
|
4016
|
+
static void analyze_append_text(LeptrisDocument doc, LeptrisElement parent,
|
|
4017
|
+
const char* p, size_t n) {
|
|
4018
|
+
if (!n) return;
|
|
4019
|
+
char* buf = (char*)malloc(n + 1);
|
|
4020
|
+
if (!buf) return;
|
|
4021
|
+
memcpy(buf, p, n);
|
|
4022
|
+
buf[n] = 0;
|
|
4023
|
+
LeptrisNodeRef tn = leptris_text_node_create(doc, buf);
|
|
4024
|
+
free(buf);
|
|
4025
|
+
if (tn) leptris_element_append_child(parent, (LeptrisElement)tn);
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
static struct leptris_xpath_result* fn_analyze_string(XPathContext* ctx,
|
|
4029
|
+
XPathASTNode** args, size_t n) {
|
|
4030
|
+
char* in = re_str_arg(ctx, args, 0);
|
|
4031
|
+
char* pat = re_str_arg(ctx, args, 1);
|
|
4032
|
+
char* fl = (n >= 3) ? re_str_arg(ctx, args, 2) : leptris_strdup("");
|
|
4033
|
+
if (!in || !pat) { free(in); free(pat); free(fl); return NULL; }
|
|
4034
|
+
char* xp = re_pattern_for(pat, fl);
|
|
4035
|
+
struct leptris_xpath_result* out = NULL;
|
|
4036
|
+
regex_t rx;
|
|
4037
|
+
if (xp && regcomp(&rx, xp, re_flags(fl)) == 0) {
|
|
4038
|
+
LeptrisDocument doc = leptris_document_create();
|
|
4039
|
+
LeptrisElement root =
|
|
4040
|
+
doc ? leptris_element_create(doc, "fn:analyze-string") : NULL;
|
|
4041
|
+
if (root) {
|
|
4042
|
+
/* F+O model: the result carries the functions namespace,
|
|
4043
|
+
* resolvable through one root declaration (#846). */
|
|
4044
|
+
leptris_element_add_namespace_definition(
|
|
4045
|
+
root, "fn", "http://www.w3.org/2005/xpath-functions");
|
|
4046
|
+
regmatch_t pm[12];
|
|
4047
|
+
/* #857: ask for exactly re_nsub+1 slots — BSD regexec
|
|
4048
|
+
* leaves the remainder untouched, so stale stack data
|
|
4049
|
+
* (from a previous analyze-string call) read as phantom
|
|
4050
|
+
* groups and corrupted the match/group spans. */
|
|
4051
|
+
const size_t nmatch =
|
|
4052
|
+
(size_t)rx.re_nsub + 1 <= 12 ? (size_t)rx.re_nsub + 1 : 12;
|
|
4053
|
+
const int max_group = (int)nmatch - 1;
|
|
4054
|
+
const char* p = in;
|
|
4055
|
+
while (*p && regexec(&rx, p, nmatch, pm, 0) == 0) {
|
|
4056
|
+
if (pm[0].rm_so > 0) {
|
|
4057
|
+
LeptrisElement nm =
|
|
4058
|
+
leptris_element_create(doc, "fn:non-match");
|
|
4059
|
+
if (nm) {
|
|
4060
|
+
analyze_append_text(doc, nm, p,
|
|
4061
|
+
(size_t)pm[0].rm_so);
|
|
4062
|
+
leptris_element_append_child(root, nm);
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
LeptrisElement m = leptris_element_create(doc, "fn:match");
|
|
4066
|
+
if (m) {
|
|
4067
|
+
/* POSIX pmatch offsets are SUBJECT-relative (to
|
|
4068
|
+
* p, not the match start) — #857: basing them at
|
|
4069
|
+
* the match start read past the match whenever
|
|
4070
|
+
* the match did not begin at offset 0. */
|
|
4071
|
+
regoff_t prev = pm[0].rm_so;
|
|
4072
|
+
char nrbuf[8];
|
|
4073
|
+
for (int g = 1; g <= max_group; g++) {
|
|
4074
|
+
if (pm[g].rm_so < 0) break;
|
|
4075
|
+
analyze_append_text(doc, m, p + prev,
|
|
4076
|
+
(size_t)(pm[g].rm_so - prev));
|
|
4077
|
+
LeptrisElement ge =
|
|
4078
|
+
leptris_element_create(doc, "fn:group");
|
|
4079
|
+
snprintf(nrbuf, sizeof(nrbuf), "%d", g);
|
|
4080
|
+
leptris_element_set_attribute(ge, "nr", nrbuf);
|
|
4081
|
+
analyze_append_text(doc, ge, p + pm[g].rm_so,
|
|
4082
|
+
(size_t)(pm[g].rm_eo -
|
|
4083
|
+
pm[g].rm_so));
|
|
4084
|
+
leptris_element_append_child(m, ge);
|
|
4085
|
+
prev = pm[g].rm_eo;
|
|
4086
|
+
}
|
|
4087
|
+
analyze_append_text(doc, m, p + prev,
|
|
4088
|
+
(size_t)(pm[0].rm_eo - prev));
|
|
4089
|
+
leptris_element_append_child(root, m);
|
|
4090
|
+
}
|
|
4091
|
+
if (pm[0].rm_eo == pm[0].rm_so) {
|
|
4092
|
+
/* zero-length match: emit the char, advance one
|
|
4093
|
+
* byte (UTF-8 self-synchronizing boundary is
|
|
4094
|
+
* acceptable for the value-level model). */
|
|
4095
|
+
LeptrisElement nm =
|
|
4096
|
+
leptris_element_create(doc, "fn:non-match");
|
|
4097
|
+
if (nm) {
|
|
4098
|
+
analyze_append_text(doc, nm, p, 1);
|
|
4099
|
+
leptris_element_append_child(root, nm);
|
|
4100
|
+
}
|
|
4101
|
+
p++;
|
|
4102
|
+
} else {
|
|
4103
|
+
p += pm[0].rm_eo;
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
if (*p) {
|
|
4107
|
+
LeptrisElement nm =
|
|
4108
|
+
leptris_element_create(doc, "fn:non-match");
|
|
4109
|
+
if (nm) {
|
|
4110
|
+
analyze_append_text(doc, nm, p, strlen(p));
|
|
4111
|
+
leptris_element_append_child(root, nm);
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
4114
|
+
out = xpath_result_new(XPATH_RESULT_NODESET);
|
|
4115
|
+
if (out) {
|
|
4116
|
+
out->value.nodeset_value = xpath_nodeset_new();
|
|
4117
|
+
if (!out->value.nodeset_value) {
|
|
4118
|
+
xpath_result_free(out);
|
|
4119
|
+
out = NULL;
|
|
4120
|
+
} else {
|
|
4121
|
+
xpath_nodeset_add(out->value.nodeset_value, root);
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
if (!out || xq_anchor_on_source(ctx, doc) != 0) {
|
|
4125
|
+
if (out) { xpath_result_free(out); out = NULL; }
|
|
4126
|
+
}
|
|
4127
|
+
} else if (doc) {
|
|
4128
|
+
leptris_document_free(doc);
|
|
4129
|
+
}
|
|
4130
|
+
regfree(&rx);
|
|
4131
|
+
}
|
|
4132
|
+
if (!out) {
|
|
4133
|
+
out = xpath_result_new(XPATH_RESULT_STRING);
|
|
4134
|
+
if (out) out->value.string_value = leptris_strdup("");
|
|
4135
|
+
}
|
|
4136
|
+
free(xp);
|
|
4137
|
+
free(in);
|
|
4138
|
+
free(pat);
|
|
4139
|
+
free(fl);
|
|
4140
|
+
return out;
|
|
4141
|
+
}
|
|
4142
|
+
#endif
|
|
4143
|
+
|
|
4144
|
+
void xpath_register_fn31(XPathFunctionRegistry* registry) {
|
|
4145
|
+
if (!registry) return;
|
|
4146
|
+
xpath_function_registry_register(registry, "exists", fn_exists, 1, 1);
|
|
4147
|
+
xpath_function_registry_register(registry, "empty", fn_empty, 1, 1);
|
|
4148
|
+
xpath_function_registry_register(registry, "head", fn_head, 1, 1);
|
|
4149
|
+
xpath_function_registry_register(registry, "tail", fn_tail, 1, 1);
|
|
4150
|
+
xpath_function_registry_register(registry, "reverse", fn_reverse, 1, 1);
|
|
4151
|
+
xpath_function_registry_register(registry, "unordered", fn_unordered, 1, 1);
|
|
4152
|
+
xpath_function_registry_register(registry, "doc", fn_doc, 1, 1);
|
|
4153
|
+
xpath_function_registry_register(registry, "parse-xml",
|
|
4154
|
+
fn_parse_xml, 1, 1);
|
|
4155
|
+
xpath_function_registry_register(registry, "parse-xml-fragment",
|
|
4156
|
+
fn_parse_xml_fragment, 1, 1);
|
|
4157
|
+
xpath_function_registry_register(registry, "collection",
|
|
4158
|
+
fn_collection, 0, 1);
|
|
4159
|
+
xpath_function_registry_register(registry, "subsequence", fn_subsequence, 2, 3);
|
|
4160
|
+
xpath_function_registry_register(registry, "remove", fn_remove, 2, 2);
|
|
4161
|
+
xpath_function_registry_register(registry, "insert-before", fn_insert_before, 3, 3);
|
|
4162
|
+
xpath_function_registry_register(registry, "index-of", fn_index_of, 2, 2);
|
|
4163
|
+
xpath_function_registry_register(registry, "distinct-values", fn_distinct_values, 1, 1);
|
|
4164
|
+
xpath_function_registry_register(registry, "avg", fn_avg, 1, 1);
|
|
4165
|
+
xpath_function_registry_register(registry, "min", fn_min, 1, 1);
|
|
4166
|
+
xpath_function_registry_register(registry, "max", fn_max, 1, 1);
|
|
4167
|
+
xpath_function_registry_register(registry, "zero-or-one", fn_zero_or_one, 1, 1);
|
|
4168
|
+
xpath_function_registry_register(registry, "one-or-more", fn_one_or_more, 1, 1);
|
|
4169
|
+
xpath_function_registry_register(registry, "exactly-one", fn_exactly_one, 1, 1);
|
|
4170
|
+
|
|
4171
|
+
xpath_function_registry_register(registry, "function-lookup", fn_function_lookup, 2, 2);
|
|
4172
|
+
xpath_function_registry_register(registry, "function-name", fn_function_name, 1, 1);
|
|
4173
|
+
xpath_function_registry_register(registry, "function-arity", fn_function_arity, 1, 1);
|
|
4174
|
+
xpath_function_registry_register(registry, "for-each", fn_for_each, 2, 2);
|
|
4175
|
+
xpath_function_registry_register(registry, "filter", fn_filter, 2, 2);
|
|
4176
|
+
xpath_function_registry_register(registry, "fold-left", fn_fold_left, 3, 3);
|
|
4177
|
+
xpath_function_registry_register(registry, "fold-right", fn_fold_right, 3, 3);
|
|
4178
|
+
xpath_function_registry_register(registry, "for-each-pair", fn_for_each_pair, 3, 3);
|
|
4179
|
+
xpath_function_registry_register(registry, "sort", fn_sort_seq, 1, 3);
|
|
4180
|
+
xpath_function_registry_register(registry, "apply", fn_apply, 2, 2);
|
|
4181
|
+
|
|
4182
|
+
xpath_function_registry_register(registry, "map:for-each", fn_map_for_each, 2, 2);
|
|
4183
|
+
|
|
4184
|
+
xpath_function_registry_register(registry, "array:for-each", fn_array_for_each, 2, 2);
|
|
4185
|
+
xpath_function_registry_register(registry, "array:filter", fn_array_filter, 2, 2);
|
|
4186
|
+
xpath_function_registry_register(registry, "array:fold-left", fn_array_fold_left, 3, 3);
|
|
4187
|
+
xpath_function_registry_register(registry, "array:fold-right", fn_array_fold_right, 3, 3);
|
|
4188
|
+
|
|
4189
|
+
xpath_function_registry_register(registry, "math:sqrt", fn_sqrt, 1, 1);
|
|
4190
|
+
xpath_function_registry_register(registry, "innermost", fn_innermost, 1, 1);
|
|
4191
|
+
xpath_function_registry_register(registry, "outermost", fn_outermost, 1, 1);
|
|
4192
|
+
xpath_function_registry_register(registry, "has-children", fn_has_children, 0, 1);
|
|
4193
|
+
xpath_function_registry_register(registry, "nilled", fn_nilled, 0, 1);
|
|
4194
|
+
xpath_function_registry_register(registry, "path", fn_path, 0, 1);
|
|
4195
|
+
xpath_function_registry_register(registry, "base-uri", fn_base_uri, 0, 1);
|
|
4196
|
+
xpath_function_registry_register(registry, "document-uri", fn_uri_constant, 0, 1);
|
|
4197
|
+
xpath_function_registry_register(registry, "static-base-uri", fn_uri_constant, 0, 0);
|
|
4198
|
+
xpath_function_registry_register(registry, "doc-available", fn_doc_available, 1, 1);
|
|
4199
|
+
xpath_function_registry_register(registry, "json-doc", fn_json_doc, 1, 1);
|
|
4200
|
+
xpath_function_registry_register(registry, "compare", fn_compare, 2, 3);
|
|
4201
|
+
xpath_function_registry_register(registry, "codepoint-equal", fn_codepoint_equal, 2, 2);
|
|
4202
|
+
#ifdef LEPTRIS_HAS_UTF8PROC
|
|
4203
|
+
xpath_function_registry_register(registry, "normalize-unicode", fn_normalize_unicode, 1, 2);
|
|
4204
|
+
#endif
|
|
4205
|
+
xpath_function_registry_register(registry, "resolve-QName", fn_resolve_qname, 2, 2);
|
|
4206
|
+
xpath_function_registry_register(registry, "environment-variable", fn_environment_variable, 1, 1);
|
|
4207
|
+
xpath_function_registry_register(registry, "available-environment-variables", fn_available_env_vars, 0, 0);
|
|
4208
|
+
xpath_function_registry_register(registry, "unparsed-text", fn_unparsed_text, 1, 2);
|
|
4209
|
+
xpath_function_registry_register(registry, "unparsed-text-lines", fn_unparsed_text_lines, 1, 2);
|
|
4210
|
+
xpath_function_registry_register(registry, "unparsed-text-available", fn_unparsed_text_available, 1, 2);
|
|
4211
|
+
xpath_function_registry_register(registry, "uri-collection", fn_uri_collection, 0, 1);
|
|
4212
|
+
xpath_function_registry_register(registry, "random-number-generator", fn_random_number_generator, 0, 1);
|
|
4213
|
+
xpath_function_registry_register(registry, "format-number", fn_format_number_plain, 2, 3);
|
|
4214
|
+
xpath_function_registry_register(registry, "snapshot", fn_snapshot, 1, 1);
|
|
4215
|
+
#ifdef LEPTRIS_HAVE_POSIX_RE
|
|
4216
|
+
xpath_function_registry_register(registry, "analyze-string", fn_analyze_string, 2, 3);
|
|
4217
|
+
#endif
|
|
4218
|
+
xpath_function_registry_register(registry, "math:pow", fn_pow, 2, 2);
|
|
4219
|
+
xpath_function_registry_register(registry, "math:exp", fn_exp, 1, 1);
|
|
4220
|
+
xpath_function_registry_register(registry, "math:exp10", fn_exp10, 1, 1);
|
|
4221
|
+
xpath_function_registry_register(registry, "math:log", fn_log, 1, 1);
|
|
4222
|
+
xpath_function_registry_register(registry, "math:log10", fn_log10, 1, 1);
|
|
4223
|
+
xpath_function_registry_register(registry, "math:sin", fn_sin, 1, 1);
|
|
4224
|
+
xpath_function_registry_register(registry, "math:cos", fn_cos, 1, 1);
|
|
4225
|
+
xpath_function_registry_register(registry, "math:tan", fn_tan, 1, 1);
|
|
4226
|
+
xpath_function_registry_register(registry, "math:asin", fn_asin, 1, 1);
|
|
4227
|
+
xpath_function_registry_register(registry, "math:acos", fn_acos, 1, 1);
|
|
4228
|
+
xpath_function_registry_register(registry, "math:atan", fn_atan, 1, 1);
|
|
4229
|
+
xpath_function_registry_register(registry, "math:atan2", fn_atan2, 2, 2);
|
|
4230
|
+
xpath_function_registry_register(registry, "math:pi", fn_pi, 0, 0);
|
|
4231
|
+
xpath_function_registry_register(registry, "abs", fn_abs, 1, 1);
|
|
4232
|
+
xpath_function_registry_register(registry, "round-half-to-even", fn_round_half_even, 1, 2);
|
|
4233
|
+
|
|
4234
|
+
xpath_function_registry_register(registry, "format-integer", fn_format_integer, 2, 2);
|
|
4235
|
+
xpath_function_registry_register(registry, "contains-token", fn_contains_token, 2, 2);
|
|
4236
|
+
xpath_function_registry_register(registry, "string-to-codepoints", fn_string_to_codepoints, 1, 1);
|
|
4237
|
+
xpath_function_registry_register(registry, "codepoints-to-string", fn_codepoints_to_string, 1, 1);
|
|
4238
|
+
xpath_function_registry_register(registry, "encode-for-uri", fn_encode_for_uri, 1, 1);
|
|
4239
|
+
xpath_function_registry_register(registry, "iri-to-uri", fn_iri_to_uri, 1, 1);
|
|
4240
|
+
xpath_function_registry_register(registry, "escape-html-uri", fn_escape_html_uri, 1, 1);
|
|
4241
|
+
xpath_function_registry_register(registry, "QName", fn_qname, 2, 2);
|
|
4242
|
+
xpath_function_registry_register(registry, "local-name-from-QName", fn_local_from_qname, 1, 1);
|
|
4243
|
+
xpath_function_registry_register(registry, "prefix-from-QName", fn_prefix_from_qname, 1, 1);
|
|
4244
|
+
xpath_function_registry_register(registry, "namespace-uri-from-QName", fn_ns_from_qname, 1, 1);
|
|
4245
|
+
xpath_function_registry_register(registry, "node-name", fn_node_name, 1, 1);
|
|
4246
|
+
/* Dates & durations (05, first slice) — canonical xs: prefix. */
|
|
4247
|
+
xpath_function_registry_register(registry, "xs:date", fn_passthrough_ctor, 1, 1);
|
|
4248
|
+
/* Atomic constructors (06) — canonical xs: prefix. */
|
|
4249
|
+
xpath_function_registry_register(registry, "xs:string", fn_passthrough_ctor, 1, 1);
|
|
4250
|
+
xpath_function_registry_register(registry, "xs:anyURI", fn_passthrough_ctor, 1, 1);
|
|
4251
|
+
xpath_function_registry_register(registry, "xs:integer", fn_xs_integer, 1, 1);
|
|
4252
|
+
xpath_function_registry_register(registry, "xs:double", fn_xs_double, 1, 1);
|
|
4253
|
+
xpath_function_registry_register(registry, "xs:decimal", fn_xs_decimal, 1, 1);
|
|
4254
|
+
xpath_function_registry_register(registry, "xs:int", fn_xs_int, 1, 1);
|
|
4255
|
+
xpath_function_registry_register(registry, "xs:long", fn_xs_long, 1, 1);
|
|
4256
|
+
xpath_function_registry_register(registry, "xs:short", fn_xs_short, 1, 1);
|
|
4257
|
+
xpath_function_registry_register(registry, "xs:unsignedShort", fn_xs_ushort, 1, 1);
|
|
4258
|
+
xpath_function_registry_register(registry, "xs:unsignedLong", fn_xs_ulong, 1, 1);
|
|
4259
|
+
xpath_function_registry_register(registry, "xs:negativeInteger", fn_xs_negint, 1, 1);
|
|
4260
|
+
xpath_function_registry_register(registry, "xs:positiveInteger", fn_xs_posint, 1, 1);
|
|
4261
|
+
xpath_function_registry_register(registry, "xs:nonPositiveInteger", fn_xs_nonpos, 1, 1);
|
|
4262
|
+
xpath_function_registry_register(registry, "xs:nonNegativeInteger", fn_xs_nonneg, 1, 1);
|
|
4263
|
+
xpath_function_registry_register(registry, "xs:boolean", fn_xs_boolean, 1, 1);
|
|
4264
|
+
xpath_function_registry_register(registry, "xs:dateTime", fn_passthrough_ctor, 1, 1);
|
|
4265
|
+
xpath_function_registry_register(registry, "xs:time", fn_passthrough_ctor, 1, 1);
|
|
4266
|
+
xpath_function_registry_register(registry, "xs:duration", fn_passthrough_ctor, 1, 1);
|
|
4267
|
+
xpath_function_registry_register(registry, "xs:dayTimeDuration", fn_passthrough_ctor, 1, 1);
|
|
4268
|
+
xpath_function_registry_register(registry, "xs:yearMonthDuration", fn_passthrough_ctor, 1, 1);
|
|
4269
|
+
xpath_function_registry_register(registry, "implicit-timezone", fn_implicit_tz, 0, 0);
|
|
4270
|
+
xpath_function_registry_register(registry, "current-dateTime", fn_current_dt, 0, 0);
|
|
4271
|
+
xpath_function_registry_register(registry, "current-date", fn_current_date, 0, 0);
|
|
4272
|
+
xpath_function_registry_register(registry, "current-time", fn_current_time, 0, 0);
|
|
4273
|
+
xpath_function_registry_register(registry, "adjust-dateTime-to-timezone", fn_adjust_dttz, 1, 2);
|
|
4274
|
+
xpath_function_registry_register(registry, "adjust-date-to-timezone", fn_adjust_dtetz, 1, 2);
|
|
4275
|
+
xpath_function_registry_register(registry, "adjust-time-to-timezone", fn_adjust_ttz, 1, 2);
|
|
4276
|
+
xpath_function_registry_register(registry, "format-dateTime", fn_format_dttz, 2, 5);
|
|
4277
|
+
xpath_function_registry_register(registry, "format-date", fn_format_dtetz, 2, 5);
|
|
4278
|
+
xpath_function_registry_register(registry, "format-time", fn_format_ttz, 2, 5);
|
|
4279
|
+
xpath_function_registry_register(registry, "year-from-dateTime", fn_year_from_dt, 1, 1);
|
|
4280
|
+
xpath_function_registry_register(registry, "year-from-date", fn_year_from_dt, 1, 1);
|
|
4281
|
+
xpath_function_registry_register(registry, "month-from-date", fn_month_from_dt, 1, 1);
|
|
4282
|
+
xpath_function_registry_register(registry, "day-from-date", fn_day_from_dt, 1, 1);
|
|
4283
|
+
xpath_function_registry_register(registry, "hours-from-dateTime", fn_hours_from_t, 1, 1);
|
|
4284
|
+
xpath_function_registry_register(registry, "minutes-from-dateTime", fn_minutes_from_t, 1, 1);
|
|
4285
|
+
xpath_function_registry_register(registry, "seconds-from-dateTime", fn_seconds_from_t, 1, 1);
|
|
4286
|
+
xpath_function_registry_register(registry, "minutes-from-duration", fn_minutes_from_dur, 1, 1);
|
|
4287
|
+
xpath_function_registry_register(registry, "seconds-from-duration", fn_seconds_from_dur, 1, 1);
|
|
4288
|
+
xpath_function_registry_register(registry, "month-from-dateTime", fn_month_from_dt, 1, 1);
|
|
4289
|
+
xpath_function_registry_register(registry, "day-from-dateTime", fn_day_from_dt, 1, 1);
|
|
4290
|
+
xpath_function_registry_register(registry, "hours-from-time", fn_hours_from_t, 1, 1);
|
|
4291
|
+
xpath_function_registry_register(registry, "minutes-from-time", fn_minutes_from_t, 1, 1);
|
|
4292
|
+
xpath_function_registry_register(registry, "seconds-from-time", fn_seconds_from_t, 1, 1);
|
|
4293
|
+
xpath_function_registry_register(registry, "days-from-duration", fn_days_from_dur, 1, 1);
|
|
4294
|
+
xpath_function_registry_register(registry, "hours-from-duration", fn_hours_from_dur, 1, 1);
|
|
4295
|
+
xpath_function_registry_register(registry, "matches", fn_matches, 2, 3);
|
|
4296
|
+
xpath_function_registry_register(registry, "replace", fn_replace, 3, 4);
|
|
4297
|
+
xpath_function_registry_register(registry, "tokenize", fn_tokenize, 2, 3);
|
|
4298
|
+
/* Maps (08, first slice) — canonical map: prefix. */
|
|
4299
|
+
xpath_function_registry_register(registry, "map:get", fn_map_get, 2, 2);
|
|
4300
|
+
xpath_function_registry_register(registry, "map:size", fn_map_size, 1, 1);
|
|
4301
|
+
xpath_function_registry_register(registry, "map:keys", fn_map_keys, 1, 1);
|
|
4302
|
+
xpath_function_registry_register(registry, "map:contains", fn_map_contains, 2, 2);
|
|
4303
|
+
xpath_function_registry_register(registry, "map:put", fn_map_put, 3, 3);
|
|
4304
|
+
xpath_function_registry_register(registry, "map:remove", fn_map_remove, 2, 2);
|
|
4305
|
+
xpath_function_registry_register(registry, "map:merge", fn_map_merge, 1, 1);
|
|
4306
|
+
/* Arrays (08C) — canonical array: prefix, over the map repr. */
|
|
4307
|
+
xpath_function_registry_register(registry, "array:size", fn_map_size, 1, 1);
|
|
4308
|
+
xpath_function_registry_register(registry, "array:get", fn_array_get, 2, 2);
|
|
4309
|
+
xpath_function_registry_register(registry, "array:append", fn_array_append, 2, 2);
|
|
4310
|
+
xpath_function_registry_register(registry, "array:put", fn_array_put, 3, 3);
|
|
4311
|
+
/* JSON (08D). */
|
|
4312
|
+
xpath_function_registry_register(registry, "parse-json", fn_parse_json, 1, 1);
|
|
4313
|
+
xpath_function_registry_register(registry, "json-to-xml", fn_json_to_xml, 1, 1);
|
|
4314
|
+
xpath_function_registry_register(registry, "xml-to-json", fn_xml_to_json, 1, 1);
|
|
4315
|
+
xpath_function_registry_register(registry, "serialize", fn_serialize, 1, 2);
|
|
4316
|
+
}
|