[xsl] New XSL user seeking assistance!

Subject: [xsl] New XSL user seeking assistance!
From: Matt Sims <matt.sims@xxxxxxxx>
Date: Tue, 05 Jul 2005 13:10:32 +0100
Hi,

I'm faced with a problem that I believe XSL may be able to help me with,
but having only just discovered XSL I am having difficulty in
implementing the solution!

Basically, I have some XML that is used in a custom .NET application for
the display of formatted text.  Here's an example to demonstrate the format:

<text>
   <font number="5">
       Hello
       <colour number="3">
           <indent x="1" y="2">
              World
           </indent>
      </colour>
   </font>
</text>

My problem is that due to the way the XML is generated by the
application, I often get nested elements of the same type that I need to
'merge' together into one, while summing the attribute values of the
merged nodes, i.e.:

<text>
   Hello
   <indent x="1" y="2">
       <indent x="6" y="-1">
           World
       </indent>
   </indent>
</text>

needs to become:

<text>
   Hello
   <indent x="7" y="1">
       World
   </indent>
</text>

There is no limit to how deep the nesting can be, but only certain types
need to be merged (eg. in this case, only 'indent' elements).  Elements
such as 'font' and 'colour' simply override any previous elements of the
same type so are not a problem.  Obviously, nodes of the same type need
only be merged when they are immediate descendants of each other, as
opposed to having text between.

I'm using the System.Xml.Xsl library of V2.0 of the .NET framework, so I
assume this will support V2.0 of the XSLT specification if required.
Any other questions, please ask.

Thanks in advance for any answers you may be able to give me!

Kind regards,

Matt Sims.

Current Thread