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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:54:08+00:00 2026-06-06T23:54:08+00:00

I’ve been struggling with what would be the best solution to get rid of

  • 0

I’ve been struggling with what would be the best solution to get rid of some specific tags. Currently I use some repetitive find/replace with some regex but there’s gotta be a better way for sure. Just not clear how to do it in xslt directly.

Take following example :

<local xml:lang="en">[Some Indicator]<div class="tab"/>some more content here</local>

I’ve got quite some of these, and all follow the same structure, where the [Some Indicator] is a kind of list identifier and can be any of the following :

  • one or more digits, sometimes followed by a dot
  • one character, sometimes followed by a hyphen and another character
  • one character in a given codepoint range (in this case 57600 to 58607)
  • and some others that are variations on above

I want to get rid of all of these without having to manually find / replace a few hundred times. I’ve been trying xsl:analyze-string but then it replaces everything without bothering position.

Some examples :

<some_nodes_above>
<local xml:lang="en">1<div class="tab"/>some more content here</local>
<local xml:lang="en">2.<div class="tab"/>some more content here</local>
<local xml:lang="fr">2-A<div class="tab"/>some more content here</local>
<local xml:lang="de">&#57600;<div class="tab"/>some more content here</local>
</some_nodes_above>

should become :

<some_nodes_above>
<local xml:lang="en">some more content here</local>
<local xml:lang="en">some more content here</local>
<local xml:lang="fr">some more content here</local>
<local xml:lang="de">some more content here</local>
</some_nodes_above>

So I’m looking for a xslt(2) script that says something like ‘Whenever you see a local node followed by a given indicator and a tab div, strip the indicator and the tab div’. Not looking for a full solution for the example, just something to put me in the right direction. If I know how it would work for one pattern I can probably figure out the remainder myself

Thanks in advance.

  • 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-06T23:54:09+00:00Added an answer on June 6, 2026 at 11:54 pm

    This transformation:

    <xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match=
      "local/node()[1]
                   [self::text()
              and
                following-sibling::node()[1]
                   [self::div and @class eq 'tab']
                  and
                   (
                    matches(., '^(\d\.?)|(.\-.)$')
                   or
                     string-length(.) eq 1
                    and
                     string-to-codepoints(.) ge 57600
                    and
                     string-to-codepoints(.) le 58607
                    )
                   ]"/>
    
     <xsl:template match=
      "div[@class eq 'tab'
         and
           preceding-sibling::node()[1]
                   [self::text()
                  and
                   (
                    matches(., '^(\d\.?)|(.\-.)$')
                   or
                     string-length(.) eq 1
                    and
                     string-to-codepoints(.) ge 57600
                    and
                     string-to-codepoints(.) le 58607
                    )
                   ]
          ]"/>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <some_nodes_above>
        <local xml:lang="en"
         >1<div class="tab"/>some more content here</local>
        <local xml:lang="en"
         >2.<div class="tab"/>some more content here</local>
        <local xml:lang="fr"
         >2-A<div class="tab"/>some more content here</local>
        <local xml:lang="de"
         >&#57600;<div class="tab"/>some more content here</local>
    </some_nodes_above>
    

    produces the wanted, correct result:

    <some_nodes_above>
       <local xml:lang="en">some more content here</local>
       <local xml:lang="en">some more content here</local>
       <local xml:lang="fr">some more content here</local>
       <local xml:lang="de">some more content here</local>
    </some_nodes_above>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words

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.