[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Converting a hierarchical to a pseudo relational xml f

Subject: Converting a hierarchical to a pseudo relational xml format -or - adding to the middle of a result tree
From: "Hugh Dixon" <hugh.dixon@xxxxxxxxxxxxxx>
Date: Sat, 22 Mar 2003 17:38:33 +1100
xsl relational
I am wanting to convert this:

      <coord val="1 2"/>
      <coord val="3 4"/>
      <coord val="3 4"/>
      <coord val="5 6"/>
      <coord val="7 8"/>
  <coord val="9 10"/>
  <coord val="11 12 13 14 15 16"/>
    <coord val="17 18"/>
    <coord val="19 20 21 22 23 24"/>

Into this:

  <Coord num = "1" val ="1 2"/>
  <Coord num = "2" val ="3 4"/>
  <Coord num = "3" val ="5 6"/>
  <Coord num = "4" val ="7 8"/>
  <Coord num = "5" val ="9 10"/>
  <Coord num = "6" val ="11 12"/>
  <Coord num = "7" val ="13 14"/>
  <Coord num = "8" val ="15 16"/>
  <Coord num = "9" val ="17 18"/>
  <Coord num = "10" val ="19 20"/>
  <Coord num = "11" val ="21 22"/>
  <Coord num = "12" val ="23 24"/>
  <Line num="1" coordVals="1 2"/>
  <Line num="2" coordVals="2 3 4"/>
  <Line num="3" coordVals="9 10 11 12"/>
  <Chain num="1" lineVals="1 2"/>

Sorry it's so long......
The number in coord::@val can be any floating point value.  The @num
values in the output document, are integers, that are generated through
the style sheet.  They are effectively primary keys, which I would like
to keep small, although this is not essential.
In the result each coord, line and chain is given a unique number, and a
list of values to the constituent elements (i.e. Chains to Lines, and
Lines to Coords)

To perform this transformation, I'd like to able to walk the source
tree, writing Coord, Line and Chain elements as required, also doing
counts to get my next number.  Is this possible?  I suspect not.
My other idea was that I write all the Coords first (as I understand you
should with XSLT!), but leave an identifier(s) on each coord node as I
process it, from which I could retrieve the Coord:@num values when the
<Line> elements are written, and similarly for the next level up.
I cannot see how to do either of these easily.
Using the first of the two ideas, I could write my output into a large
string/variable, with which I am not restricted to writing to the end.
As the output files may end up being hundreds of megabytes in size, I am
not sure this is really practical.
Could someone please offer me an alternative solution?

Hugh Dixon

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.