Subject: RE: Getting the deepest node and calculating relative paths
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 25 Jan 2001 10:19:32 -0000
|
> 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
|