xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prakash Sridharan <PSRIDHA...@selectica.com>
Subject RE: How to throw custom defined exceptions, warnings from xsl pag e?
Date Tue, 08 Oct 2002 08:04:03 GMT
Hi Simon,

I am giving a scenario in which I want to throw custom defined exceptions.  

The input xml looks like this,

<?xml version="1.0" encoding="UTF-8"?>

I am validating the data in the above xml using xsl.
Some of the validations are,
1.  Age should be greater than 18
2.  sex should be "m" or "f"

If the above conditions are not met, I want to throw some exceptions or
from the xsl.  After rendering, I shoud be able to access all the exceptions
warnings from my java program where I am calling this xsl transformation.

The xsl looks like this,

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="* | /">
	<xsl:template match="age">
			<xsl:when test="number(.) &gt; 18">
				<xsl:copy-of select="."/>
				<!-- throw exception here -->
	<xsl:template match="text() | @*">
		<xsl:copy-of select="."/>

Can you help me in this?

Thank you,

-----Original Message-----
From: Simon Kitching [mailto:simon@ecnetwork.co.nz]
Sent: Tuesday, October 08, 2002 2:31 AM
To: Prakash Sridharan
Cc: xalan-j-users@xml.apache.org
Subject: Re: How to throw custom defined exceptions, warnings from xsl

Hi Prakash,

Can you provide some more details about what you are trying to do?

Are you using standard xsl? In this case, what do you mean by "custom
defined exceptions"? Do you just mean generating your own error
messages? If this is the case, you can use <xsl:message> together with a
custom ErrorListener class.

Are you using some custom extension tags or functions, and want to
generate errors/exceptions from these? In this case, I can provide you
with some example code as I am doing this myself.



On Tue, 2002-10-08 at 05:43, Prakash Sridharan wrote:
> Hi all,
> In my project, I am doing the data validation in an xml through using xsl.
> I want to throw some
> custom defined exceptions and warnings from xsl page while rendering based
> on the validations.  
> Can anybody help me in doing this?
> Thank you,
> Prakash

View raw message