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.
<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.