This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:template - matching template with the name which is not in XML/DOM
- To: xsl-list at mulberrytech dot com
- Subject: Re: xsl:template - matching template with the name which is not in XML/DOM
- From: Wendell Piez <wapiez at mulberrytech dot com>
- Date: Thu, 24 Aug 2000 11:08:58 +0100
- Reply-To: xsl-list at mulberrytech dot com
Babu:
If I understand correctly, you want not <xsl:apply-templates
select="CHECK"/> but rather <xsl:call-template name="CHECK"/>.
<xsl:apply-templates select="CHECK"/> would select any element children of
the context node (the node currently being processed), and apply any
available matching templates to them. Since the source document has no such
CHECK elements, none would ever be selected, and hence no templates would
ever be fired.
<xsl:call-template name="CHECK">, however, allows you to call a template by
name, as if it were a function.
See XSLT, section 6.
Good luck,
Wendell
At 09:52 PM 8/23/00 -0700, you wrote:
>Hi
>
>I have a ? regarding using of "apply-templates
>match="name"
>
>can "name" be anything, that means, it is not an
>element of XML.
>
>
>XML file
>--------
>
><?xml version="1.0"?>
><?xml-stylesheet type="text/xsl"
>href="testtemplate2.xsl"?>
><ADDRESS>
> <NAME>
> <FIRSTNAME>John</FIRSTNAME>
> <LASTNAME>micheal</LASTNAME>
> </NAME>
> <CITY>mountain view</CITY>
> <STATE>CA</STATE>
></ADDRESS>
>
>
>XSL file
>--------
>
><?xml version="1.0"?>
><xsl:stylesheet
>xmlns:xsl="http://www.w3.org/TR/WD-xsl">
>
><xsl:template match="/">
> <html>
> <xsl:apply-templates select="CHECK"/> -- *
> </html>
></xsl:template>
>
><xsl:template match="CHECK"> -- **
> <title>
> Hey man what are you doing
> </title>
></xsl:template>
>
></xsl:stylesheet>
>
>
>
>Question:
>---------
>1.when the xsl transformer checks for the root node,
>then it looks in the stylesheet
>for the match for root, if there it does the process
>inside template.
>
>
>2.can i say apply-templates select="CHECK" as in line
>*.
> Note: CHECK is not in the xml document so will not
>be in the dom tree.
>
>but can i just create a template for CHECK which is
>not in dom tree and call that, will it be called
>when coded as i have coded.
>
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list