XSL: Parametrized copies of a common block

  • Thread starter Ilpo =?iso-8859-1?Q?Nyyss=F6nen?=
  • Start date
I

Ilpo =?iso-8859-1?Q?Nyyss=F6nen?=

Take an XML source:

<document>
<recipient>
<name>John Doe</name>
<email>[email protected]</email>
</recipient>
<recipient>
<name>Jane Doe</name>
<email>[email protected]</email>
</recipient>
<body>
<title>Hello <recipient-name/>,</title>
<section>
Some text...
</section>
<section>
<b>Bolded text...</b>
</section>
</body>
</document>

Now it should be quite clear that I want to create multiple copies of
the body parametrized with the values in the recipient. As the body
can be quite complex, it can't be done with a single xslt template.
The question is, how to make those references to the recipient
element?

I have few ideas:

1) Only one XSLT stylesheet: in top level match the recipients and
from there pass enough information further to get the data for the
references.

Problem with this: need to pass the parameters for multiple levels of
templates. This makes the stylesheet quite ugly.

2) Restructure the document with one stylesheet and then do the actual
transformation with another.

Problem with this: two stylesheets.

3) Find a way to handle the references in the result.

Problem with this: Do the result formats have a way to do references?

Background:

I need to be able to generate several formats: pdf, html and text (max
80 chars in a line). Currently I do the pdf with XSL-FO and the others
via HTML. The most important formats are the pdf and the text. I
translate the XSL-FO to pdf with fop.

I tried to express the original problem here. I am able to do at least
solutions 1) and 2), but those are both quite ugly and I really would
like to have a beautiful solution.
 
I

Ilpo =?iso-8859-1?Q?Nyyss=F6nen?=

[email protected] (Ilpo Nyyssönen) said:
1) Only one XSLT stylesheet: in top level match the recipients and
from there pass enough information further to get the data for the
references.

Problem with this: need to pass the parameters for multiple levels of
templates. This makes the stylesheet quite ugly.

Ok, XSLT 2.0 tunnel parameters solve this and I get those with saxon
and it even works.

Thanks for the help. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top