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]

creating XML hierarchy where not existed before??


Hi,

I've been banging my head on this for a while now: I
need to create hierarchical XML out of flat XML. The
logic is simple, but I think that I can't perform this
translation in XSL because I can't proceed through the
input file ina serial manner.

In the example that follows:
all group3s following a group2 must be included in the
last group2; all group2s follwing a group1 must be
included in the last group1. There can be any number
of groups that I would like to nest.

Can this problem be solved using XSLT, or will I have
to look somewhere else to process my input files?

Any help greatly appreciated,

//F

INPUT:
<group1>
  <datafield1>value1</datafield1>
  <datafield2>value2</datafield2>
</group1>

<group2>
  <datafield1>value1</datafield1>
  <datafield2>value2</datafield2>
</group2>

<group2>
  <datafield1>another_value1</datafield1>
  <datafield2>another_value2</datafield2>
</group2>

<group3>
  <datafield1>value1</datafield1>
  <datafield2>value2</datafield2>
</group3>

Desired Output:

<group1>
  <datafield1>value1</datafield1>
  <datafield2>value2</datafield2>

  <group2>
    <datafield1>value1</datafield1>
    <datafield2>value2</datafield2>
  </group2>

  <group2>
    <datafield1>another_value1</datafield1>
    <datafield2>another_value2</datafield2>

    <group3>
      <datafield1>value1</datafield1>
      <datafield2>value2</datafield2>
    </group3>

   </group2>

</group1>

__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/

 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]