Mycontent not showing up when I use the xslt stylesheet

Here should go questions about transforming XML with XSLT and FOP.
felix1845
Posts: 10

Mycontent not showing up when I use the xslt stylesheet

Tue May 30, 2017 5:06 pm

I made an xsl stylesheet and followed all the instructions in a tutorial I found online. It showed me this:

Code: Select all

<?xml version = "1.0" encoding = "UTF-8"?>
   <xsl:stylesheet version = "1.0"
      xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
      
   <xsl:template match = "/">
      <html>
         <body>
            <h2>Students</h2>
            <table border = "1">
               <tr bgcolor = "#9acd32">
                  <th>Roll No</th>
                  <th>First Name</th>
                  <th>Last Name</th>
                  <th>Nick Name</th>
                  <th>Marks</th>
               </tr>
               
               <xsl:for-each select = "class/student">
                  <tr>
                     <td><xsl:value-of select = "@rollno"/></td>
                     <td><xsl:value-of select = "firstname"/></td>
                     <td><xsl:value-of select = "lastname"/></td>
                     <td><xsl:value-of select = "nickname"/></td>
                     <td><xsl:value-of select = "marks"/></td>
                  </tr>
               </xsl:for-each>
               
            </table>
         </body>
      </html>
   </xsl:template> 
</xsl:stylesheet>


And I did that with my own xsl, like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:template match="/">
        <html>
            <body>
                <h2 style="text-align:center">
                    Marginalia in Mandeville's Travels
                </h2>
                <table>
                    <tr bgcolor = "#ffffff">
                        <th>Left Margin</th>
                        <th>Text Block</th>
                        <th>Right Margin</th>
                    </tr>
                    <xsl:for-each select="table">
                        <tr>
                            <td><xsl:value-of select="row/left"/></td>
                            <td><xsl:value-of select="row/middle"/></td>
                            <td><xsl:value-of select="row/right"/></td>
                        </tr>
                    </xsl:for-each>
                </table>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>


And what happens is the table header stuff arrives, but none of the table content appears. Can someone point out what I'm doing wrong? Thanks.
adrian
Posts: 2326

Re: Mycontent not showing up when I use the xslt stylesheet

Tue May 30, 2017 6:27 pm

Hi,

What's your XML source?

Without seeing the source, I guess it should work with

Code: Select all

<xsl:for-each select="//table">


Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
felix1845
Posts: 10

Re: Mycontent not showing up when I use the xslt stylesheet

Tue May 30, 2017 7:58 pm

That works! The formatting's all to hell, but I can figure that out. Thanks!

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 2 guests