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

Re: 2 columns with special conditions

Subject: Re: 2 columns with special conditions
From: Sven Waibel <sven.waibel@xxxxxxxx>
Date: Fri, 04 May 2007 16:29:28 +0200
Re:  2 columns with special conditions
Hi all,

i got another problem. I want to have a numbering in each row:

What i want:

Index   TypeF  TypeC
1		 -		1
2 		2		3
3		4		5

But i don't know if it has 1,2 or 3... rows.

Possibilities:

F=type F
C = type C

1) number of F more than C
F	C
F	-
F	C

2) number of F equals C
-	C
-	C
F	-
F	-

3) number of C more than F
-	C
-	C
-	C
-	C

I'm using template below (extended with a cell for my numbering):

I hope that my explanation is not so confusing.

Thanks again
Sven

Bjorndahl, Brad schrieb:
> Hi,
> 
> I take a direct (non-clever) approach. This works. . .
> 
> <?xml version='1.0'?>
> <xsl:transform version="2.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
> 
>  <xsl:output method="xml" indent="yes"/>
>  <xsl:template match="/allsteps">
>   <tables>
>    <xsl:apply-templates />
>   </tables>
>  </xsl:template>
> 
>  <xsl:template match="steps">
>   <table>
>    <xsl:for-each select="mc" >
>     <xsl:choose>
>      <xsl:when test="@type = 'F'" >
>       <row>
>        <col><xsl:value-of select="@name" /></col>
>        <xsl:choose>
>         <xsl:when test="following-sibling::mc" > <!-- Not at end -->
>          <xsl:choose>
>           <xsl:when test="following-sibling::mc[1]/@type eq 'C'" >
>            <col><xsl:value-of select="following-sibling::mc[1]/@name"
> /></col>
>           </xsl:when>
>           <xsl:otherwise>
>            <col />
>           </xsl:otherwise>
>          </xsl:choose>
>         </xsl:when>
>         <xsl:otherwise> <!-- At end -->
>          <col/>
>         </xsl:otherwise>
>        </xsl:choose>
>       </row>
>      </xsl:when>
> 					
>      <xsl:when test="@type = 'C'" >
>       <xsl:choose>
>        <xsl:when test="preceding-sibling::mc" > <!-- Not at beginning
> -->
>         <xsl:choose>
>          <xsl:when test="preceding-sibling::mc[1]/@type eq 'C'" >
>           <row>
>            <col />
>            <col><xsl:value-of select="@name" /></col>
>           </row>
>          </xsl:when>
>         </xsl:choose>
>        </xsl:when>
>        <xsl:otherwise><!-- At beginning -->
>         <row>
>          <col/>
>          <col><xsl:value-of select="@name" /></col>
>         </row>
>        </xsl:otherwise>
>       </xsl:choose>
>      </xsl:when>
>     </xsl:choose>
>    </xsl:for-each>
>   </table>
>  </xsl:template>
> </xsl:transform> 
> 
> . . . on this data:
> <allsteps>
>   <steps>
>     <mc name="1" type="F"/>
>     <mc name="2" type="C"/>
>     <mc name="3" type="F"/>
>     <mc name="4" type="C"/>
>     <mc name="5" type="F"/>
>     <mc name="6" type="C"/>
>   </steps>
>   <steps>
>     <mc name="1" type="C"/>
>     <mc name="2" type="C"/>
>     <mc name="3" type="F"/>
>     <mc name="4" type="C"/>
>     <mc name="5" type="F"/>
>     <mc name="6" type="C"/>
>   </steps>
>   <steps>
>     <mc name="1" type="F"/>
>     <mc name="2" type="C"/>
>     <mc name="3" type="F"/>
>     <mc name="4" type="F"/>
>     <mc name="5" type="F"/>
>     <mc name="6" type="C"/>
>   </steps>
>   <steps>
>     <mc name="1" type="F"/>
>     <mc name="2" type="C"/>
>     <mc name="3" type="F"/>
>     <mc name="4" type="F"/>
>     <mc name="5" type="F"/>
>     <mc name="6" type="F"/>
>   </steps>
>   <steps>
>     <mc name="1" type="C"/>
>     <mc name="2" type="C"/>
>     <mc name="3" type="C"/>
>     <mc name="4" type="C"/>
>     <mc name="5" type="C"/>
>     <mc name="6" type="C"/>
>   </steps>
> </allsteps>
> 
> Brad Bjorndahl
> Technical Publications
> Thermo Fisher Scientific
> 
> 
> -----Original Message-----
> From: Sven Waibel [mailto:sven.waibel@xxxxxxxx] 
> Sent: May 3, 2007 10:06 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  2 columns with special conditions
> 
> Hi,
> 
> i have a "little" problem.
> I try to get a two column layout where all elements with type F live in
> column one and elements with type C in column two. Special thing is that
> you have watch the order. How can i achieve case 2 and 3?
> 
> Thanks in advance
> Sven
> 
> xml:
> case1:
> 
> <mc name="1" type="F"/>
> <mc name="2" type="C"/>
> <mc name="3" type="F"/>
> <mc name="4" type="C"/>
> <mc name="5" type="F"/>
> <mc name="6" type="C"/>
> 
> =>
> (first column always type F, second type C)
> 
> 1	2
> 3	4
> 5	6
> 
> there is no problem, template works.
> 
> 
> case2:
> 
> <mc name="1" type="C"/>
> <mc name="2" type="C"/>
> <mc name="3" type="F"/>
> <mc name="4" type="C"/>
> <mc name="5" type="F"/>
> <mc name="6" type="C"/>
> 
> =>
> 
> -	1
> -	2
> 3	4
> 5	6
> 
> 
> case3:
> 
> <mc name="1" type="F"/>
> <mc name="2" type="C"/>
> <mc name="3" type="F"/>
> <mc name="4" type="F"/>
> <mc name="5" type="F"/>
> <mc name="6" type="C"/>
> 
> =>
> 
> 1	2
> 3	-
> 4	-
> 5	6
> 
> my xsl:
> ....
> <xsl:template match="step">
> 	<xsl:for-each select="descendant::mc[position() mod 2 = 1]">
> 		<tr>
> 			<td>
> 				<xsl:value-of
> select="self::node()[@type='F']/@name"/>
> 			</td>
> 			<td>
> 				<xsl:value-of
> select="following-sibling::node()[position()+1 and @type='C']/@name"/>
> 			</td>
> 		</tr>
> 	</xsl:for-each>
> </xsl:template>
> ...
> 
> --
> ===============================================================
> 
> 
> 

-- 
===============================================================
imbus AG, Kleinseebacher Str. 9, 91096 Mvhrendorf, DEUTSCHLAND
Tel. +49 9131 7518-0, Fax +49 9131 7518-50
info@xxxxxxxx http://www.imbus.de

imbus AG, Unter der Linde 16, 80939 M|nchen, DEUTSCHLAND
Tel. +49 89 3219909-0, Fax +49 89 3219909-50
info@xxxxxxxx http://www.imbus.de

Vorsitzender des Aufsichtsrates: Hendrik Rdssler
Vorstand: Tilo Linz, Bernd Nossem, Thomas Ro_ner, Jvrg Schulten
Sitz der Gesellschaft: Mvhrendorf, M|nchen
Registergericht: F|rth/Bay, HRB 8365
---------------------------------------------------------------
imbus Rhein-Main GmbH, Zanggasse 6, 65719 Hofheim, DEUTSCHLAND
Tel. +49 6192 92192-0, Fax +49 6192 92192-50
info@xxxxxxxx http://www.imbus.de

Geschdftsf|hrer: Frank Schmei_ner, Jvrg Schulten
Sitz der Gesellschaft: Hofheim
Registergericht: Frankfurt am Main, HRB 52155 
===============================================================

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.