xsl-list
[Top] [All Lists]

[xsl] Question about grouping

2010-09-23 20:51:01
I have an XSLT problem that I haven't been able to figure out.  The example 
below is essentially the simplest version of the problem I have encountered.

Say you have a document like this:

<doc>
  <book title="aaa" author="jones"/>
  <book title="bbb" author="smith"/>
  <book title="ccc" author="douglas"/>
  <book title="ddd" author="jones"/>
  <book title="eee" author="jones"/>
  <book title="fff" author="douglas"/>
  <book title="ggg" author="smith"/>
</doc>


How can you produce a document like this?:

<report>
  <author name="jones">
        <title>aaa</title>
        <title>ddd</title>
        <title>eee</title>
  </author>
  <author name="smith">
        <title>bbb</title>
        <title>ggg</title>
  </author>
  <author name="douglas">
        <title>bbb</title>
        <title>fff</title>
  </author>
</report>

Restrictions:
- Only XSLT 1.0
- You can't hard-code the names of the books or the authors in the XSLT.


Thanks,
Dave

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