[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

how can i implement find & replace functionality in XSL

Asked by Anandthirtha in Extensible Markup Language (XML)


Dear all,

I have an xml file as

<Word_of_day>
<Document_id>
  1
<title> sample title </title>
<source> Sample source </source>
<description> sample description approximately 3 paragraphs of data </description>

</Document_id>

....

..
.
....

</Word_of_day>

----------------------------------------------------------------------------------------------------------------
I have written the xsl file that searchs & replaces the text ie

it searches for "brk" word within the <Description> tag & replaces with "<br/>" tag.

But when i try to transform the xml file to html thru the below mentioned xsl file,

it will not replace "brk" with "<br/>"...

can anybody help........

the xsl file is as follows :

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>


<xsl:template name="globalReplace">
  <xsl:param name="outputString"/>
  <xsl:param name="target"/>
  <xsl:param name="replacement"/>
  <xsl:choose>
    <xsl:when test="contains($outputString,$target)">
   
      <xsl:value-of select=
        "concat(substring-before($outputString,$target),
               $replacement)"/>
      <xsl:call-template name="globalReplace">
        <xsl:with-param name="outputString"
             select="substring-after($outputString,$target)"/>
        <xsl:with-param name="target" select="$target"/>
        <xsl:with-param name="replacement"
             select="$replacement"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$outputString"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="text()">
  <xsl:call-template name="globalReplace">
  <xsl:with-param name="outputString" select="."/>
  <xsl:with-param name="target" select="'brk'"/>
  <xsl:with-param name="replacement" select="'&lt;br/&gt;'"/>
  </xsl:call-template>
</xsl:template>

<xsl:template match="Word-of-day/Document_id/Description/text()">
  <xsl:call-template name="globalReplace">
  <xsl:with-param name="outputString" select="."/>
  <xsl:with-param name="target" select="'brk'"/>
  <xsl:with-param name="replacement" select="'&lt;br/&gt;'"/>
  </xsl:call-template>
</xsl:template>


<xsl:template match="/">
  <html>
  <body>

          <table border="1">
                  <tr bgcolor="#9acd32">

<!--<xsl:for-each select="Word_of_day/Document_id[position()>last()-5]">-->
<xsl:for-each select="Word_of_day/Document_id">
      <xsl:sort select="Document_id" order="descending"/>
      <tr>
           
<td>
<a target='new'><xsl:attribute name='href'>description.htm#<xsl:value-of select="text()"/></xsl:attribute><xsl:value-of select="Title"/></a>
</td>
     </tr>
</xsl:for-each>
 </tr>
    </table>
 
  </body>
  </html>

</xsl:template>

</xsl:stylesheet>
--------------------------------------------------------------------------------------------------------------------

[+][-]04/26/04 12:03 AM, ID: 10916001Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Extensible Markup Language (XML)
Sign Up Now!
Solution Provided By: zulu_11
Participating Experts: 2
Solution Grade: A
 
[+][-]04/25/04 11:56 PM, ID: 10915968Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/26/04 05:49 AM, ID: 10917887Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/26/04 07:14 AM, ID: 10918622Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/26/04 07:24 AM, ID: 10918726Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/16/04 05:09 AM, ID: 12592982Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11/20/04 01:15 AM, ID: 12632880Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92