[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Feature Suggestion - result subtrees as macro arguments (REV

Subject: Feature Suggestion - result subtrees as macro arguments (REVISED)
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Jan 1999 22:03:49 -0500
xsl apply template arguments
(After reviewing my post, I realize I screwed up and mixed two of my
(incompatible) thoughts into one ... this posting wholly replaces the
previous posting with the same title. Sorry for the confusion.
............. Ken)

Right now, macro arguments are attribute value templates:

<!ELEMENT xsl:arg EMPTY>
<!ATTLIST xsl:arg
  name NMTOKEN #REQUIRED
  value CDATA #REQUIRED
>

... and their default value can be specified:

<!ELEMENT xsl:macro-arg EMPTY>
<!ATTLIST xsl:macro-arg
  name NMTOKEN #REQUIRED
  default CDATA #IMPLIED
>

I've come across a situation where I'd like to supply to the macro a
fragment of the result tree as the value of an argument, as in the
following example:

<xsl:macro name="page-layout">
  <xsl:macro-arg name="title-block">
    <xsl:apply-templates match="title-prefix"/>
    <xsl:apply-templates match="title"/>
    <xsl:apply-templates match="title-suffix"/>
  </xsl:macro-arg>
  <xsl:apply-templates select="page-prefix"/>
  <xsl:arg name="title-block"/>
  <xsl:contents/>
</xsl:macro>
...
<xsl:template match="toc">
  <xsl:invoke macro="page-layout"> <!--supply custom title-->
    <xsl:use-arg name="title-block">
      <xsl:text>Table of Contents - </xsl:text>
      <xsl:apply-templates select="../prestitle"/>
    </xsl:use-arg>
    <xsl:apply-templates mode="toccreation" select="/">
  </xsl:invoke>
</xsl:template>
...
<xsl:template match="frame">
  <xsl:invoke macro="page-layout"> <!--using default title-->
    <xsl:apply-templates/>
  </xsl:invoke>
</xsl:template>

In the above, matching a normal frame adds the default "title-block"
subtree to the result tree, while matching the toc frame adds the supplied
"title-block" subtree to the result tree.

Can someone think of a better name than "xsl:use-arg" to identify the
subtree to be used as the macro argument in place of the default subtree to
use for the macro argument?

............ Ken 

--
G. Ken Holman         mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.  http://www.CraneSoftwrights.com/s/
Training:   http://www.CraneSoftwrights.com/s/schedule.htm
Resources: http://www.CraneSoftwrights.com/s/resources.htm
Shareware: http://www.CraneSoftwrights.com/s/shareware.htm
Next XSL Training (see training link):   WWW8 - 1999-05-11


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.