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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:16:17+00:00 2026-05-16T14:16:17+00:00

I have an xml that looks something like this <para> text text text <b>text</b>

  • 0

I have an xml that looks something like this

<para>
   text text text
   <b>text</b> text text <i>text</i>
</para>

the objective is to convert this to mediaWiki formatting with ”’ for a bold font and so on.

when I write a transformation for this the template match ignores all the text inside the <para> tag and only the the <b>s and the <i>s are converted. i need help.

update: here is what i have tried so far:

this is what i have tried so far.

<xsl:template match="para">
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="b">
<xsl:text>'''</xsl:text><xsl:value-of select="replace(replace(.,'\s+$',''),'^\s+','')" disable-output-escaping="no"/><xsl:text>'''</xsl:text>
</xsl:template>

<xsl:template match="i">
<xsl:text>''</xsl:text><xsl:value-of select="replace(replace(.,'\s+$',''),'^\s+','')" disable-output-escaping="no"/><xsl:text>''</xsl:text>
</xsl:template>

this is what I used when i tried the text() function.

<xsl:template match="text()">
<xsl:value-of select="." disable-output-escaping="no"/>
</xsl:template>

–update–
in order to not lose the spaces before and after the text block and the bold and italics flags we can also check for spaces before and after the text.

<xsl:template match="text()">
    <xsl:variable name="originalText" select="."/>
    <xsl:if test="starts-with($originalText,' ')">
        <xsl:text> </xsl:text>
    </xsl:if>
    <xsl:value-of select="normalize-space(.)" disable-output-escaping="no"/>
    <xsl:if test="ends-with($originalText,' ')">
        <xsl:text> </xsl:text>
    </xsl:if>
</xsl:template>
  • 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-16T14:16:18+00:00Added an answer on May 16, 2026 at 2:16 pm

    when I write a transformation for this
    the template match ignores all the
    text inside the tag and only
    the the <b>s and the <i>s are
    converted. i need help.

    update: here is what i have tried so
    far:

    this is what i have tried so far.

    <xsl:template match="para">  
      <xsl:apply-templates select="*"/>  
    </xsl:template>
    

    Your problem is exactly in this template. Your codes ignores anything else except element – children. the * abbreviation stands for child::element(). Thus the text-nodes children of para aren’t processed at all.

    Solution:

    Simply remove the above template. Then the built-in XSLT template for element nodes will be selected to process the para element. All it does is <xsl:apply-templates/> and this is an abbreviation for <xsl:apply-templates select="child::node()"/>. This applies templates for every child node (of any type, including text nodes). When the text-node children of para are processed, the built-in XSLT template for text node is selected — all it does is to copy the text as is.

    The transformation now becomes:

    <xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
    
        <xsl:template match="b">
            <xsl:text>'''</xsl:text>
            <xsl:value-of select="replace(replace(.,'\s+$',''),'^\s+','')"/>
            <xsl:text>'''</xsl:text>
        </xsl:template>
    
        <xsl:template match="i">
            <xsl:text>''</xsl:text>
            <xsl:value-of select="replace(replace(.,'\s+$',''),'^\s+','')" />
            <xsl:text>''</xsl:text>
        </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <para>
       text text text
       <b>text</b> text text <i>text</i>
    </para>
    

    the result now includes the text node children of para:

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

Sidebar

Related Questions

I have an xml file that looks something like this <questions> <question> <text>What color
--edited for clarity (hopefully) I have an XML file that looks something like this:
I have an XML file that looks like this: <SiteMenuItems> <SiteMenuItem text=Home navigateurl=/Default.aspx tooltip=Return
I have a bit of Xml that looks something like this: <books> <book id=1>
I have an xml mapping file that looks something like this <colourMappings> <model name=modelX>
i have an xml file that looks something like this <library> <book name=ABC> <chapter
I currently have an XML Structure that looks something like this <Parent> <Info> <Info-Data></Info-Data>
I have an XML feed that looks something like this: I can parse the
I have an XML element that looks something like this: <content locale=en> </content> The
I have an xml document with multiple nodes that looks something like this: <Result>

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.