Q: XSLT transforming result of one template with another template- how?

B

Bernd Fuhrmann

Hi!

I have two (or more) templates for one certain tag:

The first one:
tobeimported.xsl:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:netzquantum="http://NetzQuantum"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="netzquantum xhtml"
<xsl:eek:utput method="xml"
cdata-section-elements="xhtml:script"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
encoding="iso-8859-1"/>

<xsl:template match="xhtml:html/xhtml:body">
<xsl:copy>
<p>This is the result of the first template</p>
<xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*|@*|text()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--------------------------------------
The second one:
importing.xsl:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:netzquantum="http://NetzQuantum"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="netzquantum xhtml"
<xsl:import href="tobeimported.xsl"/>

<xsl:eek:utput method="xml"
cdata-section-elements="xhtml:script"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
encoding="iso-8859-1"/>

<xsl:template match="xhtml:html/xhtml:body">
<xsl:copy>
<p>This is the result of the second template</p>
<xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
-----------------------------------------

The second template is now to be applied to an XHTML document. The
result should look sth like this:
<html><head>...</head>
<body>
<p>This is the result of the second template</p>
<p>This is the result of the first template</p>
</body>
</html>

My question is:
How can I apply the second template on the *result* of the first one?

While it might be trivial to get the same result as if it was applied on
the result of the first one I this example does not reflect the true
depth of my problem. Both templates (and more will come) will do more
complex transformations (like adding attributes to xhtml:body, analysing
stuff and so on).

Any ideas?

Thanks in advance
Bernd Fuhrmann
 

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

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top