xsl-list
[Top] [All Lists]

Re: [xsl] Newbie question on XSL transformations: multiple sorts on element attributes

2007-02-06 16:03:06
Rob Newman wrote:

I left some information out. I am actually importing data from 4 different XML files so I created a summary file (summary.xml) that consists of a parent element called 'sources' and child elements named 'source' that locally reference the URLs of all the XML files I need.

Then what is missing is the document(@href) function in your original code in the apply templates.


Almost! I have a whole series of pfarr elements. Each one has a pfstring element that has an id='dlt' and and value. Example:

<pfstring id='dlt'>20</pfstring>


This is quite different from your example input, where you showed one pfarr element with multiple pfstring children, each siblings to one another. I understand now, that instead of this:

   <pfarr name="dls">
       <pfarr name="abcde">
           <pfstring name="aa">0.010</pfstring>
           <pfstring name="br24">23266128.0</pfstring>
           <pfstring name="dlt">30</pfstring>

it is more like this:
   <pfarr name="dls">
       <pfarr name="abcde">
           <pfstring name="aa">0.010</pfstring>
       </pfarr>
       <pfarr name="ef">
           <pfstring name="br24">23266128.0</pfstring>
       </pfarr>
       <pfarr name="ghi">
           <pfstring name="dlt">30</pfstring>
....


with one additional change: all names are now always equal to 'dlt', right?

I want this to be output thus:

<datalogger name="B">
    <param id="dlt">80</param>
</datalogger>

<datalogger name="C">
    <param id="dlt">50</param>
</datalogger>


which, to me, looks quite different from your original output, where you kept the original siblings of params together.




To be verbose: I want to sort them so that the first datalogger element in the XML output is the one with the highest dlt. This is then followed by those with high dlt values. Once we get beyond the dlt values, the datalogger elements are ordered by their name. All dataloggers have a param element with an id of 'dlt' and an associated value.

Do you mean that siblings can occur, and that you want the pfarr that has highest available 'dlt' value to be output as first datalogger element? Or is there always only one dlt? What do you mean with "beyond dlt values"? It helps if you show the input as it really is, because it seems contradictory to say "Each one has a pfstring element that has an id='dlt' " and "Once we get beyond the dlt values", because they are always there.

Please clarify the following:

1. The order of the datalogger elements, based on some (cumulative?) value of their children 2. The order of the param elements inside each datalogger, if there are more than one (are there?) 3. Whether additional param elements influence the order of the datalogger, other then what you define by (1) 4. The exact content of your data (but keep it brief) and an example of the exact output, based on that very content. Make sure it clarifies the other points above, and the structure.


-- Abel

--~------------------------------------------------------------------
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>