Jump to content
sifar786

Xsl:variable Not Working In Ffv3.5.7

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....

Edited by sifar786

Share this post


Link to post
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>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...