Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Select following siblings with constraints (a solution)

From: mas christ <mas_christ@----------->
To:
Date: 2/4/2009 11:50:00 PM
Wednesday February 4 2009

This may be an answer or a help to the following I found at Altova Mailing
List Archives entitled, "select immediately following siblings with
constraints"
http://www.altova.com/list/xsl-list/200602/msg1000146300.html
-------------
Problem: Select following siblings with constraints.
-------------
Theory solution: use the xsl:generate-id() function on the node that preceeds
the following siblings you want to select.  Have the following siblings copy
that id.
-------------
Working solution:  The following two xsl stylesheets (convert.xsl and
convertstage2.xsl) put the v nodes belonging to its' chapter into the
bookChapter node (after bookChapter was changed into a chapter node).  The
generate-id() function was not needed because the bookChapter node already has
unique information.
-------------
The demo.xml follows:
-------------


Isaiah
The Book of the Prophet Isaiah
Chapter 1
Judah's rebellion -- Promises and threatenings.
1 The vision of Isaiah the son of Amoz, which he saw concerning Judah and
Jerusalem in the days of Uzziah, Jotham, Ahaz, and Hezekiah, kings of Judah.
2 Hear, O heavens, and give ear, O earth; for the Lord hath spoken; I have
nourished and brought up children, and they have rebelled against me.
Chapter 2
The coming of Christ's kingdom -- Effects of God's majesty.
1 The word that Isaiah the son of Amoz saw concerning Judah and Jerusalem.
2 And it shall come to pass in the last days when the mountain of the Lord's
house shall be established in the top of the mountains, and shall be exalted
above the hills, and all nations shall flow unto it;
Chapter 3
The sin of the people -- The oppression of the rulers -- The judgments for
pride.
1 For, behold, the Lord, the Lord of hosts, doth take away from Jerusalem and
from Judah the stay and the staff, the whole staff of bread, and the whole
stay of water,
2 The mighty man, and the man of war, the judge, and the prophet, and the
prudent, and the ancient,

-------------
The following are the commands (demo.sh) used to make the final document:
-------------
find . -iname "demo.xml" -exec sed -i "s@xxxxxxxx@c...@g" {} ';'

xsltproc demo.xml -o demo.xml --norman

find . -iname "demo.xml" -exec sed -i "s@@@g" {} ';'

xsltproc demo.xml -o demo.xml --norman

#the following sed command removes space at the beginning of lines:
sed -i 's/^[ \t]*//;s/[ \t]*$//' isaiah.xml;
-------------
The convert.xsl follows:
-------------
























-------------
The convertstage2.xsl follows:
-------------

























-------------
Final result follows (v nodes have been moved into chapter nodes):
-------------


Isaiah
The Book of the Prophet Isaiah

1
Judah's rebellion -- Promises and threatenings.
1 The vision of Isaiah the son of Amoz, which he saw concerning Judah and
Jerusalem in the days of Uzziah, Jotham, Ahaz, and Hezekiah, kings of Judah.
2 Hear, O heavens, and give ear, O earth; for the Lord hath spoken; I have
nourished and brought up children, and they have rebelled against me.


2
The coming of Christ's kingdom -- Effects of God's majesty.
1 The word that Isaiah the son of Amoz saw concerning Judah and Jerusalem.
2 And it shall come to pass in the last days when the mountain of the Lord's
house shall be established in the top of the mountains, and shall be exalted
above the hills, and all nations shall flow unto it;


3
The sin of the people -- The oppression of the rulers -- The judgments for
pride.
1 For, behold, the Lord, the Lord of hosts, doth take away from Jerusalem and
from Judah the stay and the staff, the whole staff of bread, and the whole
stay of water,
2 The mighty man, and the man of war, the judge, and the prophet, and the
prudent, and the ancient,


-------------
Note:  I don't know how to make it work with a single xsl file yet.
-------------
libxslt 1.1.20 was used.
-------------


_________________________________________________________________
Windows Live: E-mail. Chat. Share. Get more ways to connect.
http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_02200
9


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent