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 8357833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:36:43+00:00 2026-06-09T10:36:43+00:00

I need to transform input paramater string like 1-410000 54-420987 63-32000 into the structure

  • 0

I need to transform input paramater string like “1-410000 54-420987 63-32000” into the structure (like below) inside xslt to use its data later in xslt:

<config:categories>
  <category>
    <value>410000</value>
    <label>1</label>
  </category>
  <category>
    <value>420987</value>
    <label>54</label>
  </category>
  <category>
    <value>32000</value>
    <label>63</label>
  </category>
</config:categories>

P.S.
Are there any other options to parse string like “1-410000 54-420987 63-32000” in order to use its data in xslt to extract the right part (after the ‘-‘) if the left part is found in input document?

  • 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-06-09T10:36:45+00:00Added an answer on June 9, 2026 at 10:36 am

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:config="some:config" exclude-result-prefixes="config">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:param name="pData" select="'1-410000 54-420987 63-32000'"/>
    
     <xsl:template match="/*">
         <config:categories>
           <xsl:call-template name="gen"/>
         </config:categories>
     </xsl:template>
    
     <xsl:template name="gen">
      <xsl:param name="pGen" select="$pData"/>
    
      <xsl:if test="$pGen">
       <xsl:variable name="vChunk" select=
        "substring-before(concat($pGen, ' '), ' ')"/>
          <category>
            <value><xsl:value-of select="substring-after($vChunk,'-')"/></value>
            <label><xsl:value-of select="substring-before($vChunk,'-')"/></label>
          </category>
          <xsl:call-template name="gen">
           <xsl:with-param name="pGen" select="substring-after($pGen, ' ')"/>
          </xsl:call-template>
      </xsl:if>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on any XML document (not used), produces the wanted, correct result:

    <config:categories xmlns:config="some:config">
       <category>
          <value>410000</value>
          <label>1</label>
       </category>
       <category>
          <value>420987</value>
          <label>54</label>
       </category>
       <category>
          <value>32000</value>
          <label>63</label>
       </category>
    </config:categories>
    

    Explanation:

    Proper use of substring-before() and substring-after() plus recursion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to transform my nested sets structure (mysql) into json for this spacetree
I need to use the result of a javax.xml.transform.Transformer as an input to another
I'd like to optimize the XSL transform below. I've included sample input data and
I need to transform a list into dictionary as follows. The odd elements has
For an iPad application I need to transform some CoffeeScript files into JavaScript files
I need a way to transform numeric HTML entities into their plain-text character equivalent.
I need to use comb filter/transform to detect fundamental frequency of a wav file
I have run into a problem with XSLT transformation. I have input XML as
I'd like to output html controls using xslt, but I need to be able
I have a problem trying to transform a given input string to a given

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.