Jump to content

Xsl:variable Not Working In Ffv3.5.7


sifar786

Recommended Posts

Hi all,I have the following flavor.xml file:

<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="flavor.xsl"?><recipe>  <ingredients>	<item>Boneless chicken breasts</item>	<item>Chopped onions</item>	<item>Ginger</item>  </ingredients>  <process>	<step>Cut chicken into cubes, wash and apply lime juice and salt</step>	<step>Add ginger, garlic, chili, coriander and lime juice in a separate bowl</step>	<step>Mix well, and add chicken to marinate for 3-4 hours</step>	<step>Place chicken pieces on skewers and barbeque</step>	<step>Remove, apply butter, and barbeque again until meat is tender</step>	<step>Garnish with lemon and chopped onions</step>  </process></recipe>

and a flavor.xsl file to transform it:

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:variable name="flavour" select="'strawberry'" /><xsl:template match="/"><html><head><body>-- root level -- My favourite flavour is <xsl:value-of select="$flavour" /><br /><xsl:apply-templates select="recipe/ingredients" /><xsl:apply-templates select="recipe/process" />-- root level -- My favourite flavour is <xsl:value-of select="$flavour" /><br /></body></head></html></xsl:template><xsl:template match="ingredients/item"><xsl:variable name="flavour" select="'raspberry'" />-- item level -- My favourite flavour is <xsl:value-of select="$flavour" /><br /></xsl:template><xsl:template match="process/step">-- step level -- My favourite flavour is <xsl:value-of select="$flavour" /><br /></xsl:template></xsl:stylesheet>

The file gets transformed in IE7 easily, but does not display anything or give any error in FFv3.5.7.it seems the xsl:variable does not work in Firefox v3.5.7.Please advice....

Link to comment
Share on other sites

You have a body in your head. When IE outputs HTML, it reparses it. By doing so, it kicks into quirks mode and renders it. Firefox only takes the resulting DOM tree and renders it. Because it takes a tree, it always tries to render it in standards mode, at which point it fails because of the body in the head.If you indent your code, you'll notice it more easily. For future's sake, here's your code, working, indented, and with a <title/> added:

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:variable name="flavour" select="'strawberry'"/>	<xsl:template match="/">		<html>			<head>				<title>Flavor</title>			</head>			<body>				-- root level -- My favourite flavour is <xsl:value-of select="$flavour"/><br/>				<xsl:apply-templates select="recipe/ingredients"/>				<xsl:apply-templates select="recipe/process"/>				-- root level -- My favourite flavour is <xsl:value-of select="$flavour"/><br/>			</body>		</html>	</xsl:template>	<xsl:template match="ingredients/item">		<xsl:variable name="flavour" select="'raspberry'"/>		-- item level -- My favourite flavour is <xsl:value-of select="$flavour"/><br/>	</xsl:template>	<xsl:template match="process/step">-- step level -- My favourite flavour is <xsl:value-of select="$flavour"/><br/></xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...