Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7690349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:22:31+00:00 2026-05-31T20:22:31+00:00

Is it possible to make xsl:analyze-string return one string instead of a sequence of

  • 0

Is it possible to make xsl:analyze-string return one string instead of a sequence of strings?

Background: I’d like to use xsl:analyze-string in a xsl:function that should encapsulate the pattern matching. Ideally, the function should return an xs:string to be used as sort criteria in an xsl:sort element.

At the moment, i have to apply string-join() on every result of the function call since xsl:analyze-string returns a sequence of strings, and xsl:sort doesn’t accept such a sequence as sort criteria. See line 24 of the stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:my="www.my-personal-namespa.ce"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xsl:output indent="yes" method="xml"  />

<xsl:function name="my:sortierung" >
    <xsl:param name="inputstring" as="xs:string"/>
    <xsl:analyze-string select="$inputstring" regex="[0-9]+">
        <xsl:matching-substring>
            <xsl:value-of select="format-number(number(.), '00000')" />
        </xsl:matching-substring>
        <xsl:non-matching-substring>
            <xsl:value-of select="." />
        </xsl:non-matching-substring>
    </xsl:analyze-string>
</xsl:function>

<xsl:template match="/input">
    <result>
    <xsl:apply-templates select="value" >
        <xsl:sort select="string-join((my:sortierung(.)), ' ')" />
        </xsl:apply-templates>
    </result>
</xsl:template>

<xsl:template match="value">
    <xsl:copy-of select="." />
</xsl:template>
</xsl:stylesheet>

with this input:

<?xml version="1.0" encoding="UTF-8"?>
<input>
    <value>A 1 b 120</value>
    <value>A 1 b 1</value>
    <value>A 1 b 2</value>
    <value>A 1 b 1a</value> 
</input>

In my example, is there a way to modify the xsl:function to return a xs:string instead of a sequence?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:22:32+00:00Added an answer on May 31, 2026 at 8:22 pm

    There are several ways I think, you could put the result of the analyze-string into a variable inside of the function and then use xs:sequence select="string-join($var, ' ')" in the function.
    However the following with xsl:value-of should also do:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:my="www.my-personal-namespa.ce"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            exclude-result-prefixes="my xs">
    
    <xsl:output indent="yes" method="xml"  />
    
    <xsl:function name="my:sortierung" as="xs:string">
        <xsl:param name="inputstring" as="xs:string"/>
        <xsl:value-of separator=" ">
        <xsl:analyze-string select="$inputstring" regex="[0-9]+">
            <xsl:matching-substring>
                <xsl:value-of select="format-number(number(.), '00000')" />
            </xsl:matching-substring>
            <xsl:non-matching-substring>
                <xsl:value-of select="." />
            </xsl:non-matching-substring>
        </xsl:analyze-string>
        </xsl:value-of>
    </xsl:function>
    
    <xsl:template match="/input">
        <result>
        <xsl:apply-templates select="value" >
            <xsl:sort select="my:sortierung(.)" />
            </xsl:apply-templates>
        </result>
    </xsl:template>
    
    <xsl:template match="value">
        <xsl:copy-of select="." />
    </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is it possible to make something like this? // file.php $string = require('otherfile.php'); echo
Possible Duplicates: Make a wizard like application in Android Pattern one activity, multiple views.
Is it possible make some handler that will do something when user shutdown computer
Is it possible make an activity, that will lock the android device? That device
Is it possible to make a method return a dynamic List type. Such as
Is it possible make a CCSprite to black and white one using setBlendFunc ?
Within an XSL stylesheet, I'm trying to use the document() function with a relative
is possible make insert in the table with only one column and this column
it's possible make a dropdown menu where menu's fields are datas that comes from
Is it possible to make an Nhibernate query generate Sql that has columnName<>'value' rather

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.