xsl-list
[Top] [All Lists]

Re: template match

2003-12-29 11:14:42
At 2003-12-29 17:34 +0000, Mark Williams wrote:
I'm very new to xsl and xslt.

Welcome! You will find many free resources on the web to help you with the basics of both of these Recommendations. Two free book excerpts can be downloaded from our web site. Quality instructor-led training is also available from companies such as ours, Mulberry Technologies and ISOGEN.

I'm trying to use xsl template match within a xsl-fo document to reference
different nodes in the xml file.

Not sure what you mean by "within an XSL-FO document" ... it would help if you read up on the processing model. I suspect you are doing the typical: constructing an XSL-FO result document from your XML source document using an XSLT stylesheet.

I can add a template match statement

<xsl:template> instructions are construction rules called "template rules" describing that portion of the result tree that is constructed when a node from the source tree is pushed at the stylesheet using <xsl:apply-templates/>. Each of these template rules builds a small (or large) part of the result tree.

Your task as a stylesheet writer is to fragment the anticipated result into small well-formed packages of nodes expressed in XML syntax in your template rules that are triggered by the processing (we use the term "pushing" in our teaching) of source tree nodes under your control.

before the fo:root node and it works okay.

By "before" I'm assuming you mean the "/" root node of the source tree.

However, if I try to match
another node after the fo:root node I get a fop exception:

"xsl:template is not allowed in this position in the stylesheet".

You say "after" but I suspect you have tried to embed one template rule in another.

Template rules are "top-level instructions" and are sibling children of the XSLT stylesheet document element. They cannot be embedded.

Keep them as siblings, and engage them by using <xsl:apply-templates> selecting the nodes that you want pushed at your construction rules.

How do I switch node references within the fo:root node using template match.

Again your terminology doesn't match (no pun intended) the terminology of the recommendations ... I suspect I answered this with my previous sentence ... look for working examples of XSL-FO stylesheets in XSLT and mimic what you see.

Welcome again to these technologies ... they really are great to work with once you understand the basics of the processing model (XSLT) and data model (XPath) and result vocabulary (XSL-FO).

I hope this helps.

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

--
North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-02-09
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


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



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