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

The Archive Base Latest Questions

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

I want to convert xml file using xsltproc and only extract some portions of

  • 0

I want to convert xml file using xsltproc and only extract some portions of it, I have xslt like this:

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

    <xsl:template match="glossary">
        <ul>
        <xsl:for-each select="*/glossentry">
            <li>
                <h2><xsl:value-of select="glossterm"/> (<xsl:value-of select="abbrev/emphasis"/>)</h2>
                <div><xsl:value-of select="*/para"/></div>
            </li>
        </xsl:for-each>
        </ul>
    </xsl:template>
    <xsl:template match="/">
        <html>  
        <body>
        <xsl:apply-templates/>
        </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

But it show all other text that was inside xml as text. What’s need to be added or change to only show something like this?

<html><body>
<ul>
<li>
  <h2>Term (abbrev)</h2>
  <div>Para</div>
</li>
<li>
  <h2>Term2 (abbrev2)</h2>
  <div>Para2</div>
</li>
...
</ul>
  • 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-11T09:13:50+00:00Added an answer on June 11, 2026 at 9:13 am

    Ok, I found it, I need to add select to apply-templates

    <?xml version="1.0" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output
           method="xml"
           indent="yes"
           encoding="iso-8859-1" />
    
        <xsl:template match="part">
            <xsl:if test="@id = 'lexicon'">
                <xsl:apply-templates select="glossary"/>
            </xsl:if>
        </xsl:template>
    
        <xsl:template match="glossary">
            <ul>
            <xsl:for-each select="*/glossentry">
                <li>
                    <h2><xsl:value-of select="glossterm"/> 
                        <xsl:if test="abbrev">
                          <xsl:text>: </xsl:text>
                          <xsl:for-each select="abbrev/*">
                            <xsl:if test="position() &gt; 1">, </xsl:if>
                            <xsl:apply-templates select="."/>
                          </xsl:for-each>
                        </xsl:if>
                    </h2>
                    <div><xsl:value-of select="*/para"/></div>
                </li>
            </xsl:for-each>
            </ul>
        </xsl:template>
        <xsl:template match="book">
            <html>
                <title><xsl:value-of select="title"/></title>
            <body>
            <xsl:apply-templates select="part"/>
            </body>
            </html>
        </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML file and i want to convert to XML only using
I have an XML file generated using javax.sql.rowset.WebRowSet.writeXml which looks like: <metadata> This section
I have an XML file which I want to convert into JSON file using
I have an HTML file and i want to convert to XML document only
I want to convert one xml file into another xml file using xslt.here, i
Using XSLT transformation I want to convert an XML file, that in turn represents
I want to convert one xml format to another specified format by using xslt.
I want to convert an xml element like this: <asin>​B0013FRNKG​</asin>​ to string in javascript
I am trying to convert an HTML file into XML file using XSLT (Using
I want to convert one xml format to another xml format by using xslt

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.