[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Breaking XML into Multiple Tables or Pages Using XSL
Processor: xalan-2.4.1 Problem: XML to break into pages or into tables having 4 records each: <?xml version="1.0" encoding="UTF-8"?> <Person race="Asian" Sex="Male"> <Person1 FirstName="Pankaj" LastName="Ahuja"> <CharateristicsCollection> <Characteristics Profession="Programmer" jobs="3jobs"> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6682 S" Zip="84121" Salary="70000"/> </Characteristics> <Characteristics Profession="Programmer1" jobs="2jobs"> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> </Characteristics> <Characteristics Profession="Programmer2" jobs="1jobs"> <Detail Address="6680 S" Zip="84121" Salary="80000"/> </Characteristics> <Characteristics Profession="Programme3r" jobs="3jobs"> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6682 S" Zip="84121" Salary="70000"/> </Characteristics> <Characteristics Profession="Programmer4" jobs="3jobs"> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6682 S" Zip="84121" Salary="70000"/> </Characteristics> <Characteristics Profession="Programmer5" jobs="3jobs"> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6682 S" Zip="84121" Salary="70000"/> </Characteristics> </CharateristicsCollection> </Person1> </Person> Result desired: 1. Want to break this into table using XSL(XPATH) having 4 records each (Including Attributes of Characteristics as well as Child elements of Characteristics) 2.I want structure like this: Asian Male Pankaj Ahuja Programmer--(This one is the 1st attribute of Characteristics) 6680 S 84121 80000 6681 S 84121 60000 6682 S 84121 70000 (Page Break after this as this shd break after 4 records) 3jobs --(This one is the 2nd attribute of Characteristics) Programmer1--(This one is the 1st attribute of Characteristics) 6680 S 84121 80000 6681 S 84121 60000 (Page Break after this as this shd break after 4 records) 2jobs --(This one is the 2nd attribute of Characteristics) Programmer2 6680 S 84121 80000 1jobs (Page Break after this as this shd break after 4 records) and so on with each page Problem Solving:: Have tried this : CharateristicsCollection/Characteristics/Detail[position() mod 4 = 1] -- -- (. | following-sibling::* |../following-sibling::*/*)[position () <= 4]"> but helps only if XML is like this: <?xml version="1.0" encoding="UTF-8"?> <Person race="Asian" Sex="Male"> <Person1 FirstName="Pankaj" LastName="Ahuja"> <CharateristicsCollection> <Characteristics> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6682 S" Zip="84121" Salary="70000"/> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6682 S" Zip="84121" Salary="70000"/> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6682 S" Zip="84121" Salary="70000"/> <Detail Address="6680 S" Zip="84121" Salary="80000"/> <Detail Address="6681 S" Zip="84121" Salary="60000"/> <Detail Address="6682 S" Zip="84121" Salary="70000"/> </Characteristics> </CharateristicsCollection> </Person1> </Person> This works only if there are no multiple Detail collection in separate groups. -------------------------------------------------------------- ------------------------------------- I cannot get this to work where it is needed to first read the first attribute and then all attributes of the child and then back to reading the second attribute of the parent element. Also how to keep track of next items. Help me accomplish it.It is quite challenging. Regards, Pankaj Ahuja
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|