Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Passing an XSL param from one template to another

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="xx">
  <html>
  <body>
  <xsl:call-template name="show_title">
    <xsl:with-param name="title" />
  </xsl:call-template>
  </body>
  </html>
</xsl:variable>

<xsl:template name="show_title" match="/">
  <xsl:param name="title" />
  <xsl:for-each select="catalog/cd">
    <p>Title: <xsl:value-of select="$title" /></p>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

source: XSLT <xsl:param> Element [w3schools.com]

enforce lit-word! param

To enforce passing a lit-word! param, you need to make the param a get-word!, so it isn't evaluated when the func is called. This won't work if you're dynamically creating the param of course.

incr: func [
    {Increment a value by 1.}
    :word [lit-word!]
    /by {Change by this amount}     ; /skip ?
        value
][
    set word add get word any [value 1]
]


;>> a: 0
;== 0
;>> incr a
;** Script Error: incr expected word argument of type: ;lit-word
;** Near: incr a
;>> incr 'a
;== 1

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS