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

sorting and merging

Subject: sorting and merging
From: Riboni Ugo <Ugo.Riboni@xxxxxxxxxxxx>
Date: Tue, 3 Apr 2001 14:24:48 +0200
sorting and merging
hi everybody,
i'm new ot this list but maybe someone can can give me some help
to solve this problem i have.

(sorry if the explanation is going to be lengthy, but i had not found
a more concise way to express what i need to do. i hope this helps
clarity, thought.)

in my application (server side) i create an xml fragment from random 
user input, then i need to merge it into a "main" xml document after 
sorting it.

the structure of my main xml doc looks like:


      <q type="S">
	     {...more <a>...}
	{...more <q>...}
and the fragments i need to merge look like:

  <a new="3">txt</a>		
  <a new="1">txt</a>		
  <a new="2">txt</a>		
What i need to do is to first sort the <a>'s in the fragment based on the
"new" attribute,
then insert them in the main xml file *replacing* all the old <a>'s.
To make it simple suppose i wish to insert them always as childs of the
first <q> in the main xml doc. (i think i can parametrize this later).

Also i need, quite obviously, to remove the "new" attribute from the result,
since it's useful only as a sort device and not to the final xml.

Currently what i do is to create load the fragment in the processor and sort
the <a>'s with
a stylesheet like this one (boilerplate stuff killed):

<xsl:template match='/'>
	<xsl:apply-templates select="/temproot"/>
<xsl:template match='@* | node()'>
		<xsl:apply-templates select='@*[not(name()="new")] | node()'
			<xsl:sort select="@new" data-type="number"/>

after this i have to resort to the loading the main xml and the sorted 
fragment in two DOMs and then "manually" strip all the childs <a>'s of 
the designated <q> and insert the new <a>'s in their place.

My idea is to use document() to load the main xml in the above stylesheet
use it to perform also the part i currently do via the DOM, but so far i had
not been able to write a working stylesheet that does this.

Can someone please throw an hint at me ? Just an idea on how to tackle this
problem or some pieces of example stylesheet would be greatly appreciated.

Thanks in advance,
Ugo R. 

 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.