如何解决排序时发现的不可比较类型:无法将xs:date与xs:integer-XSLT进行比较

如何解决排序时发现的不可比较类型:无法将xs:date与xs:integer-XSLT进行比较,xslt,xslt-2.0,Xslt,Xslt 2.0,如何解决排序时发现的不可比较类型:无法将xs:date与xs:integer进行比较此行显示错误O’;康纳诉优步技术有限公司(ND Cal,2013年12月5日,编号C–;13–;3826 EMC)2013年美国地区词汇171813,修订版’;d基于其他原因(2018年第9次巡回法庭)904 F3d 1087:这一行带有两个括号(ND Cal,2013年12月5日,编号C–13–3826 EMC)和(2018年第9次巡回法庭)。我们可以用第一个括号

如何解决排序时发现的不可比较类型:无法将xs:date与xs:integer进行比较此行显示错误
O’;康纳诉优步技术有限公司(ND Cal,2013年12月5日,编号C–;13–;3826 EMC)2013年美国地区词汇171813,修订版’;d基于其他原因(2018年第9次巡回法庭)904 F3d 1087:
这一行带有两个括号(ND Cal,2013年12月5日,编号C–13–3826 EMC)和(2018年第9次巡回法庭)。我们可以用第一个括号吗。最后两个条目不会根据最新日期移动子代,因为正则表达式用于日期格式
\(.*)(“||字符串连接($months),| |”)\([0-9]{1,2}),([0-9]{4}])。

