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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:14:41+00:00 2026-05-15T00:14:41+00:00

I have a major problem finding a way to add a space between two

  • 0

I have a major problem finding a way to add a space between two child elements.

<aaa>
    I want to add <bbb>a</bbb><ccc>space</ccc> between two words.
</aaa>

I want to add a space between the “a” and “space” words if the ccc element follows the bbb element immediately. Currently I apply template at aaa element level, and then handle bbb and ccc element in separate templates.

I have no idea how to detect this </bbb><ccc> pattern in advance.

Note: I do not know what words will be inside the bbb and ccc elements.

  • 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-15T00:14:42+00:00Added an answer on May 15, 2026 at 12:14 am

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes"/>
    
     <xsl:template match="node()|@*" name="identity">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match=
       "b[. = 'a'
       and
        following-sibling::node()
                        [1]
                        [self::i
                       and
                         . = 'boy'
                        ]
          ]
       ">
       <xsl:call-template name="identity"/>
       <xsl:text> </xsl:text>
     </xsl:template>
    </xsl:stylesheet>
    

    when performed on the provided XML document:

    <aaa>
        I am <b>a</b><i>boy</i>.
    </aaa>
    

    produces the wanted, correct result:

    <aaa>
        I am <b>a</b> <i>boy</i>.
    </aaa>
    

    Do note:

    1. The use of the identity rule to copy all nodes.

    2. The overriding of the identity rule with a specific template to carry out the addition of the space character exactly between the specified <b> and <i> nodes.

    3. The match (XPath expression) pattern used to match exactly the wanted <b> node after which the space is to be inserted.

    4. The code reuse of the template rule, both being applied and called by name.

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

Sidebar

Related Questions

I have two major xml elements: courses and CRNs <courses> <course credits=3 courseNum=COMP1950 name=Intermediate
For the problem I'm working on, finding distances between two sequences to determine their
I used pole display(E POS) in my POS c# application.I have two major problem
Enums in C++ have one major problem: You can't have one name in two
I am having major problem in Data Binding. I have a stackpanel with an
I have a problem, not that major problem but since i implemented sendMultipartTextMessage on
I'm having a major problem getting a parent/child relationship working for a hierarchy of
I seem to have a major problem. I opened up Xcode and my main
I have encountered a major problem for myself in the learning process of WPF
This is not a major problem, just something I want to know whether or

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.