xsl-list
[Top] [All Lists]

[xsl] Muenchian Grouping: Not coyping all elements

2006-08-30 10:13:25
I'm using Apache Software Foundation's http://xml.apache.org/xalan-j
 
I have a standard docbook book/chapter/refentry structure. I'm trying to
group the refentry elements into sections using the role attribute on each
refentry as the section/title--so the new structure would be
book/chapter/section/refentry. I have 2 chapters and the refentry id
attribute values begin with either "comp" for the "Components Reference"
chapter or "actn" for the "Actions Reference chapter--so I use "comp" and
"actn" to determine which chapter to put the refentry elements into.
 
The problem is that only 49 new sections are created, whereas there should
be 73. Also, the input file has be 2168, but the output file only has 1680
refentry elements. If I switch the positions of the chapters in the input
file, then the second one is still truncated.
 
Thanks--Alex
 
Here's my stylesheet:
 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">  <xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" doctype-public="-//Arbortext//DTD DocBook XML V4.0//EN"
doctype-system="axdocbook.dtd"/>  <xsl:key name="task-sections"
match="refentry" use="@role"/>  <xsl:template match="/">
  <xsl:element name="book">
   <xsl:apply-templates select="book/chapter"/>
  </xsl:element>
 </xsl:template>
 <xsl:template match="chapter">
   <xsl:variable name="id-first-string">
    <xsl:choose>
     <xsl:when test="title='Actions Reference'">
      <xsl:text>actn</xsl:text>
     </xsl:when>
     <xsl:when test="title='Components Reference'">
      <xsl:text>comp</xsl:text>
     </xsl:when>
    </xsl:choose>
   </xsl:variable>
  <xsl:element name="chapter">
   <xsl:copy-of select="title"/>
   <xsl:copy-of select="partintro"/>
   <xsl:for-each
select="refentry[generate-id()=generate-id(key('task-sections', @role)[1])
and starts-with(@id,$id-first-string)]">
    <xsl:element name="section">
     <xsl:element name="title">
      <xsl:choose>
       <xsl:when test="@role != 0">
        <xsl:value-of select="@role"/>
       </xsl:when>
       <xsl:when test="@role = 0">
        <xsl:text>Need to be categorized</xsl:text>
       </xsl:when>
      </xsl:choose>
     </xsl:element>
     <xsl:for-each
select="key('task-sections',@role)[starts-with(@id,$id-first-string)]">
      <xsl:copy-of select="."/>
     </xsl:for-each>
    </xsl:element>
   </xsl:for-each>
  </xsl:element>
 </xsl:template>
</xsl:stylesheet>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] Muenchian Grouping: Not coyping all elements, Sato_Alex <=