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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:19:22+00:00 2026-06-17T12:19:22+00:00

I need to transform the XML element <mo> based on the character in it.

  • 0

I need to transform the XML element <mo> based on the character in it.
For example, if the element contains uppercase characters only, I need to transform as “obar”. But when it contains lower case characters only, I need to transform as “orule”. If the element contains both upper case and lower case characters then I need to transform as “obar”. Also if the element contains any of the ascender characters as given in XSLT code, it should be as “obar”.

I have used <xsl:if> condition. I need to use only one time of <xsl:if> condition

I need to transform by XSLT 1.0 only.

Sample XML Code:

<?xml version="1.0"?><chapter xmlns="http://www.w3.org/1998/Math/MathML">
  <p>
    <math display="block">
      <mrow>
        <mover accent='true'>
          <mrow>
            <mi>R</mi>
            <mi>T</mi>
          </mrow>
          <mo stretchy='true'>&#x00AF;</mo>
        </mover>
        <mover accent='true'>
          <mrow>
            <mi>a</mi>
            <mi>A</mi>
          </mrow>
          <mo stretchy='true'>&#x00AF;</mo>
        </mover>
        <mover accent='true'>
          <mrow>
            <mi>a</mi>
            <mi>a</mi>
          </mrow>
          <mo stretchy='true'>&#x00AF;</mo>
        </mover>
        <mover accent='true'>
          <mrow>
            <mi>a</mi>
            <mi>h</mi>
          </mrow>
          <mo stretchy='true'>&#x00AF;</mo>
        </mover>
      </mrow>
    </math>
  </p>
</chapter>

XSLT 1.0 tried:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1998/Math/MathML" xmlns:m="http://www.w3.org/1998/Math/MathML" >
<xsl:output method="xml" encoding="UTF-8" indent="no"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="m:mover[@accent='true']">
<xsl:choose>
<xsl:when test="(self::*/child::*[2]/self::m:mo[@stretchy='true']/text())='¯'">
<xsl:if test="(self::*/child::*[1]/self::m:mrow/child::*/text())='b' or 'd' or 'f' or 'h' or 'i' or 'j' or 'k' or 'l' or 'r' or 't' or 'A' or 'B' or 'C' or 'D' or 'E' or 'F' or 'G' or 'H' or 'I' or 'J' or 'K' or 'L' or 'M' or 'N' or 'O' or 'P' or 'Q' or 'R' or 'S' or 'T' or 'U' or 'V' or 'W' or 'X' or 'Y' or 'Z'"><xsl:text>*obar*{</xsl:text></xsl:if>
<xsl:if test="(self::*/child::*[1]/self::m:mrow/child::*/text())='a' or 'c' or 'e' or 'g' or 'm' or 'n' or 'o' or 'p' or 'q' or 's' or 'u' or 'v' or 'w' or 'x' or 'y' or 'z'"><xsl:text>*orule*{</xsl:text></xsl:if>
<xsl:apply-templates/>}</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="m:mrow"><xsl:apply-templates/></xsl:template>
<xsl:template match="m:mi"><xsl:apply-templates/></xsl:template>
<xsl:template match="m:mo"></xsl:template>
</xsl:stylesheet>

Output required:

<chapter xmlns="http://www.w3.org/1998/Math/MathML">
  <p>
    <math display="block">*obar*{RT}*obar*{aA}*orule*{aa}*obar*{ah}</math>
  </p>
</chapter>
  • 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-17T12:19:23+00:00Added an answer on June 17, 2026 at 12:19 pm

    How’s this:

    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1998/Math/MathML" xmlns:m="http://www.w3.org/1998/Math/MathML" >
      <xsl:output method="xml" encoding="UTF-8" indent="no"/>
      <xsl:strip-space elements="*"/>
    
      <xsl:template match="@* | node()">
        <xsl:copy>
          <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
      </xsl:template>
      <xsl:template match="m:mover[@accent='true']">
        <xsl:if test="*[2][@stretchy='true'] = '&#x00AF;'">
          <xsl:choose>
            <!-- translate(value, 'listOfCharacters', '') != .  will be true if value contains any of the characters in the list-->
            <xsl:when test="m:mrow/*[translate(., 'bdfhijklrtABCDEFGHIJKLMNOPQRSTUVWXYZ', '') != .]">
              <xsl:text>*obar*</xsl:text>
            </xsl:when>
            <xsl:otherwise>*orule*</xsl:otherwise>
          </xsl:choose>
          <xsl:text>{</xsl:text>
          <xsl:apply-templates/>
          <xsl:text>}</xsl:text>
        </xsl:if>
      </xsl:template>
      <xsl:template match="m:mrow | m:mi">
        <xsl:apply-templates/>
      </xsl:template>
      <xsl:template match="m:mo" />
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to transform an XML file by adding a new element that will
I am developing an application were I need to transform XML documents that look
I need to transform a valid XML document to the OFX v1.0.2 format .
I am having some problems with an XML transform and need some help. The
I need a way to transform numeric HTML entities into their plain-text character equivalent.
I need to merge certain xml nodes based on an attribute value, change that
I need to transform an XML file to another XML file, where the source
I need to transform one XML (say x1.xml) which is the input to my
I'm using Perl's XML::Twig module to transform XML into (X)HTML. I need to output
Situation: I have a simple XML document that contains image information. I need to

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.