Subject: [xsl] Problem:Counting specific type of nodes lying in between two nodes in a tree From: Sanjukta Mitra <sanmit27@xxxxxxxxx> Date: Mon, 7 Feb 2005 07:03:59 -0800 (PST) |
Hi, I am having trouble constructing the XPath for this one. Can anyone help me with this? Thanks Sanjukta I am trying to accomplish the following 2 steps Step1:(this is working) The current node is a ptr here.I am trying to traverse back and find the first question whose parent is an yes answer. <xsl:param name="stop_question" select="./ancestor::decisiontree_question[parent::decisiontree_answer[@answer='yes']][1]"/> Eg : If my current node is ptr6, stop_question should give me Q1a( please refer to the source structure below) Step2: (this is not working) Defining the param Cnt that counts the number of No answers in between the current node(ptr) and stop_question. If the current node is ptr6 this should return 4 Heres the piece of code that is not working: <xsl:param name="Cnt" select="count(ancestor::decisiontree_answer[@answer='no'][ancestor::decisiontree_question[.=$stop_question]> 0])"/> Here is a sample structure of the source: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="file://localhost/C:/src/css/decisiontree_xml.css" type="text/css"?> <!DOCTYPE decisiontree SYSTEM "file://localhost/C:/src/dtd/decisiontree.dtd"> <decisiontree> <decisiontree_question short_question="Q1"> <instruction/> <decisiontree_answer answer="yes"> <decisiontree_question short_question="Q1A"> <instruction/> <decisiontree_answer answer="no"> <decisiontree_question short_question="Q1B"> <instruction/> <decisiontree_answer answer="no"> <decisiontree_question short_question="Q1C"> <instruction/> <decisiontree_answer answer="no"> <decisiontree_question short_question="Q1D"> <instruction/> <decisiontree_answer answer="no"> <enumerated_type_ptr ptr="ptr6"/> </decisiontree_answer> <decisiontree_answer answer="yes"> <enumerated_type_ptr ptr="ptr4"/> </decisiontree_answer> </decisiontree_question> </decisiontree_answer> <decisiontree_answer answer="yes"> <enumerated_type_ptr ptr="ptr3"/> </decisiontree_answer> </decisiontree_question> </decisiontree_answer> <decisiontree_answer answer="yes"> <enumerated_type_ptr ptr="ptr2"/> </decisiontree_answer> </decisiontree_question> </decisiontree_answer> <decisiontree_answer answer="yes"> <enumerated_type_ptr ptr="ptr1"/> </decisiontree_answer> </decisiontree_question> </decisiontree_answer> <decisiontree_answer answer="no"> <enumerated_type_ptr ptr="ptr5"/> </decisiontree_answer> </decisiontree_question> </decisiontree> __________________________________ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Move one node in xml down, Joris Gillis | Thread | Re: [xsl] Problem:Counting specific, Joris Gillis |
RE: [xsl] Decimal precision, Jim Neff | Date | Re: [xsl] Move one node in xml down, Mukul Gandhi |
Month |