How to use XSLT to find radom no. of levels of subfolder and rereive data?

Up vote 0 down vote favorite share g+ share fb share tw.

I am stuck here. Can not think of a clever way to do this. Need to retrieve data under 'reporting:line'.

2 data needs to be retreived 'reporting:name' and 'reporting:ident'. 'reporting:line' is under the random numbers of sub-level of 'reporting:forder'. So they can be in the 100th sub-folder.

So I need a kind of clever code to automatically find the correct level to retreive data. Essentially need to see following as result: test2,-32 test3,1 test14,56 the below is the xml source file: TEST test00 2 test0 31 test1 4 test2 -32 test3 1 test4 5 test5 6 test6 7 test7 8 test8 9 test10 10 test11 11 test12 12 test13 13 test14 56 xslt link|improve this question edited Nov 26 '10 at 19:13user357812 asked Nov 26 '10 at 18:30ken103.

( – ken Nov 26 '10 at 18:31 Thanks Alejandro – ken Nov 29 '10 at 13:41.

This transformation: when applied on the provided XML document, produces the wanted result: test2 -32 test3 1 test14 56 Do note: In XSLT one doesn't have to care about the actual depth of an element. The power of XSLT pattern matching, combined with XSLT default processing allows us conveniently to provide only a simple match pattern for an The default XSLT processing is for every element to apply templates to its children and for every text node to output its content. We simply override the default XSLT processing by specifying a template matching every reporting:line element in which we output exactly the string value of the wanted two children.

We also override the default XSLT processing for every text node with a template that does nothing, so that no text nodes would be output.

1 Good answer. – user357812 Nov 26 '10 at 19:16 Thx a lot for your answer. I tried it and it worked like magic.

I have more question now. I also need to report name and ident for level 1 and level 2 of reporting:folder in the file. And for each row of reporting:line it needs to report the correct top 2 level folder so the output will be something like: test – ken Nov 29 '10 at 11:45 top level folder,2nd level folder,current level folder,name,ident test00,test00,test00,test00,2 test00,test00,test0,test0,31 test00,test0,test1,test2,-32 test00,test0,test1,test3,1 test10,test10,test10,test10,10 test10,test10,test11,test11,11 test10,test11,test13,test14,56 – ken Nov 29 '10 at 12:05 tried add below but then reporting:line is ignored : – ken Nov 29 '10 at 12:08 not sure how can tell the code to go back to the top 1 and 2 folder to report them in the file.

Thanks a lot. – ken Nov 29 '10 at 12:11.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions