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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:06:46+00:00 2026-05-25T06:06:46+00:00

I’m trying to process XML inner text. I have the following XSLT snippet: <?xml

  • 0

I’m trying to process XML inner text. I have the following XSLT snippet:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>

    <xsl:template match="/">
        <xsl:copy>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="refsect1[@id='errors']/param">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="param/constant">
        <i><xsl:apply-templates/></i>
    </xsl:template>

    <xsl:template match="param/parameter">
        <paramref cref="{.}"/>
    </xsl:template>

    <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>
    <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>

    <xsl:template name="summary" match="refentry">
/// <summary>
/// <xsl:value-of select="concat(translate(
                    substring(refnamediv/refpurpose, 1, 1), $lowercase, $uppercase),
                    substring(refnamediv/refpurpose, 2, string-length(refnamediv/refpurpose) - 1))"/>
/// </summary>
        <xsl:for-each select="refsect1/variablelist/varlistentry">
            <xsl:choose>
                <xsl:when test="../../@id = 'parameters'">
/// <param name="{term/parameter}">
        <xsl:for-each select="listitem/para">
/// <xsl:value-of select="normalize-space(.)"/>
        </xsl:for-each>
/// </param>
                </xsl:when>
            </xsl:choose>
        </xsl:for-each>
/// <remarks>
/// <para>
/// This routine generates the following errors (detectable with <see cref="Gl.GetError"/>):
        <xsl:for-each select="refsect1[@id='errors']/para">
/// <xsl:value-of select="normalize-space(.)"/>
        </xsl:for-each>
/// </para>
/// </remarks>
        <xsl:for-each select="refsect1[@id = 'seealso']/para/citerefentry">
/// <seealso cref="Gl.{substring(refentrytitle, 3)}"/>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

This XSLT shall be applied to a XML document; here is a snippet:

<refsect1 id="errors"><title>Errors</title>
    <para>
        <constant>GL_INVALID_OPERATION</constant> is generated if <parameter>pipeline</parameter> is not
        a name previously returned from a call to <citerefentry><refentrytitle>glGenProgramPipelines</refentrytitle></citerefentry>
        or if such a name has been deleted by a call to
        <citerefentry><refentrytitle>glDeleteProgramPipelines</refentrytitle></citerefentry>.
    </para>
    <para>
        <constant>GL_INVALID_OPERATION</constant> is generated if <parameter>program</parameter> refers
        to a program object that has not been successfully linked.
    </para>
</refsect1>

My current output is actually a plain text:

/// <remarks>
/// <para>
/// This routine generates the following errors (detectable with <see cref="Gl.GetError" />):
/// GL_INVALID_OPERATION is generated if pipeline is not a name previously returned from a call to glGenProgramPipelines or if such a name has been deleted by a call to glDeleteProgramPipelines.
/// GL_INVALID_OPERATION is generated if program refers to a program object that has not been successfully linked.
/// </para>
/// </remarks>

but I’d like to to process it in order to transform the internal tags in other tags. For example:

<costant>text</constant> shall become <i>text</i>

and

*<parameter>GL_PARAM</parameter>* shall become <paramref cref=”Gl.PARAM”/>


How to achieve this result?


After that Alexander has helped me, I got I have to call xsl:apply-template. It starting to work, but I cannot control the space normalization:

/// <para>
/// This routine generates the following errors (detectable with <see cref="Gl.GetError" />):
    <i>GL_INVALID_OPERATION</i> is generated if <paramref cref="pipeline" /> is not
        a name previously returned from a call to glGenProgramPipelines
        or if such a name has been deleted by a call to
        glDeleteProgramPipelines.
    <i>GL_INVALID_OPERATION</i> is generated if <paramref cref="program" /> refers
        to a program object that has not been successfully linked.

/// </para>

I’m calling xsl:apply-template just after the foreach instruction:

/// <para>
/// This routine generates the following errors (detectable with <see cref="Gl.GetError"/>):
    <xsl:for-each select="refsect1[@id='errors']/para">
        <xsl:apply-templates/>
    </xsl:for-each>
/// </para>
  • 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-25T06:06:47+00:00Added an answer on May 25, 2026 at 6:06 am

    Part of the trick is to understand the power of functional and declarative programming. You’ve got a very imperative style at the moment, so let’s rewrite it a bit ;

    <xsl:template match="refsect1[@id='errors']/param">
       <xsl:apply-templates />
    </xsl:template>
    
    <xsl:template match="param/constant">
       <i><xsl:apply-templates /></i>
    </xsl:template>
    
    <xsl:template match="param/parameter">
       <paramref cref="{.}" />
    </xsl:template>
    

    That’s roughly all you need. Basically, instead of going through all parts of your XML and try to do something at that point, use the templating system to match the items in question and have it done far more efficient and powerful.

    Lastly, if your GL_PARAM to Gl.PARAM wasn’t a typo, you need to do some extra text transformation on top, but it isn’t that hard if you know the formula (you didn’t say :), using something like before-substring(), after-substring(), and translate().

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is

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.