![]() |
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 ! |
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) > 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() < $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. :) |
no
no I get an error !
it is so difficult to read this xml ! thanks anyway for helping |
Try this stylesheet:
<?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output 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 |
yes !!!
now I have a good idea , how it works
simple when you know it :-) zhank you |
| All times are GMT +1. The time now is 05:21 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.