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

The Archive Base Latest Questions

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

This is the xml data I need to generate xslt from. <root> <entry id=1>

  • 0

This is the xml data I need to generate xslt from.

<root>
    <entry id="1">
         <headword>go</headword>
         <example>I <hw>go</hw> to school.</example>
    </entry>
    <entry id="2">
         <headword>come</headword>
         <example>I <verb>came</verb> back home.</example>           
    </entry>

I want to create an html like this:

<html>
     <body>
          <div class="entry" id="1">
                <span class="headword">go</span>
                <span class="example">I <span class="hw">go</span> to school.</span>
          </div>
          <div class="entry" id="2">
                <span class="headword">comeo</span>
                <span class="example">I <span class="hw">came</span> back home.</span>
          </div>
     </body>
</html>

This is my xslt:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <html>
            <body>
                <xsl:for-each select="root/entry">
                    <div class="entry">
                        <span class="headword">
                            <xsl:value-of select="headword"/>
                        </span>
                        <span class="example">
                            <xsl:value-of select="example"/>
                        </span>
                    </div>
                </xsl:for-each>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

I don’t know how to convert the value of the attribute “id,” and the element “hw.”

  • 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-17T14:22:46+00:00Added an answer on June 17, 2026 at 2:22 pm

    Please give this a try. I’m assuming the second class="hw" in your sample output was a typo and was supposed to be class="verb" since that’s the only possibility that makes sense:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:template match="/">
        <html>
          <body>
            <xsl:apply-templates select="root/entry" />
          </body>
        </html>
      </xsl:template>
    
      <xsl:template match="entry">
        <div class="entry" id="{@id}">
          <xsl:apply-templates select="*" mode="entryContents" />
        </div>
      </xsl:template>
    
      <xsl:template match="*" mode="entryContents">
        <span class="{local-name()}">
          <xsl:apply-templates select="node()" mode="entryContents" />
        </span>
      </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 this code to generate Xml from an IQueryable variable query: XDocument data
I'm working with XML data from an application where we get XML like this:
I am reading data from XML like this: (Contacts.xml) <?xml version=1.0 encoding=utf-8 standalone=yes?> <!--LINQ
I am parsing data from this XML url The text input varies, depending on
I need to generate a number of XML documents from Java objects. The objects
I need to develop an application that will periodically check data from a XML
This is the XML data: <Categorys> <Category> <categoryId>25</categoryId> <categoryName>My Photos</categoryName> <categoryDescription>Description</categoryDescription> <categoryIconPath>7.jpg</categoryIconPath> <userId>2</userId> <categoryStatus>ON</categoryStatus>
This site has a technique to pass xml data around in Microsoft SQL Server:
I have grabbed some XML data using this piece of jQuery: $.ajax({ type: POST,
When I receive XML data (via a Twitter API call, in this instance), 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.