Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: variables

From: "RedLars" <Liverpool1892@-----.--->
To: NULL
Date: 4/2/2007 11:55:00 PM

On 30 Mar, 14:54, Martin Honnen <mahotr...@yahoo.de> wrote:
> RedLars wrote:
> > Say I have a loop which processes some items that each has its unique
> > id (for instance; 1,2,5,7,12,25,24,46,78,130 )
>
> > <xsl:for-each select="Nodes">
> >    <h2><xsl:value-of select="@type"/><xsl:number value="@id"
> > format="001"/></h2>
> >    // code
> > </xsl:for-each>
>
> > I'm struggling with adding a line change (<br>)  when the id changes
> > from 10's to 20's. So I'd like to have all items with id 0-9 on one
> > line and from 10-19 on another line etc.
>
> As for XSLT and checking the id, use the floor(@id div 10) and compare
> to the following-sibling e.g.
>
>        <xsl:for-each select="Node">
>          <h2><xsl:value-of select="@type"/><xsl:number value="@id"
> format="001"/><xsl:value-of select="concat(' floor: ', floor(@id div
> 10))"/></h2>
>          <xsl:if test="floor(@id div 10) !=
> floor(following-sibling::node[1]/@id div 10)">
>            <br/>
>          </xsl:if>
>        </xsl:for-each>
>
> I don't think however that it is a good idea in terms of HTML structural
> markup to separate h2 elements by br elements, h2 is a block element for
> a heading, if you want list items then consider ol or ul with li and
> suggest formatting like padding and margin with CSS.
>
> --
>
>         Martin Honnen --- MVP XML
>        http://JavaScript.FAQTs.com/

Cheers for the feedback.

It's almost working now, just one small problem, the xml data I'm
working on is not sorted. By doing <xsl:sort .. I'm able to sort the
list but it seems that following.sibling::node()[1] doesn't select the
next sorted element but the next element. So for instance when dealing
with computer element with number equals 1, it looks to the next
sibling element which in the xml file is computer element with number
equals 161 and not the element with number equal 2. See the 'problem'?

Any ideas?

<xsl:for-each select="computer">
	<xsl:sort select="@number" data-type="number"/>
	<a href="#{generate-id()}"><xsl:value-of select="@type"/><xsl:number
value="@number" format="001"/></a>
	<xsl:value-of select="concat(' floor: ', floor(@number div 10))"/>
	<xsl:value-of select="concat(' floor_sib: ', floor(following-
sibling::node()[1]/@number div 10))"/>
	<xsl:value-of select="concat(' floor_num: ', (following-
sibling::node()[1]/@number))"/>
	<xsl:if test="floor(@number div 10) != floor(following-sibling::node()
[1]/@number div 10)">
	           <br/>
         	</xsl:if>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent