[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to show distinct node values?
At 2003-07-23 16:44 +0200, Poort, J. wrote:
I'm using a big XML file and want to transform the data by XSL I open the XML in IE 6.0 and say href="r_and_j.xslt". In r_and_j.xslt I enter the XSL-commands. Because you want this scoped within each scene, this can be easily and succinctly done with variables in about 15 instructions and handle all of the scenes in all of the acts. I tested this in IE6 successfully for your one act. I hope the answer below helps. ................. Ken
<xsl:output method="html"/> <xsl:template match="/"> <pre> <xsl:for-each select="/PLAY/ACT"> <xsl:text/>ACT <xsl:number format="I"/> <xsl:text>
</xsl:text> <xsl:for-each select="SCENE"> <xsl:text>	</xsl:text> <xsl:text/>SCENE <xsl:number format="I"/><xsl:text>
</xsl:text> <xsl:variable name="speeches" select=".//SPEECH"/> <xsl:for-each select="$speeches"> <xsl:if test="generate-id(.)= generate-id($speeches[SPEAKER=current()/SPEAKER])"> <xsl:text>		</xsl:text> <xsl:value-of select="SPEAKER"/> <xsl:text>	</xsl:text> <xsl:value-of select="count($speeches[SPEAKER=current()/SPEAKER] /LINE)"/> <xsl:text>
</xsl:text> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:for-each> </pre> </xsl:template> </xsl:stylesheet> T:\xsllist>type poort.xml <?xml version="1.0" standalone="yes"?><?xml-stylesheet type="text/xsl" href="r_and_j.xslt"?> <PLAY> <TITLE>The Tragedy of Romeo and Juliet</TITLE> <PLAYSUBT>ROMEO AND JULIET</PLAYSUBT> <ACT><TITLE>ACT I</TITLE> <SCENE><TITLE>SCENE I. Verona. A public place.</TITLE> <STAGEDIR>Enter SAMPSON and GREGORY, of the house of Capulet, armed with swords and bucklers</STAGEDIR> <SPEECH> <SPEAKER>SAMPSON</SPEAKER> <LINE>Gregory, o' my word, we'll not carry coals.</LINE> </SPEECH> <SPEECH> <SPEAKER>GREGORY</SPEAKER> <LINE>No, for then we should be colliers.</LINE> </SPEECH> <SPEECH> <SPEAKER>SAMPSON</SPEAKER> <LINE>I mean, an we be in choler, we'll draw.</LINE> </SPEECH> <SPEECH> <SPEAKER>GREGORY</SPEAKER> <LINE>Ay, while you live, draw your neck out o' the collar.</LINE> </SPEECH> <SPEECH> <SPEAKER>SAMPSON</SPEAKER> <LINE>'Tis all one, I will show myself a tyrant: when I</LINE> <LINE>have fought with the men, I will be cruel with the</LINE> <LINE>maids, and cut off their heads.</LINE> </SPEECH> <STAGEDIR>Enter ABRAHAM and BALTHASAR</STAGEDIR> <SPEECH> <SPEAKER>ABRAHAM</SPEAKER> <LINE>Do you bite your thumb at us, sir?</LINE> </SPEECH> <SPEECH> <SPEAKER>SAMPSON</SPEAKER> <LINE>I do bite my thumb, sir.</LINE> </SPEECH> <SPEECH> <SPEAKER>BENVOLIO</SPEAKER> <LINE>Part, fools!</LINE> <LINE>Put up your swords; you know not what you do.</LINE> </SPEECH> <STAGEDIR>Beats down their swords</STAGEDIR> <STAGEDIR>Enter TYBALT</STAGEDIR> <SPEECH> <SPEAKER>TYBALT</SPEAKER> <LINE>What, art thou drawn among these heartless hinds?</LINE> <LINE>Turn thee, Benvolio, look upon thy death.</LINE> </SPEECH> <SPEECH> <SPEAKER>BENVOLIO</SPEAKER> <LINE>I do but keep the peace: put up thy sword,</LINE> <LINE>Or manage it to part these men with me.</LINE> </SPEECH> <SPEECH> <SPEAKER>TYBALT</SPEAKER> <LINE>What, drawn, and talk of peace! I hate the word,</LINE> <LINE>As I hate hell, all Montagues, and thee:</LINE> <LINE>Have at thee, coward!</LINE> </SPEECH> <SPEECH> <SPEAKER>PRINCE</SPEAKER> <LINE>Rebellious subjects, enemies to peace,</LINE> <LINE>Profaners of this neighbour-stained steel,--</LINE> <LINE>Will they not hear? What, ho! you men, you beasts,</LINE> <LINE>That quench the fire of your pernicious rage</LINE> <LINE>With purple fountains issuing from your veins,</LINE> <LINE>On pain of torture, from those bloody hands</LINE> <LINE>Throw your mistemper'd weapons to the ground,</LINE> <LINE>And hear the sentence of your moved prince.</LINE> <LINE>Three civil brawls, bred of an airy word,</LINE> <LINE>By thee, old Capulet, and Montague,</LINE> <LINE>Have thrice disturb'd the quiet of our streets,</LINE> <LINE>And made Verona's ancient citizens</LINE> <LINE>Cast by their grave beseeming ornaments,</LINE> <LINE>To wield old partisans, in hands as old,</LINE> <LINE>Canker'd with peace, to part your canker'd hate:</LINE> <LINE>If ever you disturb our streets again,</LINE> </SPEECH> </SCENE> </ACT> </PLAY> T:\xsllist>saxon poort.xml r_and_j.xslt <pre>ACT I SCENE I SAMPSON 6 GREGORY 2 ABRAHAM 1 BENVOLIO 4 TYBALT 5 PRINCE 16 </pre> T:\xsllist>rem Done!
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) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|