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

  • Home
  • SEARCH
  • 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 3429272
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:03:41+00:00 2026-05-18T07:03:41+00:00

Okay, I have reached a complete mental block on trying to get this to

  • 0

Okay, I have reached a complete mental block on trying to get this to work and was wondering if anyone else might be able to get their head around it. I have the following structure to HTML.

    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <listing>
        <name>Frank Spencer</name>
        <dob>2010-09-01</dob>
        <details>
         <firmname>Scotts</firmname>
         <address>Blah Blah</address>
         <businessname>Scotts</businessname>
         <businessaddress>Blahdeblah</businessaddress>
        </details>
        <details>
         <firmname>Scotts</firmname>
         <address>Blah Blah</address>
         <businessname>Wilson and Son</businessname>
         <businessaddress>Blahdeblah</businessaddress>
        </details>
        <details>
         <firmname>Wilson and Son</firmname>
         <address>Blah Blah</address>
         <businessname>Brudebakers</businessname>
         <businessaddress>Blahdeblah</businessaddress>
       </details>
       <details>
         <firmname>Carnage and Co.</firmname>
         <address>Blah Blah</address>
         <businessname>Brudebakers</businessname>
         <businessaddress>Blahdeblah</businessaddress>
       </details>
     </listing>
      <listing>
       <name>Han Solo</name>
       <dob>2010-09-01</dob>
       <details>
         <firmname>Independent trading</firmname>
         <address>Blah Blah</address>
         <businessname>Fugitive freight</businessname>
         <businessaddress>Blahdeblah</businessaddress>
       </details>
       <details>
         <firmname>Scotts</firmname>
         <address>Blah Blah</address>
         <businessname>Wilson and Son</businessname>
         <businessaddress>Blahdeblah</businessaddress>
       </details>
       <details>
         <firmname>Wilson and Son</firmname>
         <address>Blah Blah</address>
         <businessname>Scotts</businessname>
         <businessaddress>Blahdeblah</businessaddress>
       </details>
       <details>
         <firmname>Carnage and Co.</firmname>
         <address>Blah Blah</address>
         <businessname>Brudebakers</businessname>
         <businessaddress>Blahdeblah</businessaddress>
       </details>
    </listing>
</root>

With the following XSLT.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>

<xsl:param name="searchName">Wilson</xsl:param>
<xsl:param name="searchName2"></xsl:param>

<xsl:variable name="Uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:variable name="Lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>

<xsl:template match="/">
    <xsl:for-each select="root/listing">
       <p>Name: <xsl:value-of select="name"/></p>
       <p>DOB: <xsl:value-of select="dob" /></p>

<xsl:for-each select="details[not(firmname=following::root/listing/details/firmname) and not(businessname=following::root/listing/details/businessname) or not(firmname=following::root/listing/details/businessname) or not(businessname=following::root/listing/details/firmname)]"> 

<xsl:choose>

    <xsl:when test="contains(translate(firmname,$Uppercase,$Lowercase), translate($searchName,$Uppercase,$Lowercase)) and contains(translate(businessname,$Uppercase,$Lowercase), translate($searchName,$Uppercase,$Lowercase)) and not($searchName = '')">
 (This individual has previously worked at:
 <xsl:value-of select="firmname" />
 </xsl:when>

 <xsl:when test="contains(translate(businessname,$Uppercase,$Lowercase), translate($searchName,$Uppercase,$Lowercase)) and not(contains(translate(firmname,$Uppercase,$Lowercase), translate($searchName,$Uppercase,$Lowercase))) and not($searchName = '')">
(This individual has previously worked at:
 <xsl:value-of select="businessname" />)
 </xsl:when>

 <xsl:when test="contains(translate(firmname,$Uppercase,$Lowercase), translate($searchName,$Uppercase,$Lowercase)) and not(contains(translate(businessname,$Uppercase,$Lowercase), translate($searchName,$Uppercase,$Lowercase))) and not($searchName = '')">
 (This individual has previously worked at:
 <xsl:value-of select="firmname" />)<br/>
 </xsl:when>

 </xsl:choose>
 </xsl:for-each>
 </xsl:for-each>
 </xsl:template>
 </xsl:stylesheet>

What I want is to get a list of the firms which contain the search term. But what I get is:

  Name: Frank Spencer

  DOB: 2010-09-01

  (This individual has previously worked at: Wilson and Son)
  (This individual has previously worked at: Wilson and Son)

  Name: Han Solo

  DOB: 2010-09-01

  (This individual has previously worked at: Wilson and Son)
  (This individual has previously worked at: Wilson and Son)

The xslt should look at both firmname and businessname and then if it finds a match with the contains it should print out only one reference. But I can’t seem to get it to work. Has anyone got any solutions/suggestions? The ideal outcome is.

<body>
  <p>Name: Frank Spencer</p>

  <p>DOB: 2010-09-01</p>

  <p>(This individual has previously worked at: Wilson and Son)</p>


  <p>Name: Han Solo</p>

  <p>DOB: 2010-09-01</p>

  <p>(This individual has previously worked at: Wilson and Son)</p>
</body>
  • 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-18T07:03:42+00:00Added an answer on May 18, 2026 at 7:03 am

    Is it what you looking for?

    <xsl:param name="searchName">Brudebakers</xsl:param>
    <xsl:param name="searchName2"></xsl:param>
    
    <xsl:variable name="Uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
    <xsl:variable name="Lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>
    
    <xsl:template match="/">
        <xsl:copy>
            <body>
                <xsl:apply-templates select="root/listing/name"/>
            </body>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="name">
        <xsl:apply-templates select=". |following-sibling::dob" mode="fetch-value"/>
        <xsl:apply-templates
                select="following-sibling::details/businessname[contains(., $searchName)]"
                mode="select-one"/>
    </xsl:template>
    
    <xsl:template match="node()[name() = 'businessname' or name() = 'firmname']" mode="select-one">
        <xsl:if test="not(../preceding-sibling::details/node()[(name() = 'businessname' or name() = 'firmname')][contains(., $searchName)])">
            <xsl:choose>
                <xsl:when test="contains(., $searchName)">
                    <xsl:apply-templates select="." mode="fetch-value"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="./firmname" mode="select-one"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>
    
    
    <xsl:template match="@*|node()" mode="fetch-value">
        <p>
            <xsl:value-of select="."/>
        </p>
    </xsl:template>
    

    Output:

    <body>
    <p>Frank Spencer</p>
    <p>2010-09-01</p>
    <p>Brudebakers</p>
    <p>Han Solo</p>
    <p>2010-09-01</p>
    <p>Brudebakers</p>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay I have been trying to get this to work for some time now.
Okay I have spent the last 2 days trying to sort this one out.
Quick question... I was wondering how I can get this to happen. Okay I
Okay I have this RewriteRule which is supposed to redirect any request for the
Okay I have a folder say... http://oldserver.net/file/index.jar How would I be able to protect
Okay, I have reached a sort of an impasse. In my open source project,
okay have a this list: object[] test; test[0]=null; .... test[8700]=null; test[8701]= object[] .... test[9431]=
Okay I have a project in CMake structured like this: CMakeLists.txt /libfoo/CMakeLists.txt /frontend/qt/CMakeLists.txt libfoo
okay I have a dilemma. I am want to be able to upload a
Okay i have this problem with every page i make. im not sure what

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.