xsl-list
[Top] [All Lists]

Re: [xsl] using xsl:result-document in a non-list situation

2008-08-19 13:34:50
2008/8/19 Mark Wilson <mark(_at_)knihtisk(_dot_)org>:
All of the examples for using <xsl:result-document> to produce multiple
files (at least those that I've seen) write to a new file each time they
encounter a new instance of a controlling element structure in a 'list' and
use "position()" to help name the file. What technique do I apply to a
document containing a <List> of <Items> such as the one shown below? Here
the controlling element is not simply another <Year> element, but <Year>
elements with differing content: 1998, 1999 and so on, with each year
repeated within the source  document many times. Ideally, the output would
be a series of files, one for each different <Year> content (1998.xml,
1999.xml) and each sorted internally by <IssueNumber> and <Page>.

I have not been able to see how the stylesheet should be constructed. Any
hints would be appreciated.
Thanks,
Mark

Source example:
<List>
  <Item>
      <Data>
          ...
      </Data>
      <Article>
          <Year>1999</Year>
          <IssueNumber>1</IssueNumber>
          <Page>6</Page>
      </Article>
  </Item>
  <Item>
      .......
  </Item>
</List>

How about:

<xsl:for-each-group select="Item" group-by="Article/Year">
  <xsl:result-document href="{current-grouping-key()}.ext">
    <xsl:for-each select="current-group()">
      <xsl:sort select="Article/IssueNumber" data-type="number"/>
      <xsl:sort select="Article/Page" data-type="number"/>
      ......


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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