following-sibling

wxdqz

New Member
I'm trying to get this stylesheet to scroll through the xml data and select the correct values of thickness, one immediately less than the thickness required, and one immediately greater than the value of thickness required from successive table rows.

Could anyone tell me why this isn't happening?

many thanks


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:jsc="http://my-company.com/namespace">

<xsl:variable name="thickness_required" select="2.75"/>

<xsl:template match="/">
<html>
<body style="font-family:Arial">
<xsl:apply-templates select="//jsc:table_row"/>
</body>
</html>
</xsl:template>

<xsl:template match="jsc:table_row">
<xsl:for-each select=".">
<xsl:if test="table_row/thickness < $thickness_required">
<xsl:if test="following-sibling::table_row/thickness > $thickness_required">
<xsl:value-of select="table_row/thickness"/>
<xsl:value-of select="following-sibling::table_row/thickness"/>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>



<fastener xmlns="http://my-company.com/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my-company.com/namespace
FastenerSchema.xsd">
<table table_number="1" bolt_material="ALLOY-STEEL" fastener_type="BOLT">
<table_row>
<row_id>1</row_id>
<thickness>0</thickness>
<dia_3b>0</dia_3b>
<dia_4b>0</dia_4b>
<dia_5b>0</dia_5b>
<dia_6b>0</dia_6b>
<dia_7b>0</dia_7b>
</table_row>
<table_row>
<row_id>2</row_id>
<thickness>2.5</thickness>
<dia_3b>835</dia_3b>
<dia_4b>1107</dia_4b>
<dia_5b>1380.25</dia_5b>
<dia_6b>1660.25</dia_6b>
<dia_7b>1937</dia_7b>
</table_row>
<table_row>
<row_id>3</row_id>
<thickness>3</thickness>
<dia_3b>990</dia_3b>
<dia_4b>1329</dia_4b>
<dia_5b>1656.5</dia_5b>
<dia_6b>1992.5</dia_6b>
<dia_7b>2325</dia_7b>
<dia_8b>2657</dia_8b>
</table_row>
<table_row>
<row_id>4</row_id>
<thickness>4</thickness>
<dia_3b>1225</dia_3b>
<dia_4b>1715</dia_4b>
<dia_5b>2209</dia_5b>
<dia_6b>2657</dia_6b>
<dia_7b>3100</dia_7b>
</table_row>
</table>
</fastener>
 
Back
Top