|
Subject: Re: [xsl] Python and XSLT pt2 From: "dvint dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 27 Aug 2025 19:05:59 -0000 |
Note it is running the else with the transform_to_file()Sent from my Verizon,
Samsung Galaxy smartphone
-------- Original message --------From: "dvint@xxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: 8/27/25 11:06 AM (GMT-08:00)
To: xsl <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: [xsl] Python and XSLT pt2
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 Pythondef run_saxon_py(input_file, xslt_file,
output_file=None, TRYREQUEST=None, DEBUG=None):B B B B time_to_wait =
10B B B B time_counter = 0B B B B while not
os.path.exists(input_file):B B B B B B B B time.sleep(2)B B B B B B B B
time_counter += 2B 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 B if
time_counter > time_to_wait:breakB B B B try:B B B B B B B B with
PySaxonProcessor(license=False) as proc:B 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 B executable =
xsltproc.compile_stylesheet(stylesheet_file=xslt_file)B 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 B
executable.set_parameter('DEBUG',
proc.make_string_value('yes'))B 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 B executable.set_parameter('P1_CONTENT',
proc.make_string_value('yes'))B 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 B messages =B
executable.transform_to_value(source_file=input_file)B 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 B
else:B 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 fileB 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 B
source_file=input_file,B 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 B
output_file=output_fileB 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 B # print(f"Transformation complete. Output
saved to: {result_file}")B B B B except Exception as e:B 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: <xsl:param name="P1_CONTENT" select="'no'"/> <!--
P1 collections uses Try Request -->I added a message in the template where
this matters <xsl:template match="partial" mode="partials"> <xsl:param
name="topicid" /> <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 B ....And I
get this result in the terminal windowInfo: Step 4 Create the nav.adoc and
antora.yaml.TRY REQUEST: noTRY REQUEST: noTRY REQUEST: noTRY REQUEST: noTRY
REQUEST: noTRY REQUEST: noTRY REQUEST: noTRY REQUEST: noTRY REQUEST: noTRY
REQUEST: noTRY REQUEST: noTRY REQUEST: noTRY REQUEST: noTRY REQUEST: noTRY
REQUEST: noTRY REQUEST: noThoughts?..dan
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Python and XSLT pt2, dvint@xxxxxxxxx | Thread | Re: [xsl] Python and XSLT pt2, Martin Honnen martin |
| [xsl] Python and XSLT pt2, dvint@xxxxxxxxx | Date | Re: [xsl] Python and XSLT pt2, Martin Honnen martin |
| Month |