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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:58:21+00:00 2026-06-13T15:58:21+00:00

I’m making an XSLT template in order to convert XML to LaTeX (then, HTML).

  • 0

I’m making an XSLT template in order to convert XML to LaTeX (then, HTML). I think XSLT wasn’t made for that, but it works. My only problem is text formatting : If in some lines of text, I want to use bold or italic words, the syntax is “< i >< / i >” in HTML for example, but “\textit{}” in LaTeX.

One solution is to declare “i” as a template, but I don’t know if I can apply it “automatically” for each encountred text block (I don’t want to call it explicitly in all my templates)

Sorry, I’m a newbie in this technology, maybe very simple solution exists, but Google didn’t help me this time.

Any suggestion will be appreciated.

EDIT : For example :

Xsl :

<xsl:template match="one">
<xsl:apply-templates select="two"/>
</xsl:template>

XML :

<one>
<two>Some text with <i>italic</i> words</two>
</one>

Desired output :

"Some text with \textit{italic} words"

And I don’t want to do :

<xsl:apply-templates select="i"/>

in all my templates

So I’m looking for a way to apply “globally” the “i” 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-06-13T15:58:22+00:00Added an answer on June 13, 2026 at 3:58 pm

    As simple as this:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
     <xsl:strip-space elements="*"/>
        
     <xsl:template match="i">
         <xsl:text>\textit{</xsl:text>
         <xsl:apply-templates/>
         <xsl:text>}</xsl:text>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document:

    <one>
        <two>Some text with <i>italic</i> words</two>
    </one>
    

    the wanted, correct result is produced:

    Some text with \textit{italic} words
    

    Explanation:

    The XSLT processing model uses a number of built-in templates, using which a default processing of any XML document is provided, should the XSLT programmer not provide a template matching a specific node.

    In particular, the built-in template for any element node, just issues <xsl:apply-templates/> so that templates are applied on all of its children.

    The built-in template for any text node is to copy this text node to the output.

    This means that we don’t need to provide any template for a node, if it must do exactly what the corresponding built-in template does.

    That leaves us only with an i element — so we provide a template matching i — it simply surrounds by "\textit{" and "}" the result of processing its children.

    Do note:

    It is entirely possible to express a complex transformation without ever specifying a single <xsl:apply-templates>, <xsl:call-template>, <xsl:for-each>, <xsl:choose>, <xsl:when>, <xsl:otherwise> and <xsl:if>.

    This is called "push-style" as opposed by the "pull-style" where one or any of these instructions are extensively used.

    The "push" style expresses the most declarative solution of a problem, while a "pull-style" transformation expresses a more "imperative" solution.

    It is in the spirit of XSLT and recommended to always try to produce as much "push" code as possible.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. 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.