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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:31:13+00:00 2026-06-11T05:31:13+00:00

First, I am not a programmer. I have a huge XML file with terms

  • 0

First, I am not a programmer.

I have a huge XML file with terms described thus:

<term>
<termId>MANUAL000399</termId>
<termUpdate>Add</termUpdate>
<termName>care</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20120618T14:38:20</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20120618T14:40:41</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
</term>

In the file, terms have either

<termType>

Pt or ND

I would like the solution to apply to both.
what I would like to do is be able to go through, look at the word length in
termName
and if there are fewer than 5 characters in there, append another property, a

<termNote> 

in after the

<termModifiedBy> 

property:

<term>
<termId>MANUAL000399</termId>
<termUpdate>Add</termUpdate>
<termName>care</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20120618T14:38:20</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20120618T14:40:41</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termNote label="Short">Short</termNote>
</term>

Can anyone advise what the best approach for this? I found regexes on here but the problem is the application of them, I found someone suggesting /\b[a-zA-Z]{5,}\b/ but I don’t know how to write a script that takes this and then inserts the termNote if it matches.

  • 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-11T05:31:14+00:00Added an answer on June 11, 2026 at 5:31 am

    This transformation can be done by a simple XSLT stylesheet. (XSLT is a language that non-programmers often take to more enthusiastically than programmers. A stylesheet is basically a set of transformation rules: when you see something that matches X, replace it by Y. Of course, once you have mastered XSLT, you can call yourself a programmer).

    First some boilerplate:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:strip-space elements="*"/> <!-- removes whitespace from the input -->
    <xsl:output indent="yes"/>      <!-- adds whitespace to the output -->
    

    Then a default template rule that copies things unchanged if there’s no more specific rule:

    <xsl:template match="*">
      <xsl:copy>
        <xsl:copy-of select="@*"/>
        <xsl:apply-templates/>
      </xsl:copy>
    </xsl:template>
    

    Then a template rule that matches short terms:

    <xsl:template match="term[string-length(termName) &lt; 5]">
      <term>
        <xsl:copy-of select="*"/>
        <termNote label="Short">Short</termNote>
      </term>
    </xsl:template>
    

    and then finish off with:

    </xsl:stylesheet>
    

    You should be able to run this with any XSLT processor; there are plenty available. If nothing else comes to mind, download KernowForSaxon (from SourceForge) which is a very simple GUI interface around my Saxon processor.

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

Sidebar

Related Questions

According to JSHint, a Javascript programmer should not add a space after the first
First, I'm not a python programmer. I'm an old C dog that's learned new
First of all, I'm absolutely not a network programmer. What I try to do,
First, let me say I'm not a professional programmer, but an engineer who had
I have a problem with selecting not first selector using attributeContains jQuery('div[id*=abc]:not(:first)').hide();
file.each_line do |line| #skip the first one/not a user 3.times { next } if
So I have already imported one XML-ish file with 3000 elements and parsed them
I'm not a front-end programmer, but I first realized the issue just when I
First of all, I'm not much of a programmer if at all. This question
Hi everyone this is my first question here and im not a programmer. I

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.