This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes problem with xsl:template and xsl:call-template Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "problem with xsl:template and xsl:call-template" Watch "problem with xsl:template and xsl:call-template" New topic
Author

problem with xsl:template and xsl:call-template

kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
Hi
in XSQL i am getting one row like this
<REASON_FOR_REJECTION>1.Overhead line is not existing in front of the premises,2.The distance from the pole to the serice is more than 30 meters.,3.Another service is existing in the same premises with arrears.</REASON_FOR_REJECTION>
In the above String for every comma i want to put <br>
the output should come like this:
1.Overhead line is not existing in front of the premises
2.The distance from the pole to the serice is more than 30 meters.
3.Another service is existing in the same premises with arrears
i have written xsl like this;i am getting this error;
XSQL-011: Error processing XSLT stylesheet: ../xsl/CMS48_RejectionLetter1.xsl
(Error) Template 'ROWSET/ROW/REASON_FOR_REJECTION' invoked but not defined.
wat's wrong with this code?
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java" version="1.0">
<xsl:template match="/">
<html>
<body Class='Ecrm_Body'>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="ROW">
<p>
<xsl:apply-templates select="REASON_FOR_REJECTION"/>
</p>
</xsl:template>

<xsl:template match="REASON_FOR_REJECTION">
<xsl aram name="REASON_FOR_REJECTION"/>
<xsl:variable name="year"
select="substring-before(.,',')"/>
<xsl:choose>
<xsl:when test="string-length($year) > 0">
<td><xsl:value-of select="$year"/></td>
<xsl:call-template name="ROWSET/ROW/REASON_FOR_REJECTION">
<xsl:with-param name="REASON_FOR_REJECTION">
<xsl:value-of select="substring-after($REASON_FOR_REJECTION,',')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl therwise>
<td><xsl:value-of select="$REASON_FOR_REJECTION"/></td>
</xsl therwise>

</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Most likely you need to change this line
<xsl:call-template name="ROWSET/ROW/REASON_FOR_REJECTION">
to
<xsl:call-template name="REASON_FOR_REJECTION">


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
i made two changes <xsl:call-template name="ROWSET/ROW/REASON_FOR_REJECTION"> to
<xsl:call-template name="REASON_FOR_REJECTION">
and also <xsl:tempalte name="REASON_FOR_REJECTION"> ;but it is not going into the 2nd template;
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
1. I changed the second template (<xsl:template match="ROW">) to

-- this is just an idiomatic way to apply a template to a piece of data eqursively.
2. I renamed REASON_FOR_REJECTION template to "FETCH_COMMA_SEPARATED_VALUES", this is a stylistical issue, it doesn't change the results at all. Templates are essentially functions, so it makes more sense to name them after what they do. On which particular piece of data they work, is irrelevant to their algorithm. For the same reason I changed the name of input parameter to INPUT_STRING. You can use this template or other pieces of data also!
So it became

I tested this on

and the output is

Hope this is what you need...
kesava, unfortunately your name doesn't comply with our official policy on registered names. Both first and last name are required. Please, take a moment and change your publicly displayed name.
Other than that we are glad to see you here!
[ April 23, 2003: Message edited by: Mapraputa Is ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with xsl:template and xsl:call-template