RE: [xsl] positional grouping xslt2

Subject: RE: [xsl] positional grouping xslt2
From: David.Pawson@xxxxxxxxxxx
Date: Wed, 10 Mar 2004 10:43:13 -0000
      <title><xsl:value-of select="self::head1"/></title>
      <title><xsl:copy-of select="self::head1/node()"/></title>
      Why different please David?
    
    As usual, value-of will give you a string but if there is 
    any markup in the title and you want to keep it you want to 
    use copy-of.
    In this case there probably is no markup, but still...

Good point. 
  I'd forgotten inline markup with dd, dt as well.

I'm near finished with a 1.0 example too, (see below)
Its a moded push mode,
which to my eyes actually looks simpler (as a whole) than the xslt 2.0
solution
which has been designed for this class of problem.

I now have my normal list of templates, even if they are all moded,
rather than the (near single) long and complex choose for the xslt 2.0
solution.

Not sure if this tells us anything or not.

regards DaveP.





  <xsl:template match="/">
    <xsl:text disable-output-escaping="yes">
	<![CDATA[

<!DOCTYPE article
  PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd";
[
<!ENTITY RH "Red Hat"> <!--The generic term "Red Hat" -->
<!ENTITY FORMAL-RHI "Red Hat, Inc."> <!--The generic term "Red Hat, Inc. -->
<!ENTITY PROJECT "Fedora project"> <!-- Set the project name -->
<!ENTITY NAME-TITLE "Fedora Project"> <!-- Set the project name, use for
titles -->
<!ENTITY DISTRO "Fedora Core"> <!-- Set the distro name -->
<!ENTITY BOOKID "example-tutorial-0.1 (2003-07-07)"> <!-- change version of
manual and date here -->

<!ENTITY LEGALNOTICE SYSTEM "../common/legalnotice-en.xml">


]>
]]>
</xsl:text>


<article id="example-tutorial" lang="en">
  <articleinfo>
    <title>Example Tutorial</title>
    <copyright>
      <year>2003</year>
      <holder>Red Hat, Inc.</holder>
      <holder>Tammy Fox</holder>
    </copyright>
    <authorgroup>
      <author>
	<surname>Fox</surname>
	<firstname>Tammy</firstname>
      </author>
    </authorgroup>
    &LEGALNOTICE;
  </articleinfo>

  <xsl:apply-templates />
      </article>
  </xsl:template>


  <xsl:template match="article">
    <xsl:apply-templates select="head1" mode="struct"/>
  </xsl:template>


  <xsl:template match="head1" mode="struct">
    <section>
      <title><xsl:apply-templates mode="struct"/></title>
     <xsl:apply-templates select="following-sibling::*[
         count(preceding-sibling::head1[1] | current()) = 1]"
mode="struct"/>

    </section>
  </xsl:template>

  
 <xsl:template match="head2" mode="struct">
  <section>
      <title><xsl:apply-templates mode="struct"/></title>
      <xsl:apply-templates select="following-sibling::*[
                                   count(preceding-sibling::head2[1] |
current()) = 1]" mode="struct"/>


    </section>
 </xsl:template>

 <xsl:template match="head3" mode="struct">
  <section>
      <title><xsl:apply-templates mode="struct"/></title>
     <xsl:apply-templates select="following-sibling::*[
                                  count(preceding-sibling::head3[1] |
current()) = 1]" mode="struct"/>


    </section>
 </xsl:template>



  
  <xsl:template match="i" mode="struct">
    <emphasis role="italics">
      <xsl:apply-templates/>
    </emphasis>
  </xsl:template>

  <xsl:template match="b"  mode="struct">
    <emphasis role="bold">
      <xsl:apply-templates/>
    </emphasis>
  </xsl:template>

  <xsl:template match="bull1|litem"  mode="struct">
    <listitem>
      <para>
      <xsl:apply-templates mode="struct"/>
    </para>
    </listitem>
  </xsl:template>

 
  <xsl:template match="hr" mode="struct"/>

  <xsl:template match="literal"  mode="struct">
    <literal>
      <xsl:apply-templates  mode="struct"/>
    </literal>
  </xsl:template>

  <xsl:preserve-space elements="verbatim"/>

  <xsl:template match="verbatim"  mode="struct">
    <programlisting >
      <xsl:value-of select="*"/>
    </programlisting>
  </xsl:template>



<xsl:template match="p" mode="struct">
  <para><xsl:apply-templates  mode="struct"/></para>
</xsl:template>


<xsl:template match="dl" mode="struct">
  <variablelist>
    <xsl:apply-templates mode="struct"/>
  </variablelist>
</xsl:template>

<xsl:template match="dt" mode="struct">
  <varlistentry>
    <term>
      <xsl:apply-templates mode="struct"/>
  </term>
  <listitem>
    <para>
      <xsl:apply-templates select="following-sibling::dd[1]" mode="dd"/>
    </para>
  </listitem>
</varlistentry>
</xsl:template>
<xsl:template match="dd" mode="struct"/>
<xsl:template match="dd" mode="dd">
  <xsl:apply-templates mode="struct"/>
</xsl:template>

<xsl:template match="link" mode="struct">
  <ulink url="{ref}">
    <xsl:choose>
      <xsl:when test="text">
        <xsl:value-of select="text"/>
      </xsl:when>
      <xsl:otherwise>
         <xsl:value-of select="ref"/>
      </xsl:otherwise>
    </xsl:choose>
</ulink>
</xsl:template>

<xsl:template match="*"/>

- 
DISCLAIMER: 

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged. If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system. 

RNIB endeavours to ensure that emails and any attachments generated by 
its staff are free from viruses or other contaminants. However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments. 

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent 
those of RNIB. 

RNIB Registered Charity Number: 226227 

Website: http://www.rnib.org.uk 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread