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

Discussion in 'XML' started by Bernd Fuhrmann, Feb 12, 2004.

  1. 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
     
    Bernd Fuhrmann, Feb 12, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Adams
    Replies:
    1
    Views:
    709
    Arnaud Berger
    Mar 10, 2005
  2. loveNUNO
    Replies:
    2
    Views:
    927
    loveNUNO
    Nov 20, 2003
  3. Jody Greening
    Replies:
    5
    Views:
    683
    Jody Greening
    Jan 6, 2005
  4. Jody Greening
    Replies:
    0
    Views:
    341
    Jody Greening
    Jan 6, 2005
  5. Michael Tan
    Replies:
    32
    Views:
    999
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page