RE: [xsl] document() function and error-handling

Subject: RE: [xsl] document() function and error-handling
From: "Scott Trenda" <Scott.Trenda@xxxxxxxx>
Date: Fri, 4 Jan 2008 12:30:53 -0600
> On a different level, being not sure I read every single letter on
> thread yet, was it already proposed to use a proxy? Because with a
> (which has hardly anything to do with XSLT of course), you can just do

> whatever you want.

> I.e., suppose you create a proxy HTTP server that resides on the same
> server as your Coldfusion stuff, suppose that
> http://localhost:123456/proxy? runs a proxy script and that you call
> as http://localhost:123456/proxy?url= Now

> your proxy script must do two things:

>   1. test if the url exists and if not, reply with an XML compatible
>   2. test if the result is a valid XML document and if not reply with
> XML compatible error, if yes, reply with the XML result itself.

> By doing something like that, you've taken the burden of your XSLT and

> you do not need to result to complex platform specific solutions. In
> fact, the solution will be very portable (and is close to what you
> would've done if you implement the XmlResolver solution, which however

> is in practice much harder with MSXML alone).


Now I'm a little angry - that's the best solution that I've heard so
far, but it's so simple! Why didn't I think of that. It'll actually fit
in quite well with the flow of several other scripts in our system, and
will undoubtedly be useful in other places. A thousand thanks for the
suggestion, but damn I feel stupid after reading it. :)

I'd like to implement it somewhat like the MSSQL "FOR XML AUTO" error
messages, like so:
<?xml-result xml-status="0" http-status="404" description="File not
found" ?>
<?xml-result xml-status="0" http-status="200" description="Invalid XML
content" ?>
<?xml-result xml-status="1" ?><!-- retrieved document here -->

Would there be any reason *not* to include an <?xml-result?> PI in the
result document? As I understand it, this sort of thing is what PIs were
designed for. (And is it an XML faux pas to start the PI with "xml-"?)
The result effect I'd want is for the caller to be able to
apply-templates to document(...) or document(...)/* with little to no
variation in the transformation's behavior, but the script's result
would still be available, error or not. And the PI content could be
similarly passed down to the result document if desired:
  <template match="processing-instruction('xml-result')">
    <xsl:copy-of select="."/>

Just wondering if extraneous PIs in transformation source/result
documents are considered good coding convention or not. It'd be nice to
actually make use of them from time to time.

~ Scott

Current Thread