This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Getting the deepest node and calculating relative paths


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]