[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Keeping an eye on processed nodes

Subject: Keeping an eye on processed nodes
From: Gustaf Liljegren <gustaf.liljegren@xxxxxx>
Date: Wed, 15 Jan 2003 18:40:41 +0100
how the eye is processed
I'm doing something really wrong here. I'm trying to process an index for a
book, and find myself in a situation where I need to keep an eye on which
nodes I have already processed. Since this is not possible in XSLT, I need
your help to find an alterntive solution. Part of the XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<index>
  ...
  <entry page="34">A4 page size</entry>
  <entry page="37">absolute direction</entry>
  <entry page="172" context="absolute-position property">correcting
    content position with</entry>
  <entry page="91" context="absolute-position property">offsetting
    content with</entry>
  <entry page="139">alignment points</entry>
  ...
</index>

This should be rendered as:

A4 page size, 34
absolute direction, 37
absolute-position property
  correcting content position with, 172
  offsetting content with, 91
alignment points, 139

The entry template in the XSL file:

  <!-- TM: Index entries -->
  <xsl:template match="entry">
    <xsl:variable name="context" select="@context"/>
    <xsl:choose>
      <!-- If the entry has a certain context... -->
      <xsl:when test="@context">
        <!-- ...print the context, then... -->
        <fo:block xsl:use-attribute-sets="entries">
          <xsl:value-of select="@context"/>
        </fo:block>
        <!-- ...print each entry within this context -->
        <xsl:for-each select="//entry[@context = $context]">
          <fo:block xsl:use-attribute-sets="entries">
            <xsl:attribute name="margin-left">1em</xsl:attribute>
            <xsl:call-template name="print-entry"/>
          </fo:block>
        </xsl:for-each>
      </xsl:when>
      <!-- If the entry has no context -->
      <xsl:otherwise>
        <fo:block xsl:use-attribute-sets="entries">
          <xsl:call-template name="print-entry"/>
        </fo:block>
        <!-- Look for other entries with this context -->
        <xsl:for-each select="//entry[@context = text()]">
          <fo:block xsl:use-attribute-sets="entries">
            <xsl:attribute name="margin-left">1em</xsl:attribute>
            <xsl:call-template name="print-entry"/>
          </fo:block>
        </xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

The problem occurs when several words are grouped. For each entry within
the same @context, a new group is made, like this:

absolute-position property
  correcting content position with, 172
  offsetting content with, 91
absolute-position property
  correcting content position with, 172
  offsetting content with, 91

Another related problem occurs on entries without @context, but other
entries with matching @context attributes, like this:

<entry page="129-132">background-color property</entry>
<entry page="94" context="background-color property">images and</entry>

This should be rendered as:

background-color property, 129-132
  images and, 94

For each new entry, I check if there are any entries with a matching
@context and list them below. But the result is:

background-color property, 129?132
background-color property
  images and, 94

Gustaf



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.