Previous , next element ?
How to access the next element in the xml from the current context?
Sometimes, we need the previous month node value, to compare with the current month value.
Use XSL functions like following-sibling::, preceding-sibling::
<?for-each:/ROOT/ROW>?
==================
Current StartDate <?START_DATE>?
Current End Date <?END_DATE>?
Next Start Date <?following-sibling::ROW/END_DATE>?
Previous End Date <?preceding-sibling::ROW[1]/END_DATE>?
================
<?end for-each>?
<ROOT>
<ROW>
<START_DATE>01-01-1980</START_DATE>
<END_DATE>01-01-1988</END_DATE>
</ROW>
<ROW>
<START_DATE>01-01-1988</START_DATE>
<END_DATE>01-01-1990</END_DATE>
</ROW>
<ROW>
<START_DATE>01-01-2000</START_DATE>
<END_DATE>01-01-2005</END_DATE>
</ROW>
</ROOT>
o/p
==================
Current StartDate 01-01-1980
Current End Date 01-01-1988
Next Start Date 01-01-1990
Previous End Date
================
==================
Current StartDate 01-01-1988
Current End Date 01-01-1990
Next Start Date 01-01-2005
Previous End Date 01-01-1988
================
==================
Current StartDate 01-01-2000
Current End Date 01-01-2005
Next Start Date
Previous End Date 01-01-1990
Sometimes, we need the previous month node value, to compare with the current month value.
Use XSL functions like following-sibling::, preceding-sibling::
<?for-each:/ROOT/ROW>?
==================
Current StartDate <?START_DATE>?
Current End Date <?END_DATE>?
Next Start Date <?following-sibling::ROW/END_DATE>?
Previous End Date <?preceding-sibling::ROW[1]/END_DATE>?
================
<?end for-each>?
<ROOT>
<ROW>
<START_DATE>01-01-1980</START_DATE>
<END_DATE>01-01-1988</END_DATE>
</ROW>
<ROW>
<START_DATE>01-01-1988</START_DATE>
<END_DATE>01-01-1990</END_DATE>
</ROW>
<ROW>
<START_DATE>01-01-2000</START_DATE>
<END_DATE>01-01-2005</END_DATE>
</ROW>
</ROOT>
o/p
==================
Current StartDate 01-01-1980
Current End Date 01-01-1988
Next Start Date 01-01-1990
Previous End Date
================
==================
Current StartDate 01-01-1988
Current End Date 01-01-1990
Next Start Date 01-01-2005
Previous End Date 01-01-1988
================
==================
Current StartDate 01-01-2000
Current End Date 01-01-2005
Next Start Date
Previous End Date 01-01-1990
Comments