Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-28-2002, 06:00 PM   PM User | #1
jeorg
Regular Coder

 
Join Date: Jul 2002
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
jeorg is an unknown quantity at this point
Xml / Xsl

with this xml file

<conditions>
<titlePara>title 1</titlePara>
<para>para 10</para>
<titlePara>title 2</titlePara>
<para>para 20</para>
<para>para 21</para>
</conditions>

and this xsl file

<xsl:template match="/">
<xsl:for-each select="/conditions/titlePara">
<div class='title1'>
<xsl:value-of select="."/>
</div>
<xsl:for-each select="/conditions/para">
<div class='ParaNormal'>
<xsl:value-of select="."/>
</div>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I get

title 1
para 10
para 20
para 21
title 2
para 10
para 20
para 21

how can I get

title 1
para 10
title 2
para 20
para 21

THANK YOU !
jeorg is offline   Reply With Quote
Old 11-28-2002, 06:24 PM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Forgive my rusty XSLT, but in your first for-each loop, I believe you could do something like:

<xsl:if test="count(following-sibling::titlePara) &gt; 0">
<xsl:variable name="offset" select="position() + following-sibling::titlePara/position()"/>
</xsl:if>

Then maybe something like:

<xsl:for-each select="para">
<xsl:if test="position() &lt; $offset">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>

Inside the very first for-each.

This is all of the top of my head, and probably I made some errors, but it might be a start.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 11-28-2002, 06:43 PM   PM User | #3
jeorg
Regular Coder

 
Join Date: Jul 2002
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
jeorg is an unknown quantity at this point
no

no I get an error !

it is so difficult to read this xml !

thanks anyway for helping
jeorg is offline   Reply With Quote
Old 11-29-2002, 07:35 PM   PM User | #4
mpjbrennan
Regular Coder

 
Join Date: Jun 2002
Location: Newcastle, England
Posts: 178
Thanks: 0
Thanked 0 Times in 0 Posts
mpjbrennan is an unknown quantity at this point
Try this stylesheet:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html"/>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="/conditions/titlePara">
<div class='title1'>
<xsl:value-of select="."/>
</div>
</xsl:template>

<xsl:template match="/conditions/para">
<div class='ParaNormal'>
<xsl:value-of select="."/>
</div>
</xsl:template>

</xsl:stylesheet>


patrick
mpjbrennan is offline   Reply With Quote
Old 11-30-2002, 08:03 AM   PM User | #5
jeorg
Regular Coder

 
Join Date: Jul 2002
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
jeorg is an unknown quantity at this point
yes !!!

now I have a good idea , how it works

simple when you know it :-)


zhank you
jeorg is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:48 AM.


Advertisement
Log in to turn off these ads.