Hi,
I have input XML that is flat and I am trying to group on one of the
elements. I am able to group, but I don't know how to get the text nodes
from the group. Here is an input snippet:
<?xml version="1.0" encoding="UTF-8"?>
<div type="book" osisID="Matt" canonical="true">
<milestone type="x-usfm-toc1" n="El Evangelio De Nuestro Señor Jesu
Cristo Según San Mateo" />
<milestone type="x-usfm-toc2" n="San Mateo" />
<milestone type="x-usfm-toc3" n="Mat" />
<!-- mt --><title type="main">EL EVANGELIO DE NUESTRO SEÑOR JESU CRISTO
SEGÚN SAN MATEO</title>
<chapter sID="Matt.1" osisID="Matt.1" n="1" />
<!-- cl --><milestone type="x-chapterLabel" n="CAPITULO 1" />
<verse sID="Matt.1.1" n="1" />Libro de la generación de Jesu Cristo,
hijo de David, hijo de Abraham.
<verse eID="Matt.1.1" />
<verse sID="Matt.1.2" n="2" />Abraham engendró a Isaac; e Isaac engendró
a Jacob; y Jacob engendró a Júdas, y a sus hermanos;
<verse eID="Matt.1.2" />
<verse sID="Matt.1.3" n="3" />Y Júdas engendró de Tamar a Fares y a
Zara; y Fares engendró a Esrom; y Esrom engendró a Aram;
<verse eID="Matt.1.3" />
<verse sID="Matt.1.4" n="4" />Y Aram engendró a Aminadab; y Aminadab
engendró a Naasón; y Naasón engendró a Salmón;
<verse eID="Matt.1.4" />
<verse sID="Matt.1.5" n="5" />Y Salmón engendró de Raab a Booz; y Booz
engendró de Rut a Obed; y Obed engendró a Jessé;
<verse eID="Matt.1.5" />
<verse sID="Matt.1.6" n="6" />Y Jessé engendró al rey David; y el rey
David engendró a Salomón de la <transChange type="added">que fue
mujer</transChange> de Urías;
<verse eID="Matt.1.6" />
</div>
My current stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="text"/>
<xsl:template match="/div[@osisID='Matt']">
<xsl:for-each-group select="*" group-starting-with="verse[@sID]">
<xsl:apply-templates select="current-group()[self::title]"/>
<xsl:apply-templates select="current-group()[not(self::title or
self::verse[@eID])]"/>
</xsl:for-each-group>
</xsl:template>
<xsl:template match="chapter[@n]">
<xsl:text>Capitulo </xsl:text><xsl:value-of
select="@n"/><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="verse[@n]">
<xsl:value-of select="@n"/><xsl:text>
</xsl:text><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="title">
<xsl:apply-templates/><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
My output will be text; here is the current output:
EL EVANGELIO DE NUESTRO SEÑOR JESU CRISTO SEGÚN SAN MATEO
Capitulo 1
1
2
3
4
5
6
que fue mujer
Of course, I want the text nodes as well. A slight wrinkle is that I may
want to preserve the tagging around any children of the text nodes, like
this (verse 6):
EL EVANGELIO DE NUESTRO SEÑOR JESU CRISTO SEGÚN SAN MATEO
Capitulo 1
1 Libro de la generación de Jesu Cristo, hijo de David, hijo de Abraham.
2 Abraham engendró a Isaac; e Isaac engendró a Jacob; y Jacob engendró a
Júdas, y a sus hermanos;
3 Y Júdas engendró de Tamar a Fares y a Zara; y Fares engendró a Esrom; y
Esrom engendró a Aram;
4 Y Aram engendró a Aminadab; y Aminadab engendró a Naasón; y Naasón
engendró a Salmón;
5 Y Salmón engendró de Raab a Booz; y Booz engendró de Rut a Obed; y Obed
engendró a Jessé;
6 Y Jessé engendró al rey David; y el rey David engendró a Salomón de la
<transChange type="added">que fue mujer</transChange> de Urías;
Thank you in advance.
Rick
Rick Quatro
Carmen Publishing Inc.
rick(_at_)frameexpert(_dot_)com
585-366-4017
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--