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

Re: unparsed-text and for-each-group

Subject: Re: unparsed-text and for-each-group
From: James Cummings <cummings.james@xxxxxxxxx>
Date: Wed, 21 Dec 2005 18:04:59 +0000
eac utf 8
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="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),
'&#13;?&#10;')">
			<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

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.