Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2008, 08:42 AM
Registered User
 
Join Date: Apr 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Frimann
Default Foot notes to end notes

I want to write out foot notes in the input document as end notes in a separate list at the bottom of the output document. The notes are marked up with asterixes (*, **, *** etc.) which I have replaced with sequential numbers allocated by <xsl:number>. This works fine, but I don't know how to lift out the notes of their original context and place them in a list.

Input is somewhat like this:

<page_content id="001">
  <p>Text, text, <foot_note target="001">text</foot_note>, text.</p>
  <p>Text, text, text, text.</p>
  <foot_note id="001">Text, text, text, text.</foot_note>
</page_content>

<page_content id="002">
  <p>Text, text, <foot_note target="002">text</foot_note>, text.</p>
  <p>Text, text, <foot_note target="003">text</foot_note>, text.</p>
  <foot_note id="002">Text, text, text, text.</foot_note>
  <foot_note id="003">Text, text, text, text.</foot_note>
</page_content>

... etc...

Output is supposed to look like this:

<page_content id="001">
  <p>Text, text, <end_note target="001">text</end_note>, text.</p>
  <p>Text, text, text, text.</p>
</page_content>

<page_content id="002">
  <p>Text, text, <end_note target="002">text</end_note>, text.</p>
  <p>Text, text, <end_note target="003">text</end_note>, text.</p>
</page_content>

...etc ...

<end_note_list>
  <end_note id="001">Text, text, text, text.</end_note>
  <end_note id="002">Text, text, text, text.</end_note>
  <end_note id="003">Text, text, text, text.</end_note>

... etc ...

</end_note_list>
 
Old April 26th, 2008, 09:38 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

It should not be that difficult, assuming you have a root element containing the page_content elements you simply set up a template for that that creates the end_node_list:
Code:
<xsl:template match="/*>
  <xsl:copy>
    <xsl:apply-templates select="page_content"/>
    <end_note_list>
      <xsl:apply-templates select="page_content/foot_note"/>
    </end_note_list>
  </xsl:copy>
</xsl:template>

<xsl:template match="foot_note">
  <end_note>
    <xsl:apply-templates select="@* | node()"/>
  </end_note>
</xsl:template>

<xsl:template match="page_content">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()[not(self::foot_node)]"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="foot_note_target">
  <end_note_target>
    <xsl:apply-templates select="@* | node()"/>
  </end_note_target>
</xsl:template>
<xsl:template match="@* | text()">
  <xsl:copy/>
</xsl:template>
--
  Martin Honnen
  Microsoft MVP - XML





Similar Threads
Thread Thread Starter Forum Replies Last Post
Email Via Lotus Notes poyserr Access 1 June 30th, 2009 04:05 PM
Issue with Lotus Notes Warbird VB How-To 1 November 13th, 2007 01:06 PM
Lotus Notes GuyB ASP.NET 1.0 and 1.1 Basics 0 December 27th, 2005 07:01 PM
Help me Please.... Lecture Notes needed ttub C# 0 September 18th, 2005 04:40 PM
Java notes jlnashrod JSP Basics 1 February 23rd, 2005 07:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.