[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

joining the values of a tag

Subject: joining the values of a tag
From: Mani Malarvannan <mani@xxxxxxxxxxxx>
Date: Thu, 2 Jan 2003 08:15:29 -0600
test1 test2 test3 test4
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() &lt; $ 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() &lt; $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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.