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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:39:24+00:00 2026-06-14T22:39:24+00:00

I have searched the internet/and posts on here to try and find an answer

  • 0

I have searched the internet/and posts on here to try and find an answer to the question I have. I am learning XML and have an assignment I have to turn a previous .xml to .xslt. I have gotten all of it but a small matter of code that will not find the value I have inputed.
For example; and I know there are probably tons of other ways to make this happen but this is the code I have been given.

A part of the .xml is as follows:

     <collection>
     <movie>
     <title>Braveheart</title>
     <genre v_genre="Action"/>
     <rating v_rating="R"/>
     <grading v_grading="4"/>
        <summary>William Wallace, a commoner, unites the 13th Century Scots in their battle to overthrow Englands rule </summary>
    <year>1995</year>
    <director>Mel Gibson</director>
    <runtime>177</runtime>
    <studio>Icon Entertainment International</studio>
    <actors>
        <actor ID="001">Mel Gibson</actor>
        <actor ID="002">Sophie Marceau</actor>
        <actor ID="003">Patrick McGoohan</actor>
    </actors>
</movie>

Now for this I do not understand the value.

If someone could help me out with understand that part I would greatly appreciate it. Part 2 of the question is going to an .xslt doc all populates correctly except the following sectors:genre, rating, and grading. I have tried a multiple different ways to try and get the values to populate. Here is a section of the code.

<xslt:for-each select="collection/movie">

 <tr>

 <td>

 <xslt:value-of select="title"/>

 </td>

 <td>

  <xslt:value-of select="genre"/>

 </td>

 <td>

<xslt:value-of select="rating/v_rating"/>

</td>

<td>

 <xslt:value-of select="grading/v_grading"/>

 </td>
 <td>
 <xslt:value-of select="summary"/>
 </td>               
 <td>
  <xslt:value-of select="year"/>
  </td>
   <td>
  <xslt:value-of select="director"/>
  </td>
  <td>
  <xslt:value-of select="runtime"/>
   </td>
   <td>
    <xslt:value-of select="studio"/>
   </td>
   <td>
  <xslt:value-of select="actors"/>
  </td>
  </tr>

 </xslt:for-each>

  </table>

 </body>

  </html>

  </xslt:template>
  </xslt:stylesheet>

I am trying to actually understand why that is that way for future uses. The whole college thing. Hopefully this will not get deleted. I have searched tons of places to figure this out but no examples list it this way. Thank you in advanced.

  • 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-14T22:39:25+00:00Added an answer on June 14, 2026 at 10:39 pm

    The elements you are having trouble with are these

     <genre v_genre="Action"/>
     <rating v_rating="R"/>
     <grading v_grading="4"/>
    

    So, if you notice, the values you want are held in attributes, not child text nodes. Therefore you need to change your xsl:value-of to this (in the the example of genre

    <xsl:value-of select="genre/@v_genre"/>
    

    If you are keen to learn XSLT, it might be worth knowing it is preferable to use xsl:apply-templates over xsl:for-each. Additionally, you should look to remove repitition in you code. Looking at your example, the table cells are output in the same order as the child elements in your XML. Therefore, you could create a generic template to match most of the child elements to output table cells.

    Try this XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
       <xsl:template match="/collection">
          <table>
             <xsl:apply-templates select="movie"/>
          </table>
       </xsl:template>
    
       <xsl:template match="movie">
          <tr>
             <xsl:apply-templates/>
          </tr>
       </xsl:template>
    
       <xsl:template match="genre">
          <td>
             <xsl:value-of select="@v_genre"/>
          </td>
       </xsl:template>
    
       <xsl:template match="rating">
          <td>
             <xsl:value-of select="@v_rating"/>
          </td>
       </xsl:template>
    
       <xsl:template match="grading">
          <td>
             <xsl:value-of select="@v_grading"/>
          </td>
       </xsl:template>
    
       <xsl:template match="*">
          <td>
             <xsl:value-of select="."/>
          </td>
       </xsl:template>
    </xsl:stylesheet>
    

    Note that the XSLT processor will match the more specific named element (e.g. genre) before matching the generic template for * at the end.

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

Sidebar

Related Questions

I have searched the internet looking for a definitive answer to the question of
I have searched the internet and the perforce help pages, but couldn't find a
I have searched the internet for an answer to what could be causing EXCEPTION_ACCESS_VIOLATION
I have searched this on the internet, but have found no solution... Here is
I have searched the Internet, but I can't find the info I'm looking for.
Searched, but couldn't find a good answer. I have an ASP.NET application that I
I have searched internet and stackoverflow thoroughly, but I haven't found answer to my
I have searched the Internet and I can't seem to find anything related to
I have searched the internet and the Boost serialization docs and I cannot find
I have searched through internet & found that there are no any direct method

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.