xsl-list
[Top] [All Lists]

Re: [xsl] Converting from <dt><dd> pairs to better XML

2010-09-02 19:10:54
Thanks to everyone who helped in my original question

With your assistance, I was able to convert
<dl>
 <dt>AAA</dt>
 <dd>111</dd>
 <dt>BBB</dt>
 <dd>222</dd>
 <dt>BBB</dt>
 <dd>333</dd>
 <dt>BBB</dt>
 <dd>444</dd>
 <dt>CCC</dt>
 <dd>555</dd>
 <dt>CCC</dt>
 <dd>666</dd>
 <dt>EEE</dt>
 <dd>777</dd>
</dt>

into

111|222,333,444|555,666|777

Unfortunately, it was only after that when I found that the supplier
of my data decided to make a variable and arbitrary number of distinct
<dd><dt> pairs from one record to the other, so I need to massage the
result further before it's suitable to go into the pipe-separated file
that I need.

What I really need is actually
111|222,333,444|555,666||777

(... for the above record, because it had no data under "DDD")

So I think I need to do a two-pass solution,

1) On the first pass, to convert the above example data to
<AAA>111</AAA>
<BBB>222,333,444</BBB>
<CCC>555,666</CCC>

So I *do* need to group by DT but I am able to assume only one <dd>
value following each <dt>

2) On the second pass I extract only those fields that I need (and
give null entries for those that have no supplied data).

The second pass I think I know how to do, but the first pass still
eludes me because of the "following-sibling" magic whose syntax and
context still eludes me at this moment. I'm trying to deconstruct the
examples you've sent me, but it hasn't been easy.

Any help (especially with the first pass) will be greatly appreciated.

- Evan

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>