Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 14th, 2014, 11:24 AM
Authorized User
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Unhappy Getting section level based on node position

Hi,

I've a XML of the below form

Code:
    <root>
     <para>//this should be section 1
      <para></para>//this should be section 2
     </para>
     <para>//this should be section 1
      <para>//this should be section 2
       <para></para>//this should be section 3
      </para>
     </para>
    <root>
here i need to scan the place where the para is present and assign the section number as given in above XML(The comments), i'm very confused because all the node names are para and i'm unable to find a pattern to do this. please let me know how this can be done.

The expected output is as below.

Code:
<root>
     <para section="1">
      <para section="2"></para>
     </para>
     <para section="1">
      <para section="2">
       <para section="3"></para>
      </para>
     </para>
    <root>
And also i want this to be done from the `para` template match.

Thanks
 
Old July 14th, 2014, 11:59 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

So the section number is the number of 'para' elements above the current 'para' element?

Try:

Code:
<para section="{count(ancestor-or-self::para)}">
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
sunnykeerthi (July 21st, 2014)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With Position of Current Node From Root ritagr XSLT 4 August 3rd, 2012 12:54 PM
How to get the following node children based on the node condition JohnKiller XSLT 6 April 20th, 2012 01:10 PM
Getting the position of a node in the original XML zvikico XSLT 8 July 17th, 2008 09:31 AM
Position of a node outside current context QuickSilver002 XSLT 2 April 19th, 2007 02:07 PM
XSLT Going up a level from current node. lafilip XSLT 4 February 23rd, 2007 03:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.