输入XML

  <root>
    <p content-type="emCase"><named-content content-type="emEntry">AFL-CIO v Unemployment Ins. Appeals Bd. (1994) 23 CA4th 51:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">AFL-CIO v Unemployment Ins. Appeals Bd. (1996) 13 C4th 1017:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Ambat v City &#x0026; County of San Francisco (ND Cal 2010) 693 F Supp 2d 1130, rev&#x2019;d on other grounds (9th Cir 2014) 757 F3d 1017:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Ambat v City &#x0026; County of San Francisco (9th Cir 2014) 757 F3d 1017:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Anaheim Union High Sch. Dist. (2016) PERB Dec. No. 2504E, 41 PERC 80:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Anaheim Union High Sch. Dist. (1981) PERB Dec. No. 0177E, 5 PERC 12148:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Artec Group v Klimov (ND Cal, Nov. 22, 2015) 2015 US Dist Lexis 171698:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Artec Group v Klimov (ND Cal, Dec. 22, 2015) 2016 US Dist Lexis 170194:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">O&#x2019;Connor v Uber Technols., Inc. (ND Cal, Dec. 05, 2013, No. C&#x2013;13&#x2013;3826 EMC) 2013 US Dist Lexis 171813, rev&#x2019;d on other grounds 904 F3d 1087:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">O&#x2019;Connor v Uber Technols., Inc. (2018) 904 F3d 1087:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">O&#x2019;Connor v Uber Technols., Inc. (ND Cal 2015) 82 F Supp 3d 1133:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Swarmfly, Inc. v Cloudflare, Inc. (ND Cal, May 31, 2018, No. C 17-06957 WHA) 2018 US Dist Lexis 91333:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Swarmify, Inc. v Cloudflare, Inc. (ND Cal, Sept. 28, 2018, No. C 17-06957 WHA) 2018 US Dist Lexis 168317:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Swarmify, Inc. v Cloudflare, Inc. (ND Cal, Mar. 3, 2018, No. C 17-06597 WHA) 2018 WL 112204:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Zody v Microsoft Corp. (ND Cal, June 7, 2013, No. C&#x2013;12&#x2013;00942&#x2013;YGR) 2013 US Dist Lexis 80623:</named-content></p>
    <p content-type="emCase"><named-content content-type="emEntry">Zody v Microsoft Corp. (ND Cal, July 24, 2013, No. C&#x2013;12&#x2013;00942&#x2013;YGR) 2013 US Dist Lexis 103868:</named-content></p>
</root>

AFL-CIO v失业保险。上诉Bd.(1994)23第51条:

AFL-CIO v失业保险。上诉Bd.(1996)13 C4th 1017:

Ambat v City和x0026;旧金山县(ND CAL 2010)693 F SUPDP 2D 1130,Rev & XX2019;d基于其他理由(2014年第9巡回法庭)757 F3d 1017:

Ambat v City和x0026;旧金山县(第九CIR 2014)757 F3D 1017:

阿纳海姆联合高等学校。区(2016)PERB第2504E号决议,41 PERC 80:

阿纳海姆联合高等学校。区(1981)PERB第0177E号决定,5 PERC 12148:

Artec Group v Klimov(ND Cal,2015年11月22日)2015年美国地区词汇171698:

Artec Group v Klimov(ND Cal,2015年12月22日)2016年美国地区词汇170194:

O’;康纳诉优步技术有限公司(ND Cal,2013年12月5日,编号C–;13–;3826 EMC)2013年美国地区词汇171813,修订版’;d其他理由904 F3d 1087:

O’;康纳诉优步技术有限公司(2018)904 F3d 1087:

O’;康纳诉优步技术有限公司(ND Cal 2015)82 F Supp 3d 1133:

Swarmfly,Inc.诉Cloudflare,Inc.(ND Cal,2018年5月31日,编号C 17-06957 WHA)2018美国地区词汇91333:

Swarmify,Inc.诉Cloudflare,Inc.(ND Cal,2018年9月28日,编号C 17-06957 WHA)2018美国地区Lexis 168317:

Swarmify,Inc.诉Cloudflare,Inc.(ND Cal,2018年3月3日,编号C 17-06597 WHA)2018 WL 112204:

Zody诉微软公司(ND Cal,2013年6月7日,编号C–;12–;00942–;YGR)2013年美国地区Lexis 80623:

Zody诉微软公司(ND Cal,2013年7月24日,编号C–;12–;00942–;YGR)2013年美国地区词汇103868:

XSLT

    <xsl:param name="months" as="xs:string*"
    select="'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'"/>

<xsl:param name="date-pattern" as="xs:string"
    select="'\((.*?)((' || string-join($months, '|') || ')\. ([0-9]{1,2}), ([0-9]{4})).*?\)'"/>

<xsl:output indent="yes"/>
<xsl:template match="@specific-use|named-content[@content-type='emSecs']"/>    

<xsl:function name="mf:extract-date" as="xs:date?">
    <xsl:param name="input" as="xs:string"/>
    <xsl:sequence
        select="let $match := analyze-string($input, $date-pattern)/*:match[1]
        return 
        if ($match) 
        then xs:date(
        $match//*:group[@nr = 5] 
        || '-' || format-integer(index-of($months, $match//*:group[@nr = 3]), '00') 
        || '-' || format-integer($match//*:group[@nr = 4], '00'))
        else ()"/>
</xsl:function>

<xsl:function name="mf:extract-year" as="xs:integer?">
    <xsl:param name="input" as="xs:string"/>
    <xsl:sequence
        select="analyze-string($input, '\((.*?)([0-9]{4})\)')/*:match[1]/*:group[@nr = 2]"/>
</xsl:function>

<xsl:function name="mf:extract-sort" as="xs:string?">
    <xsl:param name="input" as="xs:string"/>
    <xsl:sequence
        select="analyze-string($input, '\((.*?)\)')/*:match[1]/*:group[@nr = 1]"/>
</xsl:function>

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="root">
    <xsl:copy>
        <xsl:for-each-group select="p" group-adjacent="substring-before(named-content[@content-type = 'emEntry'], '(')">
            <xsl:apply-templates select="current-group()">
                <xsl:sort select="let $year := mf:extract-year(.)
                    return if ($year) then -$year else 1"/>
                <xsl:sort select="let $date := mf:extract-date(.)
                    return if (exists($date)) then $date else 1" order="descending"/>
                <xsl:sort select="let $sort := mf:extract-sort(.)
                    return if ($sort) then $sort else 1" order="descending"/>
            </xsl:apply-templates>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

预期产出

<root>
   <p content-type="emCase">
      <named-content content-type="emEntry">AFL-CIO v Unemployment Ins. Appeals Bd. (1996) 13 C4th 1017:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">AFL-CIO v Unemployment Ins. Appeals Bd. (1994) 23 CA4th 51:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Ambat v City &amp; County of San Francisco (9th Cir 2014) 757 F3d 1017:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Ambat v City &amp; County of San Francisco (ND Cal 2010) 693 F Supp 2d 1130, rev’d on other grounds (9th Cir 2014) 757 F3d 1017:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Anaheim Union High Sch. Dist. (2016) PERB Dec. No. 2504E, 41 PERC 80:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Anaheim Union High Sch. Dist. (1981) PERB Dec. No. 0177E, 5 PERC 12148:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Artec Group v Klimov (ND Cal, Dec. 22, 2015) 2016 US Dist Lexis 170194:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Artec Group v Klimov (ND Cal, Nov. 22, 2015) 2015 US Dist Lexis 171698:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">O’Connor v Uber Technols., Inc. (2018) 904 F3d 1087:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">O’Connor v Uber Technols., Inc. (ND Cal 2015) 82 F Supp 3d 1133:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">O’Connor v Uber Technols., Inc. (ND Cal, Dec. 05, 2013, No. C–13–3826 EMC) 2013 US Dist Lexis 171813, rev’d on other grounds (9th Cir 2018) 904 F3d 1087:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Swarmify, Inc. v Cloudflare, Inc. (ND Cal, Sept. 28, 2018, No. C 17-06957 WHA) 2018 US Dist Lexis 168317:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Swarmfly, Inc. v Cloudflare, Inc. (ND Cal, May 31, 2018, No. C 17-06957 WHA) 2018 US Dist Lexis 91333:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Swarmify, Inc. v Cloudflare, Inc. (ND Cal, Mar. 3, 2018, No. C 17-06597 WHA) 2018 WL 112204:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Zody v Microsoft Corp. (ND Cal, July 24, 2013, No. C–12–00942–YGR) 2013 US Dist Lexis 103868:</named-content>
   </p>
   <p content-type="emCase">
      <named-content content-type="emEntry">Zody v Microsoft Corp. (ND Cal, June 7, 2013, No. C–12–00942–YGR) 2013 US Dist Lexis 80623:</named-content>
   </p>
</root>

劳联-产联诉失业调查局。上诉Bd.(1996)13 C4th 1017:

劳联-产联诉失业调查局。上诉Bd.(1994)23第51条:

Ambat v City&;旧金山县(第九CIR 2014)757 F3D 1017:

Ambat v City&;旧金山县(ND CAL 2010)693 F SUPDP 2D 1130,根据其他理由(第九CIR 2014)757 F3D 1017:

阿纳海姆联合高中。区(2016)PERB第2504E号决议,41 PERC 80:

阿纳海姆联合高中。区(1981)PERB第0177E号决定,5 PERC 12148:

Artec Group v Klimov(北加利福尼亚州,2015年12月22日)2016年美国地区词汇170194:

Artec Group v Klimov(北加利福尼亚州,2015年11月22日)2015美国地区词汇171698:

奥康纳诉优步技术有限公司(2018)904 F3d 1087:

奥康纳诉优步技术有限公司(ND Cal 2015)82 F Supp 3d 1133:

O'Connor v Uber Technols.,Inc.(北加州,2013年12月5日,编号C-13–3826 EMC)2013年美国地区Lexis 171813,其他原因修订版(2018年第9巡回法庭)904 F3d 1087:

Swarmify,Inc.诉Cloudflare,Inc.(北加利福尼亚州,2018年9月28日,编号C 17-06957 WHA)2018年美国地区Lexis 168317:

Swarmfly,Inc.诉Cloudflare,Inc.(北加利福尼亚州,2018年5月31日,编号C 17-06957 WHA)2018年美国地区Lexis 91333:

Swarmify,Inc.诉Cloudflare,Inc.(北加利福尼亚州,2018年3月3日,编号C 17-06597 WHA)2018 WL 112204:

Zody诉微软公司(ND Cal,2013年7月24日,编号C-12-00942-YGR)2013年美国地区Lexis 103868:

Zody诉微软公司(ND Cal,2013年6月7日,编号C-12-00942-YGR)2013年美国地区Lexis 80623:


CODE

让$date:=mf:extract date(.)返回如果(存在($date)),那么$date else 1可能是罪魁祸首,您需要使用一些默认的xs:date,不确定您需要哪个基准日期,但您可以使用例如else xs:date('1900-01-01')

至于月份名称匹配,如果我们使用正则表达式模式匹配月份名称,我不确定前面的方法是否有效,但是如果我们使用一个附加函数

<xsl:param name="months" as="xs:string*"
    select="'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June?', 'July?', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'"/>

<xsl:param name="date-pattern" as="xs:string"
    select="'\((.*?)((' || string-join($months, '|') || ')\. ([0-9]{1,2}), ([0-9]{4})).*?\)'"/>

<xsl:function name="mf:index-of-match" as="xs:integer*">
    <xsl:param name="patterns" as="xs:string*"/>
    <xsl:param name="month-match" as="xs:string"/>
    <xsl:sequence
      select="for $pos in (1 to count($patterns))
              return $pos[matches($month-match, $patterns[$pos])]"/>
</xsl:function>

<xsl:function name="mf:extract-date" as="xs:date?">
    <xsl:param name="input" as="xs:string"/>
    <xsl:sequence
        select="let $match := analyze-string($input, $date-pattern)/*:match[1]
        return 
        if ($match) 
        then xs:date(
        $match//*:group[@nr = 5] 
        || '-' || format-integer(mf:index-of-match($months, $match//*:group[@nr = 3]), '00') 
        || '-' || format-integer($match//*:group[@nr = 4], '00'))
        else ()"/>
</xsl:function>


它可能提供更大的灵活性。

让$date:=mf:extract date(.)返回如果(存在($date)),那么$date else 1可能是罪魁祸首,您需要使用一些默认的
xs:date
,不确定您需要哪个基准日期,但您可以使用例如
else xs:date('1900-01-01')

至于月份名称匹配,我是n