This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Getting the deepest node and calculating relative paths
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Getting the deepest node and calculating relative paths
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Thu, 25 Jan 2001 10:19:32 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
> I need to transform an XML that looks like:
>
> <Root>
> <Paths>
> <Path value="/Catalog/Department/Product/SKU"/>
> <Path value="/Catalog/Department/@dept_id"/>
> <Path value="/Catalog/Department/Product/Name"/>
> <Path value="/Catalog/Department/Product/Price"/>
> <Path value="/Catalog/Department/Product/Variant/Name"/>
> </Paths>
> </Root>
>
> to something that looks like:
>
> <Root>
>
> <LongestPath>/Catalog/Department/Product/Variant/Name</LongestPath>
Would counting the number of "/" characters give you the right answer?
You can do that as
string-length($path) - string-length(translate($path, '/', ''))
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list