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

Re: problem with processing nodes

Subject: Re: problem with processing nodes
From: Andreas Peter <info@xxxxxxxxxx>
Date: Wed, 19 Dec 2007 22:20:22 +0100
Re:  problem with processing nodes
Thanks Ken.

For future postings I will do my best. It is not very easy to decribe a problem in a foreign language :-)

I am very very thankful that volunteers take time to answer questions. Eventually I can take part in answering questions. But unfortuanately not now :-( The needed background and of course the needed practise are missing.

Greetings from Germany,
Andreas

G. Ken Holman schrieb:
At 2007-12-19 20:15 +0100, Andreas Peter wrote:
I have a problem with processing several nodes. My input document looks
like the following:
...
I use the following XSL for output:
...
The output should like this:

Here I'm stuck ... I cannot see why two <h2> elements are in the same <Ebene2> and I've tried many ways to get them both into one and I've given up:


<Ebene2>
<h2>1.2 Leben und Werk Ittmanns im C&#65533;berblick<fn>Die
biographischen Daten
beruhen auf einem Nachruf zu Ittmann (KCBhler-Meyer 1964), ...</fn></h2>
<p>Ittmann schilderte mitunter, wie er selbst wCBhrend der Reise auf
FuC&#65533;mCBrschen seine afrikanischen Begleiter befragte. ...</p>
<h2>1.3 Quellenlage, Eingrenzung, Aufbau und Methodik</h2>
<p>Aus Ittmanns reichhaltigem Schaffen galt es inhaltlich auszuwCBhlen
...</p>
</Ebene2>

I cannot take any more time to try and figure out the above, but for the rest, I think the code below does what you need.


Everything works fine except the <p>-elements from the
xsl:for-each-group. They are not processed properly.

Unfortunately, you don't explain what "properly" is, so I had to guess.


Any idea from the experts?

Making it a guessing game is not fun and it takes a lot of time ... in the future I suggest you put into words what you need, in addition to the data, so that volunteers don't have to guess. I cannot figure out why <p> elements are sometimes grouped and sometimes not. I added comments to explain the assertions I assumed.


Note the changes I made in the copying of node titles (your code was losing the <name_geo> structure), and in the composition of element names using an attribute value template (you had a redundant XPath if expression).

I hope the code below helps get you started, but I can't help with the above.

. . . . . . . . . . . Ken

p.s. also, my mailer does not handle UTF-8 well ... can you post examples with an XML declaration of ISO-8859-1 (Latin1) so that old mail systems don't get confused?


t:\ftemp>type andreas.xml <?xml version="1.0" encoding="UTF-8"?> <Root> <h01>Evangelium, afrikanisches Volkstum und geistiger Volksbesitz im Denken des Missionars Johannes Ittmann</h01> <h02>bis zum ersten groen <name_geo>Jamaika</name_geo>-Manuskript (ca. 1943) im Zusammenhang der deutschen missionstheologischen Debatte 19091940</h02> <h03>Magisterschrift</h03> <p>zum Erwerb des Mag. theol.</p> <p>nach der Ordnung der</p> <bildunterschrift> <p>Johannes Ittmann (18851963)</p> </bildunterschrift>

<h1>1. Einleitung</h1>
<h2>1.1 Gott kommt frAOher als der
Missionar</h2>
<p>Gott kommt frAOher als der
Missionar so titelt ein Buch des
Befreiungstheologen Leonardo
Boff (1992). ...</p>
<p_e>Ittmann steht im Kontext der deutschen Missionstheologie seiner
Zeit, die davon ausgeht,
da das Volkstum
...</p_e>
<h2>1.2 Leben und Werk Ittmanns im berblick<fn>Die
biographischen Daten
beruhen auf einem
Nachruf zu Ittmann (KA?hler-Meyer 1964), ...</fn>
</h2>
<p>Ittmann schilderte mitunter, wie er selbst whrend der Reise auf
FuArschen seine
afrikanischen Begleiter befragte. ...</p>
<h2>1.3 Quellenlage, Eingrenzung, Aufbau und Methodik</h2>
<p>Aus Ittmanns reichhaltigem Schaffen galt es inhaltlich auszuwhlen
...</p>

<h1>2. Gott kommt frAOher als der
Missionar Inwiefern?</h1>
<h2>2.1 Einleitendes</h2>
<p>Gott kommt frAOher als der
Missionar so habe ich mit Leonardo
Boff
in der Einleitung
Ittmanns...</p>
<h3>2.1.1 Grobgestalt</h3>
<p>Die etwa 200 Seiten des Manuskriptes gliedern sich in eine Einleitung
von sechs Seiten und
vier Hauptteile:</p>
<h3>2.1.2 Ziele und Zielgruppen</h3>
<p>In der EinfAOhrung {I-VI} nennt Ittmann fAOnf Zielgruppen und
entsprechende Ziele:</p>
<h3>2.1.3 Methodenreflexion</h3>
<p>Gerade der letzte Punkt fordert ihn zur Klarlegung seiner Methode:
...</p>
<h4>Zu B. Leibesleben zwischen Geburt und Tod {14-24}</h4>
<p>Hier kommen beide zunA?chst auf die Beschneidung zu sprechen.
Johanssen (1931, 199-201)
...</p>
</Root>
t:\ftemp>type andreas.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/>


<xsl:template match="/">
<Teil>
<xsl:apply-templates select="Root"/>
</Teil>
</xsl:template>

<xsl:template match="Root">
<Titelei>
<xsl:call-template name="titelei"/>
</Titelei>
<inhalt>
<xsl:call-template name="inhalt"/>
</inhalt>
</xsl:template>

<xsl:template name="titelei">
<xsl:param name="t" select="1"/>
<xsl:param name="nodes" select="*"/>
<!--group according to the expected level-->
<xsl:for-each-group select="$nodes"
group-starting-with="*[name()=concat('h0',$t)]">
<xsl:choose>
<xsl:when test="name()=concat('h0',$t)">
<xsl:element name="h0{$t}">
<xsl:copy-of select="node()"/>
</xsl:element>
<!--only copy nodes from the expected level-->
<xsl:choose>
<xsl:when test="not(current-group()[position()>1]
[starts-with(local-name(.),'h0')])">
<!--there are no deeper levels, so copy everything up
until the next heading-->
<xsl:for-each-group select="current-group()[position()>1]"
group-starting-with="*[starts-with(local-name(.),'h')]">
<xsl:if test="position()=1">
<xsl:copy-of select="current-group()"/>
</xsl:if>
</xsl:for-each-group>
</xsl:when>
<xsl:otherwise>
<!--there are deeper levels, so go deep-->
<xsl:call-template name="titelei">
<xsl:with-param name="t" select="$t+1"/>
<xsl:with-param name="nodes"
select="current-group()[position()!=1]"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>

