[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Select following siblings with constraints (a solution
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|