Subject: [xsl] Stylesheet works in oXygen fails in Python with Saxonc From: "dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 21 Jan 2025 21:58:14 -0000 |
I have a stylesheet that works fine in oXygen and Python using lxml/etree. I'm experimenting with switching the Pythion config over to Saxon. Currently I'm just testing a simple Python config to run the stylesheet as follows: from saxonche import * with PySaxonProcessor(license=False) as proc: print(proc.version) xsltproc = proc.new_xslt30_processor() executable = xsltproc.compile_stylesheet(stylesheet_file="02a-build_content-short.xslt") executable.set_result_as_raw_value(True) executable.set_initial_match_selection(file_name="nav-short.xml") result = executable.apply_templates_returning_string() print(result) Attached are the xaml and XSLT files and I'm getting these errors: (base) danvint@mac-PHFW3L52 samples % python3 /Users/danvint/pubsrc/adoc2PDF/_saxon-test.py SaxonC-HE 12.5 from Saxonica Error at char 9 in expression in xsl:variable/@select on line 13 column 62 of 02a-build_content-short.xslt: XPDY0002 Finding root of tree: the context item is absent. Found while atomizing the first argument of fn:concat() in {((root/nav)/div[xs:string(@class) eq "toc"])/@home-folder[1]} on line 13 In variable FILEPATH on line 13 column 62 of 02a-build_content-short.xslt: invoked by global variable FILEPATH at file:///Users/danvint/pubsrc/adoc2PDF/02a-build_content-short.xslt#13 During lazy evaluation of fn:concat(...) on line 43 of file:///Users/danvint/pubsrc/adoc2PDF/02a-build_content-short.xslt In template rule with match="a" on line 36 of 02a-build_content-short.xslt invoked by built-in template rule (text-only) In template rule with match="span[fn:contains(...)]" on line 26 of 02a-build_content-short.xslt invoked by built-in template rule (text-only) In template rule with match="span[fn:contains(...)]" on line 26 of 02a-build_content-short.xslt invoked by built-in template rule (text-only) In template rule with match="h3" on line 24 of 02a-build_content-short.xslt invoked by built-in template rule (text-only) In template rule with match="h3" on line 24 of 02a-build_content-short.xslt invoked by built-in template rule (text-only) In template rule with match="h3" on line 24 of 02a-build_content-short.xslt invoked by built-in template rule (text-only) In template rule with match="h3" on line 24 of 02a-build_content-short.xslt invoked by built-in template rule (text-only) In template rule with match="/" on line 18 of 02a-build_content-short.xslt invoked by xsl:apply-templates at file:///Users/danvint/pubsrc/adoc2PDF/02a-build_content-short.xslt#20 In template rule with match="/" on line 18 of 02a-build_content-short.xslt Traceback (most recent call last): File "/Users/danvint/pubsrc/adoc2PDF/_saxon-test.py", line 10, in <module> result = executable.apply_templates_returning_string() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "python_saxon/saxonc.pyx", line 2405, in saxonche.PyXsltExecutable.apply_templates_returning_string saxonche.PySaxonApiError: XPDY0002: Finding root of tree: the context item is absent. Found while atomizing the first argument of fn:concat() in {((root/nav)/div[xs:string(@class) eq "toc"])/@home-folder[1]} on line 13. Line number: 13 ..dan <nav> <div class="coverpage"> <div class="doctitle"> FORMAT: sample 2.1 _Early Access CONTENT </div> <div class="publicationdate"> January 08, 2025 </div> <div class="productname"> FORMAT: sample 2.1 _Early Access CONTENT </div> <span class="productversion"> latest </span> <img class="logo" src="/Users/danvint/pubsrc/adoc2PDF/PIC_square_logo_PIC_red_RGB.png" /> </div> <div class="toc" home-folder="/Users/danvint/_stash/format-sample-work/target/build/site/FormatSample-samples2/_pdf_build/simple_element_samples"> <h3> Table of Contents </h3> <div class="toc_content"> <div class="wholetoc"> <ul class="nav-list"> <li class="nav-item" data-depth="1"> <span class="nav-text nav-item-toggle"> Simple Element Samples </span> <ul class="nav-list"> <li class="nav-item is-current-page" data-depth="2"> <a class="nav-link" entry-type="file" filename="fs_concept_examples.html" href="fs_concept_examples.html" id="idp105548782269128"> FORMAT: Concept topic examples </a> </li> </ul> </li> </ul> </div> </div> </div> </nav> [demime 1.01d removed an attachment of type text/xml which had a name of 02a-build_content-short.xslt]
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[no subject], Unknown | Thread | Re: [xsl] Stylesheet works in oXyge, Martin Honnen martin |
Re: [xsl] I love programs that outp, Michael Kay michaelk | Date | Re: [xsl] Stylesheet works in oXyge, Martin Honnen martin |
Month |