Subject: [xsl] XSL Word counting and Merging From: Mani Malarvannan <mani@xxxxxxxxxxxx> Date: Mon, 23 Dec 2002 09:52:14 -0600 |
Hello, I've a following XML. <?xml version="1.0" encoding="iso-8859-1"?> <search-result> <document-list> <document> <important> <p> <IMPORTANT>test1 test2 test3 test4 test5 test6</IMPORTANT> </p> <b> <IMPORTANT>test7</IMPORTANT> </b> <p> <b> <IMPORTANT>test8</IMPORTANT> </b> <IMPORTANT> test9 test10 <Hit n-wordpos="6879">Auto</Hit> test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 </IMPORTANT> </p> </important> </document> <document> <important> <p> <IMPORTANT>test1 test2 </IMPORTANT> <iref dest="59"> <IMPORTANT>test3</IMPORTANT> </iref> <IMPORTANT>) test4 test5 test6 test7 test8 test9 test10 <Hit n-wordpos="15570">Auto</Hit> test1 test2 test3 test4 test5 test6 test7 test8 test9 test10</IMPORTANT> </p> </important> </document> <document> <important> <p> <IMPORTANT>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 <Hit n-wordpos="19548">Auto</Hit>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10</IMPORTANT> </p> <p> <IMPORTANT>test1 test2 test3 test4 test5 test6 test7 test8</IMPORTANT> <scaps> <IMPORTANT>test9</IMPORTANT> </scaps> <IMPORTANT>test10<Hit n-wordpos="35689">Auto</Hit> test1 test2 test3 </IMPORTANT> <scaps> <IMPORTANT>test4</IMPORTANT> </scaps> <IMPORTANT>test5 test6 test7 <Hit n-wordpos="35696">Auto</Hit> test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 </IMPORTANT> </p> <p> <IMPORTANT>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 <Hit n-wordpos="39554">Auto</Hit> itest1 test2 test3 test4 test5 test6 test7 test8 test9 test10 </IMPORTANT> </p> <p> <IMPORTANT>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 <Hit n-wordpos="46008">Auto</Hit> test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 </IMPORTANT> </p> <p> <IMPORTANT>test1 test2 test3 test4 test5 test6 test7 test8 </IMPORTANT> <b> <IMPORTANT>test9 test10 <Hit n-wordpos="52292">Auto</Hit> </IMPORTANT> </b> <IMPORTANT> test1 test2 test3 test4 test5 test6 test7 test8 test9 test10</IMPORTANT> </p> <p> <IMPORTANT>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10<Hit n-wordpos="65109">Auto</Hit> test1 test2 test3 test4 test5 test6 test7 test8 test9 test10</IMPORTANT> </p> <b> <IMPORTANT>test1</IMPORTANT> </b> <b> <IMPORTANT>test2 test3</IMPORTANT> </b> <p> <IMPORTANT>test4 test5 test6 test7 test8 test9 test10 <Hit n-wordpos="77364">Auto</Hit> test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 </IMPORTANT> </p> </important> </document> </document-list> </search-result> I'm working in an application, when a user types in keywords will display 10 words that appears before the keyword and 10 words that appears after the keyword from a document. In a document there might be one or more hit words and the hit word is presented in <Hit> tag. The words that comes before and after the <Hit> word is presented in <IMPORTANT>. Some times all the words that comes before and after the keyword is presented in one <IMPORTANT> and some times it comes in several different <IMPORTANT> I want to combine the values of <IMPORTANT> that appears before and after <Hit> so that my output looks like ..test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 Auto test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 ... ..test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 Auto test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 ... Currently I've following XSL that produces the output but it is not combining the values of <IMPORTANT>, instead it outputs the values in a separate line. <xsl:template match="IMPORTANT"> <xsl:if test="$displaySnippets='true'"> <xsl:if test="position() < $numsnippets"> <br/>...<xsl:apply-templates/>... </xsl:if> </xsl:if> </xsl:template> <xsl:template match="Hit | important"> <xsl:choose> <xsl:when test="$displaySnippets='true'"> <xsl:if test="position() < $numsnippets"> <xsl:apply-templates/> </xsl:if> </xsl:when> <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> </xsl:choose> </xsl:template> I don't have any control on the XML format, so my choice is to modify the XSL so that I'll get the desired output. Thanks for the help. -Mani XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Adding namespaces to outp, Kevin Jones | Thread | [xsl] regarding unique nodes in a n, Laura |
Re: [xsl] Hot to get n records per , Prateek Gupta | Date | Re: [xsl] Performance issue XSL:FO, Oleg Tkachenko |
Month |