Can xsl throw an exception when value-of xpath does not exist?

P

Patrick TJ McPhee

[collection of syntax errors elided]


% i am merely requesting that xslt have the same error checking
% capabilities as just about every other language out there (it does in

Well, you're not though. XPath (not XSLT) does catch syntax
errors. What it doesn't catch, like any other language, is incorrect
logic and incorrectly typed data. In this case, you're asking for
an exception to be thrown when an XPath expression returns
an empty node set, and the connection between that and incorrectly
typed expressions is tenuous at best.

% I believe that xslt is the way of the future of development, and am

The future of development of what, exactly? I was thinking about this
problem as I napped through a matinee screening of the Yu Gi Oh! movie
yesterday, and it seems to me that the solution to this problem in XSLT
is the same as the solution in every other language. When you perform a
query against an external data source and you want to throw an exception
when it doesn't return a value, you test for that condition and handle
it the way you want to. If it's too difficult to do this in XSLT, then
perhaps that's a sign that there's a more fundamental problem with XSLT.
 
I

inquirydog


Sorry I didn't respond all week. I was away on vacation and got
some great relaxation. For now I am back to my xml work....
% i am merely requesting that xslt have the same error checking
% capabilities as just about every other language out there (it does in

Well, you're not though. XPath (not XSLT) does catch syntax
errors. What it doesn't catch, like any other language, is incorrect
logic and incorrectly typed data. In this case, you're asking for
an exception to be thrown when an XPath expression returns
an empty node set, and the connection between that and incorrectly
typed expressions is tenuous at best.


Most other languages do more than catch syntax errors though
(ie- I specifically put in the java example to show such an example- a
missed exception.) I personally believe that the more error checking
the better(sheesh, if I could just get the computer to write the code
for me I would), and think I have found an example of a typical error
that I believe that xslt doesn't catch properly (without way too much
unnecessary work). And I have personally been burned by this very
error in the past. The small change to xslt that I suggested in this
thread (or something like it) would certainly make it easy to avoid
this in the future.

Just to reiterate what I have written earlier, I don't want
xslt to throw an exception for all empty node sets returned, but I am
calling for a simple way to tell xslt to do that if requested.
% I believe that xslt is the way of the future of development, and am

The future of development of what, exactly?

Software development, of most kinds. I am of the opinion that
xslt is going to revolutionize the way software is written. Unlike c,
c++, java, perl, python, ml and other functional languages, etc., xslt
is a truely data-dentric language. I can do in a page of xslt what
might take double that in the other languages written. xslt is to c,
c++, java what jsp is to servlets, except that jsp's only get half the
picture (easy outputs html data, doesn't easily manipulate data).
Since I've learned about xslt in the last year roughly half of my
programming tasks have turned over to it. And xslt isn't even fully
polished yet, once it is it will be much nicer. The very stuff I am
writting about in this thread needs to get fixed before xslt is going
to be widely adopted as a replacement for other languages.
I was thinking about this
problem as I napped through a matinee screening of the Yu Gi Oh! movie
yesterday, and it seems to me that the solution to this problem in XSLT
is the same as the solution in every other language. When you perform a
query against an external data source and you want to throw an exception
when it doesn't return a value, you test for that condition and handle
it the way you want to. If it's too difficult to do this in XSLT, then
perhaps that's a sign that there's a more fundamental problem with XSLT.

It isn't fundamental. I am not suggesting anything that a
simple attribute addition couldn't fix, although I do think that the
particular change needs some discussion so that it solves the problem
as fully as possible.

thanks
-I
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top