xsl-list
[Top] [All Lists]

Re: [xsl] Creating multiple xmls using xslt1.0

2012-05-17 15:10:45
On Thu, 2012-05-17 at 11:21 +0000, Siddhi Thakkar wrote:
Hi experts, 

I have an xml file like this:
[...]
And I have thousands of <Row> elements like this. For the first 50
rows, I should be able to create an output xml with name Data1.xml,
for next 50 rows output xml should be data2.xml,

So there are three parts to this.
(1) selecting the right elements, e.g. with Muenchian grouping;
(2) generating the file names, probably using position()
(3) writing to multiple files, which will require the use of the
    exslt extensions, or the xt extensions, or XSLT 2,
    or some other non-XSLT-1.0 approach.

With the xt extensions, supported by xt and by libxml,
xmlns:xt="http://www.jclark.com/xt";

<xsl:template name="write-one-file">
  <xsl:param name="what-to-write" />
  <xsl:param="filename" />
  <xt:document method="html" href="{$filename}">
    <xsl:apply-templates select="$what-to-write" />
  </xs:document>
</xsl:template>

But not all processors support that. So best if you mention which XSLT
processor you're using. Always best to give people enough information to
help you :-) These days I mostly use Saxon and xsl:result-document.

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml


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