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

RE: XSL selection question

Subject: RE: XSL selection question
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Tue, 5 Nov 2002 10:55:21 -0000
fo table height
Hi,

You need to just apply-templates in document order, so in english you
might say

for each <inst-part>
  output <part-number>
  output <description>
  output <inst-notes>

at the moment you are saying

for each <inst-note>
  output <part-number>
  output <description>
  output content...

so naturally enough you will get the <part-number> and <description>
output every time you encounter an <inst-note>.

Rearrange your templates a little and then apply them in document order
(if your dtd allows)

(untested)

<xsl:template match="inst-part">
  <!-- format the part number and description -->
  <!-- It is not that easy with FO -->
  <xsl:apply-templates/>
</xsl:template> 

<xsl:template match="part-number">
  <fo:table-row line-height="10pt">
    <fo:table-cell padding="4pt">
      <fo:block text-align="start">
        <xsl:value-of select="."/>
      </fo:block>
    </fo:table-cell>
  <fo:table-cell padding="4pt" height="1cm">
</xsl:template>

<xsl:template match="description">
  <fo:table-cell padding="4pt" height="1cm">
    <fo:block text-align="start">
      <xsl:value-of select="."/>
    </fo:block>
  </fo:table-cell>
</xsl:template>


<xsl:template match="inst-note">
      <!-- format the output of the "view" value along -->
      <!-- with the note contents. This will not start -->
      <!-- at the beginning of the line.               -->

      <!--....part-number and description handling code separated out-->


      <fo:table-cell padding="4pt" height="1cm">
        <fo:block text-align="center">
         <xsl:value-of select="view"/>
      .....

cheers
andrew

