| 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','
?
')">
>  <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="http://www.w3.org/1999/XSL/Transform" 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:for-each>
</xsl:variable>
	<xsl:template name="main">
<xsl:result-document href = "{$output1}">
<poem>	
<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(.)=' ']">
	<lg>
		<xsl:copy-of select="current-group()"/>
	</lg>
	</xsl:for-each-group>
</poem>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
--------
I hear mince pies calling....
-james
--
James Cummings, Cummings dot James at GMail dot com
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| RE: [xsl] unparsed-text and for-eac, Michael Kay | Thread | Re: [xsl] unparsed-text and for-eac, James Cummings | 
| RE: [xsl] unparsed-text and for-eac, Michael Kay | Date | [xsl] Use for-each-group to elimina, cknell | 
| Month |