Subject: [xsl] joining the values of a tag From: Mani Malarvannan <mani@xxxxxxxxxxxx> Date: Thu, 2 Jan 2003 08:15:29 -0600 |
Hello, For following XML How can I do word counting and joining the values that comes in <IMPORTANT> <?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 test8</IMPORTANT> </b> <p> <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 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="65109">Auto</Hit> test1 test2 test3 test4 test5 test6 test7 test8 test9 test10</IMPORTANT> </p> </important> </document> </document-list> </search-result> >From the above XML I?d like to combine the values of <IMPORTANT> ten words that appears before and 10 words that appear after <Hit> under the SAME PARENT. So under each <document>/<important> I?d like to display the values of <IMPORTANT> in a new line that begins and ends with ???. The output should look as specified below: desired output ..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 like ..test1 test2 test3 test4 test5 test6... ..test7... But I want my output to look like the one specified under "desired output" current XSL <xsl:template match="IMPORTANT"> <xsl:if test="$ displayImportants ='true'"> <xsl:if test="position() < $ important"> <br/>...<xsl:apply-templates/>... </xsl:if> </xsl:if> </xsl:template> <xsl:template match="Hit | important"> <xsl:choose> <xsl:when test="$displayImportants='true'"> <xsl:if test="position() < $important"> <xsl:apply-templates/> </xsl:if> </xsl:when> <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> </xsl:choose> </xsl:template> What should I change in my current XSL so that I get the desired output? Thanks for the help. -Mani XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|