[xsl] multiple files to single file problem

Subject: [xsl] multiple files to single file problem
From: "Ganesh Babu N" <nbabuganesh@xxxxxxxxx>
Date: Tue, 9 Dec 2008 18:55:58 +0530
Hai All,

I am processing number of files recursively and getting title and
author information from them. I could able to get the title without
any problem as it will be one in a file. But When it coming to author
info I am getting strange results.

Sample XML:


<author-group>
<author><given-name>V.E.</given-name><surname>Blinov</surname></author>
<author><given-name>A.V.</given-name><surname>Bogomyagkov</surname></author>
<author><given-name>N.Yu.</given-name><surname>Muchnoi</surname></author>
<author><given-name>S.A.</given-name><surname>Nikitin</surname></author>
<author><given-name>I.B.</given-name><surname>Nikolaev</surname></author>
<author><given-name>A.G.</given-name><surname>Shamov</surname></author>
<author><given-name>V.N.</given-name><surname>Zhilich</surname>
<cross-ref refid="cor1"><sup>&#x204E;</sup></cross-ref>
<e-address type="email">zhilich@xxxxxxxxxx</e-address></author>
<affiliation><textfn>Budker Institute of Nuclear Physics, Novosibirsk,
Russia</textfn></affiliation><correspondence
id="cor1"><label>&#x204E;</label><text>Corresponding
author.</text></correspondence>
</author-group>

My XSL:

	<xsl:template match="/" name="main">
		<xsl:element name="cover-body">
			<xsl:for-each select="for $x in collection('file:///D:/cover/sample
xmls/pageall/else/nima?select=*.xml;recurse=yes;on-error=ignore')
return $x">
				<xsl:variable name="a" select="document(document-uri(/))"/>
				<xsl:element name="para">
					<xsl:element name="aid">
						<xsl:value-of select="$a/article/item-info/aid"/>
					</xsl:element>
					<xsl:element name="aug">
						<xsl:element name="author">
							<xsl:value-of select="$a/article/head/author-group/author/given-name"/>
							<xsl:text/>
							<xsl:value-of select="$a/article/head/author-group/author/surname"/>
						</xsl:element>
					</xsl:element>
					<xsl:element name="article">
						<xsl:value-of select="$a/article/head/title"/>
					</xsl:element>
				</xsl:element>
			</xsl:for-each>
		</xsl:element>
	</xsl:template>

Resultant output:

<aug><author>V.E. A.V. N.Yu. S.A. I.B. A.G. V.N. Blinov Bogomyagkov
Muchnoi Nikitin Nikolaev Shamov Zhilich</author></aug>

All the given-names are come first and surnames are next. Please help
me getting this result.

Required Output:

<aug>
<author>V.E. Blinov</author>
<author>A.V. Bogomyagkov</author>
<author>N.Yu. Muchnoi</author>
<author>S.A. Nikitin</author>
<author>I.B. Nikolaev</author>
<author>A.G. Shamov</author> and
<author>V.N. Zhilich</author>
</aug>

Regards,
Ganesh

Current Thread