Project

Profile

Help

Bug #6336

closed

passing an array as a parameter results in an object has no attribute 'derivedaptr'

Added by Menzo Windhouwer 3 months ago. Updated 3 months ago.

Status:
Resolved
Priority:
Low
Category:
Python
Start date:
2024-01-31
Due date:
% Done:

100%

Estimated time:
Found in version:
12.4.2
Fixed in version:
Platforms:

Description

I'm trying to pass an array to a stylesheet:

with PySaxonProcessor(license=False) as proc:
    print(proc.version)
    xsltproc = proc.new_xslt30_processor()
    xsltproc.set_cwd(os.getcwd())
    executable = xsltproc.compile_stylesheet(stylesheet_file="cat.xsl")

    value = proc.make_array([proc.make_integer_value(i) for i in [8,9,10]])
    print(value)
    executable.set_parameter("values", value)

    result = executable.apply_templates_returning_string(source_file="person.xml")
    print(result)

However, this results in:

    SaxonC-HE 12.4.2 from Saxonica
    [8,9,10]
    Traceback (most recent call last):
        File "/Users/menzowi/Temp/saxontest/saxon.py", line 22, in <module>
        executable.set_parameter("values", value)
     File "python_saxon/saxonc.pyx", line 1958, in saxonche.PyXsltExecutable.set_parameter
     AttributeError: 'saxonche.PyXdmArray' object has no attribute 'derivedaptr'

I expected a result an XML document with each of the values in the array multiplied by 3. Using this sytlesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
    <xsl:param name="values" select="(2, 3, 4, 5)"/>
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="*">
        <output>
            <xsl:for-each select="$values">
                <out>
                    <xsl:value-of select=". * 3"/>
                </out>
            </xsl:for-each>
        </output>
    </xsl:template>
</xsl:stylesheet>

Files

Archive.zip (2.62 KB) Archive.zip code that shows the bug Menzo Windhouwer, 2024-01-31 17:02

Related issues

Has duplicate SaxonC - Bug #6335: AttributeError: 'saxonche.PyXdmArray' object has no attribute 'derivedaptr'ClosedO'Neil Delpratt2024-01-30

Actions
Actions #2

Updated by O'Neil Delpratt 3 months ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Thanks for reporting this issue and supplying a repo.

Bug fixed and committed to the repos.

As mention in the stack overflow post the passing of an XdmArray to the stylesheet which expects an XdmValue will give the following error:

XPTY0004: A sequence of more than one item is not allowed as the first operand of '*' ([8, 9, 10])
Actions #3

Updated by O'Neil Delpratt 3 months ago

  • Has duplicate Bug #6335: AttributeError: 'saxonche.PyXdmArray' object has no attribute 'derivedaptr' added

Please register to edit this issue

Also available in: Atom PDF