> -----Original Message-----
> From: jeremyf@xxxxxxxxxxx [mailto:jeremyf@xxxxxxxxxxx]
> Sent: 04 November 2002 18:05
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSL selection question
> 
> 
> Hi All,
>       I have an XML file such that:
> 
> <report>
> -snip-
>   <module-installation-requirements sectionID="4">
>     <inst-part>
>       <part-number>G4P5616EGPPAE500</part-number>
>       <description>DESCRIPTION FOR INSTALLATION 
> REQUIREMENTS</description>
>       <inst-notes>
>         <inst-note>
>           <view>ENG</view>
>           <note>
>             <note-title>FREE FORM NOTE</note-title>
>             <note-description>TEXT FOR FREE FORM 
> NOTE</note-description>
>           </note>
>         </inst-note>
>         <inst-note>
>           <view>ENG</view>
>           <note>
>             <note-title>FREE FORM NOTE 2</note-title>
>             <note-description>TEXT FOR FREE FORM NOTE 
> 2</note-description>
>           </note>
>         </inst-note>
>       </inst-notes>
>     </inst-part>
>   </module-installation-requirements>
> -snip-
> </report>
> 
> I want the following output
> 
> 
> 
> G4P5616EGPPAE500  DESCRIPTION FORINSTALLATIONREQUIREMENTS         ENG
> FREE FORM NOTE    TEXT FOR FREE FORM NOTE
> 
>                                                             ENG
> FREE FORM NOTE 2  TEXT FOR FREE FORM NOTE 2
> 
> Each of these is a row in my output. How do I select the number and
> description the first time but not every time after until I 
> reach a new
> number?
> I have a template that gives me the nodes, but I also need to handle
> different views for the same part/description and potentially multiple
> <note> items per view.
> My templates look something like this:
> 
> -snip-
> 
>     <xsl:template match="module-installation-requirements">
>       <!-- start of format specific setup -->
>                   <fo:table height="1cm" table-layout="fixed">
>                         <fo:table-column column-width="25cm"/>
>                         <fo:table-body font-family="Times-Roman"
> font-weight="bold" font-size="8pt">
>                               <fo:table-row line-height="8pt">
>                                     <fo:table-cell padding="8pt">
>                                           <fo:block text-align="start"
> height=".5cm">* * * * * * * * * * * * * * * * * * * * * * * * 
> * * * * * * *
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
> * * * * * * *
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
> * * * * * * *
> * * * * * * * * </fo:block>
>                                     </fo:table-cell>
>                               </fo:table-row>
>                               <fo:table-row line-height="8pt">
>                                     <fo:table-cell padding="8pt">
>                                           <fo:block 
> text-align="center"
> height=".5cm" font-weight="normal">.  .  .  MODULE INSTALLATION
> REQUIREMENTS  .  .  .</fo:block>
>                                     </fo:table-cell>
>                               </fo:table-row>
>                         </fo:table-body>
>                   </fo:table>
>                   <fo:table height="1cm" table-layout="fixed">
>                         <fo:table-column column-width="6cm"/>
>                         <fo:table-column column-width="4cm"/>
>                         <fo:table-column column-width="2cm"/>
>                         <fo:table-column column-width="4cm"/>
>                         <fo:table-column column-width="8cm"/>
>                         <fo:table-header font-family="Times-Roman"
> font-weight="bold" font-size="8pt">
>                               <fo:table-row line-height="10pt">
>                                     <fo:table-cell padding="4pt">
>                                           <fo:block 
> text-align="start">PART
> OR IDENTIFYING NUMBER</fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="start">DESCRIPTION</fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="center">VIEW</fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="center">NOTE TITLE</fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block 
> text-align="start">NOTE
> DESCRIPTION</fo:block>
>                                     </fo:table-cell>
>                               </fo:table-row>
>                         </fo:table-header>
>                         <fo:table-body font-family="Times-Roman"
> font-weight="bold" font-size="8pt">
>       <!-- end setup -->
>       <!-- call the template to format this section and pass 
> the title -->
>       <xsl:choose>
>       <xsl:when test="*">
>             <xsl:apply-templates/>
>       </xsl:when>
>       <xsl:otherwise>
>             <fo:table height=".8cm" table-layout="fixed">
>                   <fo:table-column column-width="25cm"/>
>                   <fo:table-body font-family="Times-Roman" font-weight
> ="bold" font-size="8pt">
>                         <fo:table-row line-height="10pt">
>                               <fo:table-cell padding-top="8pt">
>                                     <fo:block 
> text-align="center" height
> =".8cm">NO APPLICABLE DATA EXISTS</fo:block>
>                               </fo:table-cell>
>                         </fo:table-row>
>                   </fo:table-body>
>             </fo:table>
>      </xsl:otherwise>
>     </xsl:choose>
>       <!-- start of clean up -->
>                         </fo:table-body>
>                   </fo:table>
>       <!-- end clean up -->
>     </xsl:template>
> 
>     <xsl:template match="inst-part">
>       <!-- format the part number and description -->
>       <!-- It is not that easy with FO -->
>         <xsl:apply-templates select="inst-notes"/>
>     </xsl:template>
> 
>     <xsl:template match="inst-note">
>       <!-- format the output of the "view" value along -->
>       <!-- with the note contents. This will not start -->
>       <!-- at the beginning of the line.               -->
>                               <fo:table-row line-height="10pt">
>                                     <fo:table-cell padding="4pt">
>                                           <fo:block text-align
> ="start"><xsl:value-of select="../../part-number"/></fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="start"><xsl:value-of select="../../description"/></fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="center"><xsl:value-of select="view"/></fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="center"><xsl:value-of select="note/note-title"/></fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="start"><xsl:value-of select="note/note-description"/></fo:block>
>                                     </fo:table-cell>
>                               </fo:table-row>
>                         <xsl:for-each select="inst-note/note">
>                               <fo:table-row line-height="10pt">
>                                     <fo:table-cell padding="4pt">
>                                           <fo:block 
> text-align="start"/>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block 
> text-align="start"/>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="center"><xsl:value-of select="view"/></fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="center"><xsl:value-of select="note-title"/></fo:block>
>                                     </fo:table-cell>
>                                     <fo:table-cell 
> padding="4pt" height
> ="1cm">
>                                           <fo:block text-align
> ="start"><xsl:value-of select="note-description"/></fo:block>
>                                     </fo:table-cell>
>                               </fo:table-row>
>                         </xsl:for-each>
>     </xsl:template>
> 
> I am certain that I  am making this harder than it sould be, 
> but I am still
> having trouble.
> Any help is appreciated.
> 
> Jeremy
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> 

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


Current Thread
  • XSL selection question
    • jeremyf - Mon, 4 Nov 2002 12:57:18 -0500 (EST)
      • <Possible follow-ups>
      • Andrew Welch - Tue, 5 Nov 2002 05:51:25 -0500 (EST) <=
      • jeremyf - Wed, 6 Nov 2002 09:07:42 -0500 (EST)

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.