[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Incrementing position in the tree midstream (Part 3)
Hi Andreas (and all), What I have is a really flat XML file. "test-plan" is the bottom level. There are several hundred of "object" within "test-plan." Each "object" has 30-40 odd items under it including "objecttext" and the others I mentioned. However, I will have one or more tables buried throughout the XML. Starting in one instance of "object" and running for 20-30 objects then ending. So my table building routine needs to find the related "objecttext"s in that table but not further instances of tables. I think I can do that by having two tests in the count command you mention -- count(following::objecttext[.='.0-1.0']) How would that be written? count(following::objecttext[.= 'string1' & 'string2']) ?? And once I have the count, I use that in a for-each from '.' to following less than count, to output the cells? <xsl:for-each select=". | following::objecttext[position()< <<insert count command here or a variable??>>]"> ^^ or following-sibling?? <xsl:copy-of select="."/> </xsl:for-each> Thanks again, Andrew ps This makes my old brain hurt... :) Andrew C. Durston Smiths Aerospace Electronic Systems - Grand Rapids 616.241.8715 andrew.durston@xxxxxxxxxxxxxxxxxxxx Date: Thu, 15 Apr 2004 20:37:01 +0200 To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx> Subject: RE: Incrementing position in the tree midstream (Part 2) Message-ID: <CIEIIKAKHEBMGMANDDFOMEGOCLAA.a_l.delmelle@xxxxxxxxxx> > -----Original Message----- > From: Durston, Andrew (AGRE) > Hi, <snip /> > I am basically getting confused in how to count the occurances > down the chain of siblings (all objecttexts under all objects > under test-plan). > What exactly do you need? If, while processing an objecttext node (the objecttext matching template or an encompassing xsl:for-each) you need the number of objecttexts having a certain content ('.0-1.0'), that would be count(ancestor::test-plan/object/objecttext[.='.0-1.0']) for the number of all preceding- or following objecttexts in the document, this would become count(preceding::objecttext[.='.0-1.0']) count(following::objecttext[.='.0-1.0']) The *-sibling axes return only nodes from the same object parent (my guess is that this is one of the things causing your confusion?) xsl:number offers a very interesting and highly configurable alternative... For all objecttext nodes in the document, no matter what level <xsl:number count="objecttext[.='.0-1.0']" format="1. " level="any" /> For all objecttext nodes, starting from the current test-plan (if there are more than one in the document) <xsl:number count="objecttext[.='.0-1.0']" from="test-plan" format="1. " level="any" /> This should rid you of having to do the counting yourself (in case there are more than one test-plan in your source document, the XPath needed to feed to count() will obviously become more complicated..) Hope this helps! Cheers, Andreas ------------------------------ ****************************************** The information contained in, or attached to, this e-mail, may contain confidential information and is intended solely for the use of the individual or entity to whom they are addressed and may be subject to legal privilege. If you have received this e-mail in error you should notify the sender immediately by reply e-mail, delete the message from your system and notify your system manager. Please do not copy it for any purpose, or disclose its contents to any other person. The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. The recipient should check this e-mail and any attachments for the presence of viruses. The company accepts no liability for any damage caused, directly or indirectly, by any virus transmitted in this email. ******************************************
|
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
|