<xsl:template name="inhalt">
<xsl:param name="i" select="1"/>
<xsl:param name="nodes" select="*"/>
<!--group according to the expected level-->
<xsl:for-each-group select="$nodes"
group-starting-with="*[name()=concat('h',$i)]">
<xsl:choose>
<xsl:when test="name()=concat('h',$i)">
<xsl:element name="Ebene{$i}">
<xsl:element name="h{$i}">
<xsl:copy-of select="node()"/>
</xsl:element>
<!--only copy nodes from the expected level up
until the next heading-->
<xsl:for-each-group select="current-group()[position()>1]"
group-starting-with="*[starts-with(local-name(.),'h')]">
<xsl:if test="position()=1">
<xsl:copy-of select="current-group()"/>
</xsl:if>
</xsl:for-each-group>
<xsl:if test="current-group()[position()>1]
[starts-with(local-name(.),'h')]">
<!--there are deeper levels, so go deep-->
<xsl:call-template name="inhalt">
<xsl:with-param name="i" select="$i+1"/>
<xsl:with-param name="nodes"
select="current-group()[position()!=1]"/>
</xsl:call-template>
</xsl:if>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
t:\ftemp>call xslt2 andreas.xml andreas.xsl andreas-out.xml

t:\ftemp>type andreas-out.xml
<?xml version="1.0" encoding="UTF-8"?>
<Teil>
<Titelei>
<h01>Evangelium, afrikanisches Volkstum und geistiger Volksbesitz im
Denken des Missionars
Johannes Ittmann</h01>
<h02>bis zum ersten groen
<name_geo>Jamaika</name_geo>-Manuskript (ca.
1943) im Zusammenhang
der deutschen missionstheologischen Debatte 19091940</h02>
<h03>Magisterschrift</h03>
<p>zum Erwerb des Mag. theol.</p>
<p>nach der Ordnung der</p>
<bildunterschrift>
<p>Johannes Ittmann (18851963)</p>
</bildunterschrift>
</Titelei>
<inhalt>
<Ebene1>
<h1>1. Einleitung</h1>
<h2>1.1 Gott kommt frAOher als der
Missionar</h2>
<p>Gott kommt frAOher als der
Missionar so titelt ein Buch des
Befreiungstheologen Leonardo
Boff (1992). ...</p>
<p_e>Ittmann steht im Kontext der deutschen Missionstheologie seiner
Zeit, die davon ausgeht,
da das Volkstum
...</p_e>
<Ebene2>
<h2>1.1 Gott kommt frAOher als der
Missionar</h2>
<p>Gott kommt frAOher als der
Missionar so titelt ein Buch des
Befreiungstheologen Leonardo
Boff (1992). ...</p>
<p_e>Ittmann steht im Kontext der deutschen Missionstheologie seiner
Zeit, die davon ausgeht,
da das Volkstum
...</p_e>
</Ebene2>
<Ebene2>
<h2>1.2 Leben und Werk Ittmanns im berblick<fn>Die
biographischen Daten
beruhen auf einem
Nachruf zu Ittmann (KA?hler-Meyer 1964), ...</fn>
</h2>
<p>Ittmann schilderte mitunter, wie er selbst whrend der Reise auf
FuArschen seine
afrikanischen Begleiter befragte. ...</p>
</Ebene2>
<Ebene2>
<h2>1.3 Quellenlage, Eingrenzung, Aufbau und Methodik</h2>
<p>Aus Ittmanns reichhaltigem Schaffen galt es inhaltlich auszuwhlen
...</p>
</Ebene2>
</Ebene1>
<Ebene1>
<h1>2. Gott kommt frAOher als der
Missionar Inwiefern?</h1>
<h2>2.1 Einleitendes</h2>
<p>Gott kommt frAOher als der
Missionar so habe ich mit Leonardo
Boff
in der Einleitung
Ittmanns...</p>
<Ebene2>
<h2>2.1 Einleitendes</h2>
<p>Gott kommt frAOher als der
Missionar so habe ich mit Leonardo
Boff
in der Einleitung
Ittmanns...</p>
<Ebene3>
<h3>2.1.1 Grobgestalt</h3>
<p>Die etwa 200 Seiten des Manuskriptes gliedern sich in eine Einleitung
von sechs Seiten und
vier Hauptteile:</p>
</Ebene3>
<Ebene3>
<h3>2.1.2 Ziele und Zielgruppen</h3>
<p>In der EinfAOhrung {I-VI} nennt Ittmann fAOnf Zielgruppen und
entsprechende Ziele:</p>
</Ebene3>
<Ebene3>
<h3>2.1.3 Methodenreflexion</h3>
<p>Gerade der letzte Punkt fordert ihn zur Klarlegung seiner Methode:
...</p>
<Ebene4>
<h4>Zu B. Leibesleben zwischen Geburt und Tod {14-24}</h4>
<p>Hier kommen beide zunA?chst auf die Beschneidung zu sprechen.
Johanssen (1931, 199-201)
...</p>
</Ebene4>
</Ebene3>
</Ebene2>
</Ebene1>
</inhalt>
</Teil>
t:\ftemp>rem Done!



--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds: publicly-available developer resources and training
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal

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.