Project

Profile

Help

Bug #5695

closed

Unexpected sort order in Firefox

Added by Martynas Jusevicius over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
Start date:
2022-09-26
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2, Trunk
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

The following stylesheet outputs B D A C E Z in Firefox and A B C D E Z in Chrome (tested on https://martin-honnen.github.io/xslt3fiddle/).

Not sure this has to do with collations, but I added one as suggested by Norm.

Note that there is one element without dct:title which might be part of the cause. After removing it, Firefox also returns A B C D E Z.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="3.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dct="http://purl.org/dc/terms/"
  exclude-result-prefixes="#all"
  expand-text="yes">

  <xsl:output method="xml" indent="yes"/>
  <xsl:mode on-no-match="shallow-copy"/>

  <xsl:variable name="results" as="document-node()">
    <xsl:document>
      <rdf:RDF
          xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns:j.0="http://purl.org/dc/terms/"> 
        <rdf:Description>
          <j.0:title>D</j.0:title>
        </rdf:Description>
        <rdf:Description>
          <j.0:title>B</j.0:title>
        </rdf:Description>
        <rdf:Description>
          <!-- no title -->
        </rdf:Description>
        <rdf:Description>
          <j.0:title>C</j.0:title>
        </rdf:Description>
        <rdf:Description>
          <j.0:title>Z</j.0:title>
        </rdf:Description>
        <rdf:Description>
          <j.0:title>A</j.0:title>
        </rdf:Description>
        <rdf:Description>
          <j.0:title>E</j.0:title>
        </rdf:Description>
      </rdf:RDF>
    </xsl:document>
  </xsl:variable>

  <xsl:template match="/" name="xsl:initial-template">
    <xsl:variable name="sorted-results" as="document-node()">
      <xsl:document>
        <xsl:for-each select="$results/rdf:RDF">
            <xsl:copy>
                <xsl:perform-sort select="*">
                    <xsl:sort select="dct:title" order="ascending" collation="http://www.w3.org/2005/xpath-functions/collation/codepoint"/>
                </xsl:perform-sort>
            </xsl:copy>
        </xsl:for-each>
      </xsl:document>
    </xsl:variable>
    
    <xsl:value-of select="$sorted-results/rdf:RDF/*/dct:title"/>
  </xsl:template>
  
</xsl:stylesheet>

Please register to edit this issue

Also available in: Atom PDF Tracking page