Page 1 of 1 [ 4 posts ] 

dalhousie12
Veteran
Veteran

User avatar

Joined: 5 Jul 2007
Age: 40
Gender: Male
Posts: 1,059
Location: A frozen baron wasteland, me and my friend tuk have to watch out for flying frozen hockey pucks Eh!

03 Mar 2009, 3:41 pm

i'm brand new to xsl and am looking for help with the following piece of code. The error i get is as follows:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

End tag 'xsl:otherwise' does not match the start tag 'xsl:when'. Error processing resource 'file:///C:/Documents and Settin...

</xsl:otherwise>
-----------^

The corresponding piece of xsl code is as follows:
<!--<xsl:for-each select="JOBFile/FieldBook/*">--> <!--Every child node of FieldBook-->
<xsl:for-each select="/JOBFile/FieldBook/*">
<xsl:choose>
<xsl:when test="local-name() = 'EllipsoidRecord'"> <!--Spit out Ellipsoid Records-->
<xsl:choose>
<xsl:when test="EarthRadius = '6378137'">
<tr/><xsl:call-template name="OutputFormattedDateTime">
<xsl:with-param name="DateTime" select="@TimeStamp"/>
</xsl:call-template>
<td bgcolor="rgb(0,225,0)"> <xsl:value-of select="EarthRadius"/></td>


<xsl:when>
<xsl:when test="EarthRadius = '&lt; 6378137 &gt; '">
<tr/><xsl:call-template name="OutputFormattedDateTime">
<xsl:with-param name="DateTime" select="@TimeStamp"/>
</xsl:call-template>
<td bgcolor="rgb(225,225,0)"> <xsl:value-of select="EarthRadius"/></td>
</xsl:otherwise>
</xsl:choose>
<xsl:when> <!-- End of Ellipsoid Record test -->

</xsl:choose> <!-- End of first fieldbook loop -->

</xsl:for-each> <!-- outer loop, End of first Fieldbook loop -->

</table>
</xsl:template>

It seems i need to add or remove a line of code but i'm not sure what. Any help would be greatly appreicated.

Thanks


_________________
Ralph Wiggum has my vote for president of the United States! I especially like his immgration policy. STRANGER DANGER!


0_equals_true
Veteran
Veteran

User avatar

Joined: 5 Apr 2007
Age: 39
Gender: Male
Posts: 11,038
Location: London

03 Mar 2009, 5:38 pm

I suppose it might be because you haven't put <xsl:otherwise>

But this all shows just how incredibly overrated xml is. All you are making is angle bracket spaghetti. Certainly don't use it to render web output. Only the top browsers have transformation engine.

If you look at what xml is actually used for in practice and you will see it is often used as a convoluted serialisation tasks like installation and config files. It rarely used in AJAX anymore despite the name, and why would it be it is a totally redundant use. That is because it want to send stuff you don’t want to have to rely on you browsers certain inability to handle it, when you just want to pass on the required information simply (rather than bloated crap) and fast, and let your code handle it.

Things like YAML and JSON do serialisation a lot better, are easy on the eye, and don't take an age to parse due to unnecessary built in complexity.

XML is an example of not scrapping what really isn't working in the first place. Have you any idea of the parsing engines that have to be build to parse these tags? XML is often used without an enforced document definition, so that put its validity in question.

XHTML is ok but that is only because it is an improved version of HTML basically.



peterd
Veteran
Veteran

User avatar

Joined: 25 Dec 2006
Age: 69
Gender: Male
Posts: 1,335

04 Mar 2009, 7:43 am

Quote:
<xsl:for-each select="/JOBFile/FieldBook/*">
<xsl:choose>
<xsl:when test="local-name() = 'EllipsoidRecord'"> <!--Spit out Ellipsoid Records-->
<xsl:choose>
<xsl:when test="EarthRadius = '6378137'">
<tr/><xsl:call-template name="OutputFormattedDateTime">
<xsl:with-param name="DateTime" select="@TimeStamp"/>
</xsl:call-template>
<td bgcolor="rgb(0,225,0)"> <xsl:value-of select="EarthRadius"/></td>


</xsl:when>
<xsl:when test="EarthRadius = '&lt; 6378137 &gt; '">
<tr/><xsl:call-template name="OutputFormattedDateTime">
<xsl:with-param name="DateTime" select="@TimeStamp"/>
</xsl:call-template>
<td bgcolor="rgb(225,225,0)"> <xsl:value-of select="EarthRadius"/></td>
</xsl:when>
</xsl:choose>
</xsl:when> <!-- End of Ellipsoid Record test -->

</xsl:choose> <!-- End of first fieldbook loop -->


Each <xsl:when> needs to be closed by a </xsl:when>
If you want a <xsl:otherwise>, it'll need a </xsl:otherwise> to close it

and so forth

Check here for further details



dalhousie12
Veteran
Veteran

User avatar

Joined: 5 Jul 2007
Age: 40
Gender: Male
Posts: 1,059
Location: A frozen baron wasteland, me and my friend tuk have to watch out for flying frozen hockey pucks Eh!

04 Mar 2009, 10:56 am

peterd wrote:
Quote:
<xsl:for-each select="/JOBFile/FieldBook/*">
<xsl:choose>
<xsl:when test="local-name() = 'EllipsoidRecord'"> <!--Spit out Ellipsoid Records-->
<xsl:choose>
<xsl:when test="EarthRadius = '6378137'">
<tr/><xsl:call-template name="OutputFormattedDateTime">
<xsl:with-param name="DateTime" select="@TimeStamp"/>
</xsl:call-template>
<td bgcolor="rgb(0,225,0)"> <xsl:value-of select="EarthRadius"/></td>


</xsl:when>
<xsl:when test="EarthRadius = '&lt; 6378137 &gt; '">
<tr/><xsl:call-template name="OutputFormattedDateTime">
<xsl:with-param name="DateTime" select="@TimeStamp"/>
</xsl:call-template>
<td bgcolor="rgb(225,225,0)"> <xsl:value-of select="EarthRadius"/></td>
</xsl:when>
</xsl:choose>
</xsl:when> <!-- End of Ellipsoid Record test -->

</xsl:choose> <!-- End of first fieldbook loop -->


Each <xsl:when> needs to be closed by a </xsl:when>
If you want a <xsl:otherwise>, it'll need a </xsl:otherwise> to close it

and so forth

Check here for further details


Thank You


_________________
Ralph Wiggum has my vote for president of the United States! I especially like his immgration policy. STRANGER DANGER!