[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] How to get a multiple TOC HTMLs from Map2HTMTOC.xsl


Subject: Re: [xsl] How to get a multiple TOC HTMLs from Map2HTMTOC.xsl
From: Matthieu Ricaud-Dussarget <matthieu.ricaud@xxxxxxxxx>
Date: Tue, 17 Jul 2012 17:12:57 +0200

Hi Ray,

I'm not sure I can clearly understand what you want to do from your big sample.
The relevant part is just :
<xsl:template name="generate-toc">
<html>
do somethings ...
</html>
</xsl:template>
isn't it ?


Anyway form what I understand you want to output multiple files : with XSLT2 you can use many <xsl:result-document> with differents @href.

How many <xsl:result-document> you use and how to make then be applied can depend on xml input (is the information there?), hard code in the XSLT, given as param to the transformation, etc.
Using mode for each <xsl:result-document> is a good idea. Think that you can also use mode="#all" or mode="mode1 mode2" if there are templates that should be the same.


By the way, instead of formating the output with <xsl:value-of select="$newline"/>, I suggest you use <xsl:output> with good attributes (@indent="yes|no", @method="xml|text|xhtml").

Hope this helps,
Regards,

Matthieu.


Le 17/07/2012 16:40, team wise a C)crit :
Dear list readers,

I have a style sheet called map2htmtoc.XSL stylesheet written in XSLT
1.0, if I need to apply lines of code snippet as follows to generate a
couple of different 'TOC's as HTML,
how to achieve that?

<xsl:template name="generate-toc">
   <html><xsl:value-of select="$newline"/>
   <head><xsl:value-of select="$newline"/>
     <xsl:if test="string-length($contenttarget)>0 and
	        $contenttarget!='NONE'">
       <base target="{$contenttarget}"/>
       <xsl:value-of select="$newline"/>
     </xsl:if>
     <!-- initial meta information -->
     <xsl:call-template name="generateCharset"/>   <!-- Set the
character set to UTF-8 -->
     <xsl:call-template name="generateDefaultCopyright"/> <!-- Generate
a default copyright, if needed -->
     <xsl:call-template name="generateDefaultMeta"/> <!-- Standard meta
for security, robots, etc -->
     <xsl:call-template name="copyright"/>         <!-- Generate
copyright, if specified manually -->
     <xsl:call-template name="generateCssLinks"/>  <!-- Generate links
to CSS files -->
     <xsl:call-template name="generateMapTitle"/> <!-- Generate the
<title> element -->
     <xsl:call-template name="gen-user-head" />    <!-- include user's
XSL HEAD processing here -->
     <xsl:call-template name="gen-user-scripts" /> <!-- include user's
XSL javascripts here -->
     <xsl:call-template name="gen-user-styles" />  <!-- include user's
XSL style element and content here -->
   </head><xsl:value-of select="$newline"/>

<body>


<div class="container top">


<div class="header">

<h1>

<span class="logo">

<xsl:element name="img">

<xsl:attribute name="src">../images/logo.png</xsl:attribute>

<xsl:attribute name="alt">SOY</xsl:attribute>

</xsl:element>

</span>

<a href="index.html" class="title">Help</a></h1>

<div class="nav">

<xsl:apply-templates select="." mode="generate-dynamic-toc"/>

</div><!--/.nav-->

</div><!--/.header-->

<div class="section">

<h1>

<span class="category-name">App</span>

<span class="model-name">"" Application</span>

</h1>

<h2></h2>

<div class="main-visual">

<div class="banner">

<xsl:element name="img">

<xsl:attribute name="src">../images/p_cover.png</xsl:attribute>

<xsl:attribute name="alt"></xsl:attribute>

</xsl:element>

</div>

</div><!--/.main-visual-->

<div class="information pattern2">

<p>This manual used as you have some trouble or you do not know how to
use the "" Application.<br />

<a href="contents/t0900_trademark.html">Trademarks</a>

</p>

</div><!--/.information.pattern2-->

<div class="return-pagetop">

<a href="#top">

<xsl:element name="img">

             <xsl:attribute
name="src">../images/arrow_return_pagetop.png</xsl:attribute>

<xsl:attribute name="alt"></xsl:attribute>

</xsl:element>Go to Page Top

</a>

</div>

</div><!--/.section-->

<div class="footer">

<div class="copyright">2012</div>

</div>

</div>

<!--/.container-->
<xsl:if test="string-length($OUTPUTCLASS) &gt; 0">
        <xsl:attribute name="class">
          <xsl:value-of select="$OUTPUTCLASS"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:value-of select="$newline"/>
     <xsl:apply-templates/>
    </body><xsl:value-of select="$newline"/>
   </html>
</xsl:template>

At this point of time, I could implement a variety of  apply-templates
in different modes, subject to conditions, for example,

<xsl:apply-templates select="." mode="generate-dynamic-toc"/>

<xsl:apply-templates select="." mode="generate-dynamic-toc2"/>

<xsl:apply-templates select="." mode="generate-dynamic-toc3"/>

<xsl:apply-templates select="." mode="generate-dynamic-toc4 "/> ,etc,
the current template applys a XSL document instruction to get just one
TOC HTML file.

<xsl:document href="{$OUTPUTDIR}\{$transformedLngValue}\toc.html">

if I need to get mutiple TOC*.html, what is the right syntax? Does
removing the document instruction make a diferenece?

I greatly appreciate if anyone out there can share your thoughts.
Cheers,

Ray


--
Matthieu Ricaud
05 45 37 08 90
IGS-CP, service livres numC)riques


Current Thread
Keywords