XSL: Parametrized copies of a common block

Joined
May 24, 2004
Messages
13
Reaction score
0
Take an XML source:

<document>
<recipient>
<name>John Doe</name>
<email></email>
</recipient>
<recipient>
<name>Jane Doe</name>
<email></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.
 
Joined
May 24, 2004
Messages
13
Reaction score
0
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
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top