Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Q: XSLT transforming result of one template with another template- how?

Reply
Thread Tools

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

 
 
Bernd Fuhrmann
Guest
Posts: n/a
 
      02-12-2004
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlnshtml="http://www.w3.org/1999/xhtml"
xmlns:netzquantum="http://NetzQuantum"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="netzquantum xhtml"
>


<xslutput 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"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlnshtml="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"/>

<xslutput 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Transforming xml using xslt into a string variable? Ken Adams Java 1 03-10-2005 04:13 PM
Transforming with XSLT, Grouping elements until difference found. Jody Greening XML 5 01-06-2005 06:52 PM
Transforming with XSLT, Grouping elements until difference found. Jody Greening XML 0 01-06-2005 04:07 PM
Using One XSLT and multiple XML Problem (One is XML and another one is XBRL) loveNUNO XML 2 11-20-2003 06:47 AM



Advertisments