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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:54:29+00:00 2026-05-31T17:54:29+00:00

I think I have this working but I need advice. I’d like to know

  • 0

I think I have this working but I need advice. I’d like to know if this is a good setup for the requirement that I have.
I’ve got a requirement to apply different transformation rules to an element based on what is contained in that element. I’ve tried to search for ‘xsl’ and ‘choose’, ‘contains’, ‘substring’. I can’t seem to find a solution applicable to this situation.

Here are the various scenarios for this element:

  1. If it begins with U, I need everything before the ‘/’

    • Original Value: UJXXXXX/001

    • Transformed : UJXXXXX

  2. If it begins with ECG_001 I need everything after ECG_001

    • Original Value: ECG_0012345678

    • Transformed : 12345678

  3. If it does not meet the above criteria and contains a ‘/’ take everyting after the ‘/’

    • Original Value: F5M/12345678

    • Transformed : 12345678

  4. If it does not meet 1,2, or 3 just give me the value

    • Original Value : 12345678

    • Transformed : 12345678

Here is what I have so far:

<xsl:variable name="CustomerPO">
        <xsl:choose>
            <xsl:when test="contains(substring(rma/header/CustomerPO,1,1), 'U')">
                <xsl:value-of select="substring-before(rma/header/CustomerPO,'/')"/>
            </xsl:when>
            <xsl:when test="contains(rma/header/CustomerPO, 'ECG_001')">
                <xsl:value-of select="substring-after(rma/header/CustomerPO,'ECG_001')"/>
            </xsl:when>
            <xsl:when test="contains(rma/header/CustomerPO, '/')">
                <xsl:value-of select="substring-after(rma/header/CustomerPO, '/')"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="rma/header/CustomerPO"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

Any feedback on potential loopholes or a more efficient way to accomplish this is appreciated.

Thanks.

  • 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-31T17:54:30+00:00Added an answer on May 31, 2026 at 5:54 pm

    Your XSLT looks fine. You might consider using the starts-with function rather than substring, I find it easier to read, but I am not sure it is any faster.

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

Sidebar

Related Questions

I have this program that I am working on for class, I think the
I have this vb.net code ( but I think meaning code is equivalent for
So I have this idea for a RubyGem that I think would be an
I have this in my controller: Konkurrencer.where(title LIKE ?, %#{params[:q]}%).limit(4) I think this query
I have this thing working mostly. What I don't get is, if I have
I swear, I have this exact thing working on another page. I'm such a
Please see the back trace below, I don´t think I have seen this before
I have this.... function MyFunction() { var myVar = I think I am encapsulated;
Dear all,Now i have this question in my java program,I think it should be
I've been looking around on SO and I don't -think- this is something that's

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.