Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 14th, 2014, 11:24 AM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old July 14th, 2014, 11:59 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
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?
Reply With Quote
The Following User Says Thank You to samjudson For This Useful Post:
sunnykeerthi (July 21st, 2014)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:10 PM.


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