[xsl] Add items to a sequence

Subject: [xsl] Add items to a sequence
From: "rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 24 Mar 2023 16:02:21 -0000
Hi All,

 

I am not sure if I can ask this without giving more context, but I have a
function that loops through some regular expressions in a lookup file and
finds matches against a description element. When there is a match, I want
to return an element from my lookup file. I want to return a sequence
because there may be more than one regular expression match. In my function
below, it seems like it is returning a flattened sequence instead of a
sequence of distinct elements. If this isn't enough context, I can try to
mock up a more complete example. Thank you.

 

Rick

 

<xsl:function name="rq:get-key-codes">

        <xsl:param name="description" as="xs:string"/>

        <xsl:param name="report-type" as="xs:string"/>

        <xsl:iterate
select="$key-codes/key-codes/record[report[.=$report-type]]">

            <xsl:param name="keyword-codes" as="empty-sequence()"/>

            <xsl:on-completion>{$keyword-codes}</xsl:on-completion>

            <xsl:choose>

                <xsl:when
test="matches($description,./key-word,'i')=true()">

                    <xsl:next-iteration>

                        <xsl:with-param name="keyword-codes">

                            <xsl:sequence select="$keyword-codes ||
./key-code"/>

                        </xsl:with-param>

                    </xsl:next-iteration>

                </xsl:when>

                <xsl:otherwise>

                    <xsl:next-iteration>

                        <xsl:with-param name="keyword-codes"
select="$keyword-codes"/>

                    </xsl:next-iteration>

                </xsl:otherwise>

            </xsl:choose>

        </xsl:iterate>

    </xsl:function>

Current Thread