xsl-list
[Top] [All Lists]

Re: [xsl] XSL and XML Help

2006-10-16 10:30:58
Wendell Piez wrote:

  Hi

At 06:00 PM 10/13/2006, Dr KM wrote:

You can do this with a for-each instruction, but
anything you can do with a for-each instruction you
can do with templates

  Excepted that template rules are applicable (mmh, not
sure this is correct English) only to nodes.

This is interesting ... it's true in XSLT 2.0, but not in
XSLT 1.0, where one can select only nodes when executing a
for-each.

  Yes.

In XSLT 1.0, indeed, the content of a for-each instruction
is formally called a "template", while what we commonly
call a "template" is actually named a "template rule"
(which usage I see you observe :-).

  Yes, there were a lot of confusion between "template" and
"template rule".  So XSLT 2.0 replaced "template" by
"sequence constructor".  But in your initial sentence above,
I guess you meant "template rule", isn't it ?-)

I suppose this is also not the case in XSLT 2.0?

  Mmh, I'm not sure what you mean here?

  A simple example for for-each vs/ apply-templates in XSLT
2.0.  It is not "right" (for one definition of "right") to
write:

    <xsl:function name="my:f">
      <xsl:param name="p" as="item()+"/>
      <xsl:apply-templates select="$p"/>
    </xsl:function>

Write instead:

    <xsl:function name="my:f">
      <xsl:param name="p" as="item()+"/>
      <xsl:for-each select="$p">
        ...
      </xsl:for-each>
    </xsl:function>

or:

    <xsl:function name="my:f">
      <xsl:param name="p" as="node()+"/>
      <xsl:apply-templates select="$p"/>
    </xsl:function>

or even:

    <xsl:function name="my:f">
      <xsl:param name="p" as="item()+"/>
      <xsl:sequence select="for $i in $p return ..."/>
    </xsl:function>

  But I agree for-each is often over-employed, instead of
template rules.

  Regards,

--drkm



















        

        
                
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Demandez à ceux qui savent sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>