[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

single document write

Subject: single document write
From: gl <glarowe@xxxxxxxxxxx>
Date: Wed, 29 Jun 2005 15:14:33 -0500
document.write select
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.