Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Eclipse Web Tools Platform Project (WTP) » XSL XML transformation not working and item not appearing for selection for HTTP server
XSL XML transformation not working and item not appearing for selection for HTTP server [message #1865802] Mon, 13 May 2024 13:33 Go to next message
ro ro is currently offline ro roFriend
Messages: 1
Registered: May 2024
Junior Member
I've been trying to figure out why my XML and XSL transformation keep failing to generate in XML originally the format was in HTML and it generated perfectly. But after I changed the output method for XSL to HTML it did not generate for me when I tried transforming

my XML
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="/(name of file).xsl"?>
<forecast queryTime="28/04/2024 10:45 AM" queryLocation="Singapore">
  <weather yyyymmdd="20240411">
    <year>2024</year>	
    <month>4</month>
    <date>11</date>
    <dayOfWeek>Thu</dayOfWeek> 
    <overall>Considerable clouds</overall>
    <overallCode>cloudy</overallCode>
    <highest>27</highest>
    <lowest>17</lowest>
  </weather>
  <weather yyyymmdd="20240116">
    <year>2024</year>	
    <month>1</month>
    <date>16</date>
    <dayOfWeek>Tue</dayOfWeek> 
    <overall>Cloudy with a thunderstorm</overall>
    <overallCode>thunderstorm</overallCode>
    <highest>26</highest>
    <lowest>18</lowest>
  </weather>
  <weather yyyymmdd="20240405">
    <year>2024</year>	
    <month>4</month>
    <date>5</date>
    <dayOfWeek>Fri</dayOfWeek> 
    <overall>Afternoon shower</overall>
    <overallCode>rain</overallCode>
    <highest>22</highest>
    <lowest>19</lowest>
  </weather>
  <weather yyyymmdd="20240209">
    <year>2024</year>	
    <month>2</month>
    <date>9</date>
    <dayOfWeek>Fri</dayOfWeek> 
    <overall>A morning shower, then rain</overall>
    <overallCode>rain</overallCode>
    <highest>29</highest>
    <lowest>20</lowest>
  </weather>
  <weather yyyymmdd="20240310">
    <year>2024</year>	
    <month>3</month>
    <date>10</date>
    <dayOfWeek>Sun</dayOfWeek> 
    <overall>Partly sunny</overall>
    <overallCode>partlySunny</overallCode>
    <highest>30</highest>
    <lowest>21</lowest>
  </weather>
  <weather yyyymmdd="20240311">
    <year>2024</year>	
    <month>3</month>
    <date>11</date>
    <dayOfWeek>Mon</dayOfWeek> 
    <overall>Plenty of sunshine</overall>
    <overallCode>sunny</overallCode>
    <highest>34</highest>
    <lowest>20</lowest>
  </weather>
</forecast>


my XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://    www.w3.org/1999/XSL/Transform" xmlns="http://    www.w3.org/1999/xhtml">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/forecast">
    <html>
    <head>
        <title>Testing</title>
        <style>
            body {
                font-family: Arial, sans-serif;
            }
            table {
                border-collapse: collapse;
                table-layout: fixed;
                width: 100%;
            }
            th, td {
                border: 1px solid black;
                height: 100px; /* Ensures square cells */
                text-align: center;
                vertical-align: middle;
            }
            th {
                background-color: #FFD700; /* Darker yellow for top row */
                font-weight: bold;
            }
            td:first-child {
                background-color: orange; /* Leftmost column background color */
                font-weight: bold;
            }
            .bold {
                font-weight: bold;
                font-size: 16px;
            }
            .blue {
                color: blue;
            }
            .red {
                color: red;
            }
            .green {
                color: green;
            }
        </style>
    </head>
    
    <body>
        <h1>Singapore [01/08/20 10:00 PM]</h1>
        <table>
            <tr>
                <th>Date</th>
                <th>Mon</th>
                <th>Tue</th>
                <th>Wed</th>
                <th>Thu</th>
                <th>Fri</th>
                <th>Sat</th>
                <th>Sun</th>
            </tr>
            <xsl:for-each select="forecast/day">
                <xsl:variable name="day_of_week" select="@dayOfWeek"/>
                <tr>
                    <td><xsl:value-of select="@date"/></td>
                    <td>
                        <xsl:if test="$day_of_week='Mon'">
                            <xsl:call-template name="format-weather"/>
                        </xsl:if>
                    </td>
                    <td>
                        <xsl:if test="$day_of_week='Tue'">
                            <xsl:call-template name="format-weather"/>
                        </xsl:if>
                    </td>
                    <td>
                    </td>
                    <td>
                        <xsl:if test="$day_of_week='Thu'">
                            <xsl:call-template name="format-weather"/>
                        </xsl:if>
                    </td>
                    <td>
                        <xsl:if test="$day_of_week='Fri'">
                            <xsl:call-template name="format-weather"/>
                        </xsl:if>
                    </td>
                    <td>
                    </td>
                    <td>
                        <xsl:if test="$day_of_week='Sun'">
                            <xsl:call-template name="format-weather"/>
                        </xsl:if>
                    </td>
                </tr>
            </xsl:for-each>
        </table>
    </body>
    </html>
</xsl:template>

<xsl:template name="format-weather">
    <div class="bold">
        <xsl:value-of select="concat(lowest, '° - ', highest, '°')"/>
        <br/>
        <img src="{overallImage}"/>
        <br/>
        <xsl:value-of select="overallCode"/>
        <br/>
        <xsl:choose>
            <xsl:when test="contains(overall, 'Cloudy with a thunderstorm') or contains(overall, 'A morning shower, then rain')">
                <span class="blue"><xsl:value-of select="overall"/></span>
            </xsl:when>
            <xsl:when test="contains(overall, 'Sunny') and @dayOfWeek='Mon'">
                <span class="red"><xsl:value-of select="overall"/></span>
            </xsl:when>
            <xsl:when test="contains(overall, 'Partly sunny') and @dayOfWeek='Fri'">
                <span class="red"><xsl:value-of select="overall"/></span>
            </xsl:when>
            <xsl:when test="contains(overall, 'Partly cloudy')">
                <span class="red"><xsl:value-of select="overall"/></span>
            </xsl:when>
            <xsl:when test="contains(overall, 'Considerable clouds')">
                <span class="green"><xsl:value-of select="overall"/></span>
            </xsl:when>
            <xsl:otherwise>
                <span><xsl:value-of select="overall"/></span>
            </xsl:otherwise>
        </xsl:choose>
    </div>
</xsl:template>

</xsl:stylesheet>



this code is after changing my output to HTML ^^ (also I've spaced out the https links cause it limited me to not send this in this forum due to being a new user)

Adding onto that my HTTP server has also been facing issues I was not able to locate the original outputted transformation of my HTML code to the HTTP preview server on the configuration, it did not appear on the section to let me choose it either. The original output did not appear when I clicked on Edit Configuration > Common > Folder either. When I run the server it does not seem to pop up either but I can see that its running. I've already changed the port to 8080 with assistance of someone's inquiry from this forum.
Re: XSL XML transformation not working and item not appearing for selection for HTTP server [message #1865808 is a reply to message #1865802] Mon, 13 May 2024 14:48 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4476
Registered: July 2009
Senior Member

You haven't mentioned any error messages for the transformation, nor what's performing the transformation. I'm also not sure what Folder field you're editing for the HTTP Preview server. Could you provide that information?

_
Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Mon, 13 May 2024 17:37]

Report message to a moderator

Previous Topic:Could someone guide me on how to accomplish this?
Next Topic:Javascript syntax coloring
Goto Forum:
  


Current Time: Sat Jul 27 10:44:05 GMT 2024

Powered by FUDForum. Page generated in 0.03139 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top