Re: [xsl] unparsed-text and for-each-group

Subject: Re: [xsl] unparsed-text and for-each-group
From: James Cummings <cummings.james@xxxxxxxxx>
Date: Wed, 21 Dec 2005 18:04:59 +0000
On 12/21/05, David Carlisle <davidc@xxxxxxxxx> wrote:
> only one unparsed-text to pull in the whole file then  use regular
> expressions, probably easiset to pu every lin ein an l first
> <xsl:variable name="lines" as="element()*"">
> <xsl:for-each select="tokenize(unparsed-text('file.txt','&#13;?&#10;')">
>  <l><xsl:value-of select="."/>
> </xsl:for-each>
> </xsl:element>

Ok, doing this part rightly got me a <poem> with lots of <l> elements
in it... but when I try to expand it to do the second part...
> then use for-each-group to group up the versesinto lg elements based on
> empty l elements.

I'm obviously not uisng $lines right nor testing for 'empty' (i.e.
having whitespace) <l> elements correctly.  The way I was trying was:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl=""; version="2.0">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:param name="input" />
<xsl:param name="output" />
<xsl:variable name="source1" select="$input"/>
<xsl:variable name="output1" select="$output"/>
<xsl:variable name="encoding" select="'iso-8859-1'"/>
<xsl:variable name="lines" as="element()*">
<xsl:for-each select="tokenize(unparsed-text($source1, $encoding),
			<l><xsl:value-of select="."/></l>

	<xsl:template name="main">
<xsl:result-document href = "{$output1}">
<title><xsl:value-of select="$lines/l[1]"/></title>
<xsl:if test="not(normalize-space($lines/l[2])='
')"><author><xsl:value-of select="$lines/l[2]"/></author></xsl:if>
<xsl:for-each-group select="$lines/l[position >2]"
group-starting-with="l[normalize-space(.)=' ']">
		<xsl:copy-of select="current-group()"/>


I hear mince pies calling....

James Cummings, Cummings dot James at GMail dot com

Current Thread