[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Break output into files based on values


Subject: RE: [xsl] Break output into files based on values
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 27 Sep 2006 07:50:20 +0100

There's no standard facility in XSLT 1.0 to produce multiple output files.
You can do it in 2.0 using xsl:result-document, or some 1.0 processors have
a vendor extension.

In 1.0, the only way to do this is to invoke the stylesheet once for each
output file, supplying a parameter to indicate which output file to generate
on that run.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Thangavelu Srinivasan [mailto:vasantry@xxxxxxxxx] 
> Sent: 27 September 2006 06:34
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Break output into files based on values
> 
> Hi All,
> I need help in resolving the problem for the below. I am 
> using XSLT 1.0.
> Any suggestions are welcome.
> 
> My XML:
> <root>
> <DataComponent id="one">
>        <DatasComponent>
>          <p>This is a sample text</p>
>        </DatasComponent>
> </DataComponent>
> <DataComponent id="two">
>        <DatasComponent>
>          <p>This is a sample text</p>
>        </DatasComponent>
> </DataComponent>
> <DataComponent id="three">
>        <DatasComponent>
>          <p>This is a sample text</p>
>        </DatasComponent>
> </DataComponent>
> </root>
> 
> Result I am Expecting:
> 
> Based on the id, it has save in the folder as a individual 
> xml file with their content.
> 
> Filename: one.xml
> 
> <DataComponent id="one">
>        <DatasComponent>
>          <p>This is a sample text</p>
>        </DatasComponent>
> </DataComponent>
> 
> Filename: two.xml
> <DataComponent id="two">
>        <DatasComponent>
>          <p>This is a sample text</p>
>        </DatasComponent>
> </DataComponent>
> 
> My XSL:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="doc" />
> <xsl:template match="DataComponent">
> <xsl:apply-templates>
> </xsl:template>
> </xsl:stylesheet>
> 
> 
> 
> Thanks,
> Srinivas


Current Thread
Keywords