[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: Absolute-path/index challenge
At 00/01/20 12:58 -0600, Thomas E Enebo wrote:
As an extension of the position() of parent question from digest 480,
I have a challenge. How can a template be created, such that it will
print out the complete path of current node from the root? As an
example:
<A>
<B>
<C/>
</B>
<B>
<C/>
<C/> <--- calling a template with current() here...
</B>
<B>
</B>
</A>
will yield
A:1.B:2.C:2
The following is the output for the above (with the comment repaired) from
the SHOWTREE diagnostic stylesheet available through the free resources
page on our web site:
1 Element 'A' ():
1.1 Text (A): {
}
1.2 Element 'B' (A):
1.2.1 Text (A,B): {
}
1.2.2 Element 'C' (A,B): (no child nodes or attributes)
1.2.3 Text (A,B): {
}
1.3 Text (A): {
}
1.4 Element 'B' (A):
1.4.1 Text (A,B): {
}
1.4.2 Element 'C' (A,B): (no child nodes or attributes)
1.4.3 Text (A,B): {
}
1.4.4 Element 'C' (A,B): (no child nodes or attributes)
1.4.5 Text (A,B): { }
1.4.6 Comment (A,B): {- calling a template with current() here...}
1.4.7 Text (A,B): {
}
1.5 Text (A): {
}
1.6 Element 'B' (A):
1.6.1 Text (A,B): {
}
1.7 Text (A): {
}
The numbers above correspond to *all* nodes, so text nodes are included in
the count as well.
I hope you find it useful in figuring out the detail of precisely what you
need.
............... Ken
--
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath ISBN 1-894049-03-9
Next instructor-led training: 2000-02-27/28,2000-05-11/12,2000-05-15
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|