Re: [xsl] Python and XSLT pt2

Subject: Re: [xsl] Python and XSLT pt2
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Aug 2025 19:50:50 -0000
On 27/08/2025 20:07, dvint@xxxxxxxxx wrote:
This is a different question but related to the code in the previous.
I thought I was passing parameter values to the stylesheet correctly,
but I just tried changing a value and I found that it isn't doing what
I expect.

I've confirmed that the Python parts for passing and changing the
parameter are correct, it isn't reaching the stylesheet. Note that
previously I was using these stylesheets and call java at the command
line and that process was working. Here is the Python

def run_saxon_py(input_file, xslt_file, output_file=None,
TRYREQUEST=None, DEBUG=None):

B B B  time_to_wait = 10
B B B  time_counter = 0
B B B  while not os.path.exists(input_file):
B B B B B B B  time.sleep(2)
B B B B B B B  time_counter += 2
B B B B B B B  print(f"WARNING: Waiting for \"{input_file}\" to exist to
apply \"{xslt_file}\".")
B B B B B B B  if time_counter > time_to_wait:break
B B B  try:
B B B B B B B  with PySaxonProcessor(license=False) as proc:

B B B B B B B B B B B  xsltproc = proc.new_xslt30_processor()
B B B B B B B B B B B  executable =
xsltproc.compile_stylesheet(stylesheet_file=xslt_file)


B B B B B B B B B B B if DEBUG == 'yes': B B B B B B B B B B B B B B B executable.set_parameter('DEBUG', proc.make_string_value('yes'))

B B B B B B B B B B B  if TRYREQUEST == 'yes':
B B B B B B B B B B B B B B B  executable.set_parameter('P1_CONTENT',
proc.make_string_value('yes'))

B B B B B B B B B B B  if output_file == None:
B B B B B B B B B B B B B B B  messages =
executable.transform_to_value(source_file=input_file)
B B B B B B B B B B B B B B B  print(messages)
B B B B B B B B B B B  else:
B B B B B B B B B B B B B B B  # Perform the transformation and write the
output
directly to a file
B B B B B B B B B B B B B B B  result_file = xsltproc.transform_to_file(
B B B B B B B B B B B B B B B B B B B  source_file=input_file,
B B B B B B B B B B B B B B B B B B B  stylesheet_file=xslt_file,
B B B B B B B B B B B B B B B B B B B  output_file=output_file
B B B B B B B B B B B B B B B  )
B B B B B B B B B B B B B B B  # print(f"Transformation complete. Output
saved to:
{result_file}")

B B B  except Exception as e:
B B B B B B B  print(f"ERROR: Unable to apply \"{xslt_file}\" to
\"{input_file}\": \n{e}\n")




TRYREQUEST is the value I'm trying to change. I'm setting it to yes, but instead of getting that value, my default definition of no is not changing.

Parameter setting:

B B B B <xsl:param name="P1_CONTENT" select="'no'"/>B B B  <!-- P1
collections uses Try Request -->

I added a message in the template where this matters

B B B B <xsl:template match="partial" mode="partials">
B B B B B B B  <xsl:param name="topicid" />

B B B B B B B  <xsl:message>TRY REQUEST: <xsl:value-of
select="$P1_CONTENT"/></xsl:message>
B B B B B B B B B B B B B B  ....

And I get this result in the terminal window

Info: Step 4 Create the nav.adoc and antora.yaml.

TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no
TRY REQUEST: no

Thoughts?



Seems to be a bug in SaxonC, I see it with 12.8. Is that the version you also use?

Current Thread