Project

Profile

Help

Is my attempt to use saxon:canonical serialization extension with fn:serialize wrong?

Added by Martin Honnen over 3 years ago

I am trying to use the extension saxon:canonical="yes" with fn:serialize as follows with Saxon EE 10.3 Java:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="#all"
    version="3.0">
    
    <xsl:output method="text"/>
    
    <xsl:template match="/">
        <xsl:value-of select="serialize(., map { QName('http://saxon.sf.net/', 'canonical') : true() })"/>
    </xsl:template>
    
</xsl:stylesheet>

Some I am not sure canonicalization happens that way, at least attributes don't seem to be ordered, as the input sample

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <foo att1="value 1" att2="value 2">
        <bar>bar 1</bar>
    </foo>
    <foo att1="value 2">
        <bar>bar 2</bar>
    </foo>
    <foo att1="value 1" att2="value 2">
        <bar>bar 1</bar>
    </foo>
    <foo att2="value 2" att1="value 1">
        <bar>bar 1</bar>
    </foo>
</root>

is output as

<root>
    <foo att1="value 1" att2="value 2">
        <bar>bar 1</bar>
    </foo>
    <foo att1="value 2">
        <bar>bar 2</bar>
    </foo>
    <foo att1="value 1" att2="value 2">
        <bar>bar 1</bar>
    </foo>
    <foo att2="value 2" att1="value 1">
        <bar>bar 1</bar>
    </foo>
</root>

Am I using the wrong arguments to serialize or is there some quirk with canonical serialization and fn:serialize?


Replies (1)

RE: Is my attempt to use saxon:canonical serialization extension with fn:serialize wrong? - Added by Michael Kay over 3 years ago

It seems that the code for fn:serialize() has an explicit list of serialization parameters that are accepted, and the saxon:canonical parameter has been accidentally omitted from this list.

    (1-1/1)

    Please register to reply