[xsl] single document write

Subject: [xsl] single document write
From: gl <glarowe@xxxxxxxxxxx>
Date: Wed, 29 Jun 2005 15:14:33 -0500
Hello,

I've searched the archives for an answer to this problem, so I apologize for any repeat posting.

I have a large XML file composed of multiple <article> element trees. I am attempting to use XSLT to transform this large XML file into a tab-delimited file format suitable for uploading into an Open Source database. Each <article> contains some one-to-many relationships which I am trying to capture in separate files for uploading into a corresponding table. One of these is an <AuthorList>.

Right now, the stylesheet template transforms and outputs a single file for each author using the result-document directive, but what I would like to do is just write to a single author file every time the stylesheet template processes a single author. Is this possible?

I am using saxon (saxon8.jar) for the processing ...

For example, XML for an <AuthorList> inside the <article> tag:

<article>
...
...
<AuthorList CompleteYN="Y">
<Author ValidYN="Y">
<LastName>Di Venere</LastName>
<ForeName>A</ForeName>
<Initials>A</Initials>
</Author>
<Author ValidYN="Y">
<LastName>Rossi</LastName>
<ForeName>A</ForeName>
<Initials>A</Initials>
</Author>
<Author ValidYN="Y">
<LastName>De Matteis</LastName>
<ForeName>F</ForeName>
<Initials>F</Initials>
</Author>
<Author ValidYN="Y">
<LastName>Rosato</LastName>
<ForeName>N</ForeName>
<Initials>N</Initials>
</Author>
<Author ValidYN="Y">
<LastName>Agr</LastName>
<ForeName>A F</ForeName>
<Initials>AF</Initials>
</Author>
<Author ValidYN="Y">
<LastName>Mei</LastName>
<ForeName>G</ForeName>
<Initials>G</Initials>
</Author>
</AuthorList>
...
...
</article>

XSL template for the <AuthorList>:

<xsl:template name="authorlist">
<xsl:param name="pmid"/>
<xsl:if test="Article/AuthorList/Author">
<!-- write author data to author/pmid output file -->
<!-- tab delimited -->
<!-- fields: pmid valid(y/n) name_last name_first initials -->
<!-- unique identifier: pmid value -->
<xsl:result-document href="author/mal_{$pmid}.pgsql">
<xsl:for-each select="Article/AuthorList/Author">
<xsl:value-of select="$pmid"/><xsl:value-of select="$tab"/><xsl:value-of select="normalize-space(@ValidYN)"
/><xsl:value-of select="$tab"/><xsl:value-of select="normalize-space(LastName)"/><xsl:value-of select="$tab"/><xsl:value-of
select="normalize-space(ForeName)"/><xsl:value-of select="$tab"/><xsl:value-of select="normalize-space(Initials)"/><xsl:va
lue-of select="$newline"/>
</xsl:for-each>
</xsl:result-document>
</xsl:if>
</xsl:template>


Thanks in advance,

Best,

Gerry

Current Thread