RE: [xsl] appendig to multiple output files

Subject: RE: [xsl] appendig to multiple output files
From: "Bryan Rasmussen" <bry@xxxxxxxxxx>
Date: Thu, 24 Jan 2002 15:45:20 +0100

> out of this XML file I want to generate in a *single* transformation
> process two separate, completely different output files (method="text")


>    <xsl:document method="text" href="somefilename">
<xsl:text>.....</xsl:text>
>     <xslvalue-of select="content"/>
>     ...
>   </xsl:document>

>    <xsl:apply-templates select="anotherelement"/>
> </xsel:template>

>  <xsl:template match="anotherelement">
>    <!-- more output *appended* to main document -->
>    <xsl-value-of select="..."/>
    ...


>  <xsl:docmument method="text" href="somefilename">
>      <xsl:value-of select="some content"/>
>      ...
>    </xsl_document>

> </xsl:template>


the problem, like I pointed out in one of my posts is you can't read in a
text file, unless there's some extension for it, probably with xalan. or you
write your own.
If you could read in a text file you could do the same as I did in my
example for xml:

if you had xml like this:

<?xml version='1.0' encoding="utf-16"?>
<output file="e_files.xml">
<p>test</p>
</output>

and an xslt like this
<?xml version='1.0' encoding="utf-16"?>

<xsl:stylesheet version='1.1'
    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
>

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="output">
<xsl:variable name="href"><xsl:value-of select="@file"/></xsl:variable>
<xsl:param name="input" select="document($href)"/>
<xsl:document href="{$href}" method="xml">
<root>
<xsl:copy-of select="$input"/>
<xsl:apply-templates/></root>
</xsl:document>
</xsl:template>

<xsl:template match="p">
<para><xsl:value-of select="."/></para>
</xsl:template>




</xsl:stylesheet>

you could then keep reading in the xml again and again and overwriting
e_files.xml, copying the content it had, and appending the content in your
file with output.
but can't do this with a simple text, cause you can't use document() to get
a text file. with xslt 2.0 you can use unparsed-text(uri,encoding-string?)
to get text files, in that case you should be able to do the same thing, as
above.
so my advice is use xml instead of text and you can set the above up easily
enough(few modifications required of course.)



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread