Loading ...
Sorry, an error occurred while loading the content.

Creating an alpha index with sub heads

Expand Messages
  • Carolyn
    I m trying to create an alpha index from a number of xml files which is no problem but I need to get a sub heading in between each break of alpha characters. A
    Message 1 of 2 , Aug 31, 2006
    • 0 Attachment
      I'm trying to create an alpha index from a number of xml files which
      is no problem but I need to get a sub heading in between each break of
      alpha characters.

      A
      Another part
      Anything here

      B
      Begin another part
      Being here

      etc.

      My xml that is being processed is a 'hub' file of sorts that
      references the files themselves as entities.

      Example:

      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE firsttag [

      <!ENTITY graphic1 SYSTEM "graphic1.tif" NDATA tif>
      <!ENTITY graphic2 SYSTEM "graphic2.tif" NDATA tif>

      <!ENTITY xmlfile1 SYSTEM "xmlfile1.xml">
      <!ENTITY xmlfile2 SYSTEM "xmlfile2.xml">
      <!ENTITY xmlfile3 SYSTEM "xmlfile3.xml">
      <!ENTITY xmlfile4 SYSTEM "xmlfile4.xml">
      ]>
      <pm>
      <chapter>
      <subsystem>
      &xmlfile1;
      &xmlfile2;
      </subsystem>
      </chapter>
      <chapter>
      <subsystem>
      &xmlfile3;
      </subsystem>
      <subsystem>
      &xmlfile4;
      </subsystem>
      </chapter>
      </pm>

      The individual xml files are pretty basic:

      xmlfile1:

      <firsttag id="first1">
      <secondtag id="second1">
      <thirdtag id="third1">
      ...
      </thirdtag>
      </secondtag>
      <contenttag id="contenttag1">
      <step1>
      ...
      </step1>
      <partlisttag id="partlisttag1">
      <figure id="fig1">
      <title>Fig title</title>
      <graphic boardno="graphic1" id="graphic1"/>
      </figure>
      <parttag ind="0" item="0">
      <subparttag id="subparttag1>
      <qna>1</qna>
      <mfc>45165</mfc>
      <pnr hardware="0">123456</pnr>
      <pas>
      <dfp>Beging here</dfp>
      <pcs uom="EA"></pcs>
      </pas>
      ...
      </subparttag>
      <subparttag id="subparttag1>
      <qna>1</qna>
      <mfc>45165</mfc>
      <pnr hardware="0">476594</pnr>
      <pas>
      <dfp>Another part</dfp>
      <pcs uom="EA"></pcs>
      </pas>
      ...
      </subparttag>
      </parttag>
      <parttag>
      <subparttag id="subparttag1>
      <qna>1</qna>
      <mfc>45165</mfc>
      <pnr hardware="0">4765954</pnr>
      <pas>
      <dfp>Begin another part</dfp>
      <pcs uom="EA"></pcs>
      </pas>
      ...
      </subparttag>
      </parttag>
      ...
      <partlisttag>
      </contenttag>
      </firsttag>

      xmlfile2:

      <firsttag id="first1">
      <secondtag id="second1">
      <thirdtag id="third1">
      ...
      </thirdtag>
      </secondtag>
      <contenttag id="contenttag1">
      <step1>
      ...
      </step1>
      <partlisttag id="partlisttag1">
      <figure id="fig1">
      <title>Fig title</title>
      <graphic boardno="graphic1" id="graphic1"/>
      </figure>
      <parttag ind="0" item="0">
      <subparttag id="subparttag1>
      <qna>1</qna>
      <mfc>45165</mfc>
      <pnr hardware="0">84956</pnr>
      <pas>
      <dfp>Anything here</dfp>
      <pcs uom="EA"></pcs>
      </pas>
      ...
      </subparttag>
      </parttag>
      ...
      <partlisttag>
      </contenttag>
      </firsttag>

      I can get the alpha index with:
      <xsl:for-each
      select="descendant-or-self::firsttag//partlisttag//pnr[@hardware!='1']/following-sibling::pas/dfp">
      <xsl:sort select="."/>
      <fo:table-row>
      <fo:table-cell hyphenate="false" column-number="1">
      <fo:block>
      <xsl:value-of select="."/>
      </fo:block>
      </fo:table-cell>
      <fo:table-cell column-number="2" display-align="after">
      <fo:block>
      <fo:page-number-citation ref-id="{generate-id()}"/>
      </fo:block>
      </fo:table-cell>
      <fo:table-cell column-number="3" display-align="after">
      <fo:block text-align="left">
      <xsl:value-of select="ancestor::parttag/@item"/>
      </fo:block>
      </fo:table-cell>
      </fo:table-row>
      </xsl:for-each>

      How do I test the previous sorted description and not the previous
      descritpion element?

      I've tried, <xsl:if test=".=preceding::pas/dfp or
      preceding::firsttag//partlisttag//pas/dfp"> and various other tests
      but they're all looking at the document structure and not the previous
      sorted element.

      I'm using AntennaHouse XML Formatter 3.3. Sorry this is so long but I
      wanted to give as much info as I could. :)

      Carolyn
    • Jirka Kosek
      ... Basicly, you need to group your terms by their first letter, and then process all terms beginning with this letter. Search for XSLT grouping and you will
      Message 2 of 2 , Aug 31, 2006
      • 0 Attachment
        Carolyn wrote:
        > I'm trying to create an alpha index from a number of xml files which
        > is no problem but I need to get a sub heading in between each break of
        > alpha characters.
        >
        > A
        > Another part
        > Anything here
        >
        > B
        > Begin another part
        > Being here
        >
        > etc.

        Basicly, you need to group your terms by their first letter, and then
        process all terms beginning with this letter. Search for "XSLT grouping"
        and you will get plenty of examples how to implement grouping in XSLT.

        Jirka

        --
        ------------------------------------------------------------------
        Jirka Kosek e-mail: jirka@... http://www.kosek.cz
        ------------------------------------------------------------------
        Profesion�ln� �kolen� a poradenstv� v oblasti technologi� XML.
        Pod�vejte se na n�� nov� spu�t�n� web http://DocBook.cz
        Podrobn� p�ehled �kolen� http://xmlguru.cz/skoleni/
        ------------------------------------------------------------------
        Nejbli��� term�ny �kolen�:
        ** XSLT 23.-26.10.2006 ** XML sch�mata 13.-15.11.2006 **
        ** DocBook 11.-13.12.2006 ** XSL-FO 11.-12.12.2006 **
        ------------------------------------------------------------------
        http://xmlguru.cz Blog mostly about XML for English readers
        ------------------------------------------------------------------



        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.