This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Turning off 'well-formedness'


Richard,

The classic solution to your problem would pick up every third <Record> and 
group its next two siblings with it, along the lines of:

<xsl:template match="Record">
   <xsl:if test="(count(preceding-sibling::Record) mod 3) = 1">
   <!-- works on first, fourth, seventh Records, etc. -->
     <td>
       <xsl:apply-templates/>
       <br/>
       <xsl:for-each select="following-sibling::Record(position() &lt; 3)">
          <!-- picks up the next two Records -->
          <xsl:apply-templates/>
          <br/>
       </xsl:for-each>
     </td>
   </xsl:if>
</xsl:template>

You say you want a <br> after every entry; but you can see here it's easy 
enough to put one just before 2nd and 3rd rows, not after each.

Also, you can see how easy it is to parameterize this: just change the 
number '3' into a parameter to make bigger or smaller groups.

Don't try to 'turn off well-formedness' -- the language is built to work 
with it, not without it. Whenever you think it's in the way, it's probably 
because your approach to the problem isn't XSL-ish enough.

Cheers,
Wendell

At 04:20 PM 1/9/02, you wrote:
>Folks,
>
>I am trying to create the following marked-up tags using MSXML3 on an IE5.x
>browser:
>
><td>
>         data1 <br />
>         data2 <br />
>         data3 <br />
></td>
><td>
>         data4 <br />
>         data5 <br />
>         data6 <br />
></td>
>----------------------------------------------------------
>my source file looks like:
>
><Data>
>     <Record>data</Record>
>     <Record>data</Record>
>     <Record>data</Record>
>     <Record>data</Record>
>     <Record>data</Record>
>     <Record>data</Record>
></Data>
>----------------------------------------------------------


======================================================================
Wendell Piez                            mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]