Loading ...
Sorry, an error occurred while loading the content.

Breaking XML into Multiple Tables or Pages Using XSL

Expand Messages
  • pankaj_ahuja99
    XML to break into pages or into tables having 4 records each:
    Message 1 of 1 , Nov 10, 2005
    • 0 Attachment
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.