Jump to content

my useless with-param


Recommended Posts

Hello !

 

Hope someone could help me with this one.

 

I accidently wrote this code:

 

<select name="TYPE" id="TYPE" > <xsl:apply-templates select="TYPE-OPTION" /> <!-- The '/' closed the tag too early --> <xsl:with-param name="Slctd" select="normalize-space(TYPE-SELECTED)" /> <!--The with-param became worthless--></select>

 

It was suppose to be like this :

<select name="TYPE" id="TYPE" > <xsl:apply-templates select="TYPE-OPTION"> <xsl:with-param name="Slctd" select="normalize-space(TYPE-SELECTED)" />

</xsl:apply-templates> <!-- now the with-param is doing something --></select>

 

As you can see in the first part, I accidently closed the xsl:apply-templates tag too early with / , making the with-param completely useless.

This caused a bug.

 

Is this code legal ?

Is there a way or a product which could warn me about this kind of mistakes ?

 

TNX

Agumiya

Link to post
Share on other sites

When compiling your stylesheet, your XSLT processor should tell you that the `xsl:with-param` is not allowed where you put it. For instance with

 

<xsl:stylesheet    version="1.0"    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    <xsl:template match="root">  <xsl:apply-templates select="foo"/>  <xsl:with-param name="p" select="1"/></xsl:template></xsl:stylesheet>

Saxon 6.5.5 tells me

 

Error at xsl:with-param on line 7 of file:/C:/Users/Foo/Bar/sheet.xsl  xsl:with-param cannot appear as a child of xsl:template
  • Like 1
Link to post
Share on other sites

 

When compiling your stylesheet, your XSLT processor should tell you that the `xsl:with-param` is not allowed where you put it. For instance with

<xsl:stylesheet    version="1.0"    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    <xsl:template match="root">  <xsl:apply-templates select="foo"/>  <xsl:with-param name="p" select="1"/></xsl:template></xsl:stylesheet>

Saxon 6.5.5 tells me

Error at xsl:with-param on line 7 of file:/C:/Users/Foo/Bar/sheet.xsl  xsl:with-param cannot appear as a child of xsl:template

 

Thank you Martin !

 

I`ll check into it.

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