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

RE: null call of document function

Subject: RE: null call of document function
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 8 Apr 2007 22:55:35 +0100
RE:  null call of document function
Sorry, but advising on application design is much harder than advising on
coding or debugging, and I really don't like doing it without knowing a lot
more than this about your requirements and constraints. And it then becomes
a consultancy assignment rather than a simple question+answer on a forum.

It's easy to spot when someone is doing things the wrong way, it's sometimes
much harder to identify the right way.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Steve [mailto:subsume@xxxxxxxxx] 
> Sent: 08 April 2007 01:47
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  null call of document function
> 
> Maybe you could give me some additional guidance? My 
> situation is this:
> 
> I have a sql table 'alerts' which contains system messages to 
> be delivered to the user.
> 
> A call to my xsl template "getAlerts" calls a script which 
> serves these alerts up as XML and then clears them from the table.
> 
> In some cases I want a file my user is viewing to generate an alert.
> My idea was to use the document function to insert the alert, 
> and then later in the script it would be available for the 
> getAlerts template.
> 
> Are you suggesting it would be wiser to insert this Alert in 
> my processing script pre-transform? Some other suggestion?
> 
> -Steve
> 
> On 4/7/07, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > > What if I want to make a call to the document() function 
> but I don't 
> > > expect any value?
> >
> > That presumably means you expect the call to have side-effects.
> >
> > A call on the document function is analagous to an HTTP GET 
> request, 
> > and it's considered bad form for GET requests to have side effects:
> >
> > http://www.w3.org/2001/tag/doc/whenToUseGet.html
> >
> > At the XSLT level, calling document() and expecting 
> side-effects has 
> > all the problems associated with extensions functions that 
> have side 
> > effects, notably that the call is liable to be optimized 
> away if the 
> > result isn't used. In fact it's worse than extension 
> functions, because:
> >
> > (a) with extension functions, the optimizer might if you're 
> lucky take 
> > into account the possibility that the call has 
> side-effects; with the 
> > document() function this is unlikely
> >
> > (b) the semantics of the document() function essentially 
> say that if 
> > you make the same call twice with the same URI, it only 
> gets executed once.
> >
> > In short - don't do it.
> >
> > Michael Kay
> > http://www.saxonica.com/

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.