Link to home
Start Free TrialLog in
Avatar of DaFou
DaFou

asked on

insert xml into a node of parent xslt

Hi all,

Please consider the following two xsl stylesheets:

parent.xslt

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" omit-xml-declaration="yes" standalone="yes" indent="yes" />
      <xsl:template match="/">
            <html>
                  <head>
                        <title>Some page</title>
                        <!-- How do I insert content here from child.xslt? -->                        
                  </head>
                  <body>
                        <xsl:call-template name="HtmlBodyContent" />
                  </body>
            </html>
    </xsl:template>
</xsl:stylesheet>

and child.xslt

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" omit-xml-declaration="yes" standalone="yes" indent="yes" />
      <xsl:include href="parent.xslt" />

      <!--
      But how can I insert content in the html head in the parent.xslt from here?
      or from somewhere else in this child.xslt
      -->

      <xsl:template name="HtmlBodyContent">
            Body content goes here
      </xsl:template>
</xsl:stylesheet>

When reasoning top down ( from parent to child ) there is no problem. A child.xslt must implement a template named HtmlBodyContent and all is well. Also going deeper than one level is no problem.

However when reversing the direction ( from child to parent ) I don't see how I can insert content into a node that is contained in a parent or ansestor stylesheet.

Please check my stylesheets and look for the comments in it, it should help explain what I need to do.

Working from child to ansestor is important because some files have multiple levels and each level needs to be able to add to the html head ( to add script blocks )

Any ideas,

Kind regards
SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DaFou
DaFou

ASKER

thanks zc2 for your suggestion.

Could you please elaborate on this idea a bit more with an example of 3 levels?

parent.xslt, child.xslt and grandchild.xslt.

both child.xslt and grandchild.xslt should be able to add content to the html head.

kind regards
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial