I assume that the differences between your input and output are
unintentional: that is, you don't really want the second line of the second
stanza repeated, and the third stanza omitted.
You can do this using the general approach you have taken, but surely
(a) in the initial tokenization you need to use two newlines as the
separator rather than a single newline.
(b) in the analyze-string, you need to use something like regex=".*\n" (or
alternatively, use flags="m").
An alternative approach is to split it first into a flat set of lines (using
tokenize($input, '\n')), and then use grouping (xsl:for-each-group) to
create the stanzas.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Byomokesh [mailto:bkesh(_at_)eztechgroup(_dot_)net]
Sent: 07 February 2007 10:30
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Problem in Poem
Hi All,
I have a big problems in poem coding.
My Input
========
Todo pasa y todo queda,
pero lo nuestro es pasar,
pasar haciendo caminos,
Nunca persequí la gloria,
ni dejar en la memoria
de los hombres mi canción;
Me gusta verlos pintarse
de sol y grana, volar
bajo el cielo azul, temblar
súbitamente y quebrarse...
I need Output
=============
<poem>
<stanza>
<line>Todo pasa y todo queda,</line>
<line>pero lo nuestro es pasar,</line>
<line>pasar haciendo caminos,</line>
</stanza>
<stanza>
<line>Nunca persequ la gloria,</line>
<line>ni dejar en la memoria</line>
<line>de los hombres mi cancin; </line>
<line>ni dejar en la memoria</line>
</stanza>
</poem>
Here is my XSLT
===============
<xsl:template match="P">
<poem>
<xsl:for-each select="tokenize(., '
')">
<xsl:text>
</xsl:text> <xsl:analyze-string
select="normalize-space(.)" regex=".{{1,80}}(\s|$)">
<xsl:matching-substring>
<line><xsl:value-of select="."/></line>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:for-each>
</poem>
</xsl:template>
In my XSL files output only line coding. But I m not success
to stanza coding. anyone help
Thanks and Regards
Byomokesh
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--