Re: [xsl] problem: getting link text without document() function

Subject: Re: [xsl] problem: getting link text without document() function
From: "Trevor Nicholls trevor@xxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Sep 2018 11:29:05 -0000
Thanks for such a fast response!

> What kind of URI are you supplying to document()? Are you trying to get a
document from the server using HTTP, or a document in the local filestore of
the client machine?

Always from the local filesystem. The parameter will typically have a value
like "../manual/chapter.xml#section-id", i.e. relative to the XML document
which is being edited.

> You could consider using Saxon-JS, which supports asynchronous HTTP
requests to get resources (and also supports XSLT 3.0 rather than 1.0)

I wish.

As it happens the documents are viewed in html in the browser of the user's
choice, and there is an edit function which loads Xopus into the browser and
runs its own stylesheets and javascript to manage editing. I have no control
over what Xopus does other than through the document schema and the xsl
stylesheet that renders the XML as html (and that's the piece that doesn't
like document() in a non-IE browser). So I'm a bit limited in my options.

cheers
T

-----Original Message-----
From: Michael Kay mike@xxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> 
Sent: Tuesday, 11 September 2018 23:17
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] problem: getting link text without document() function


> 
> This list seems to have gone dormant but here goes

I think most of the simple coding questions that used to dominate this list
are now posted on StackOverflow, which benefits from much better search and
filtering options. I'm told that some people get great kudos from the
brownie points that StackOverflow awards its members.
> 
> I have a working XSLT 1 stylesheet which determines the text to insert 
> in hyperlinks by identifying the linked elements in separate 
> documents. I'm now incorporating it into an application which uses 
> Xopus to edit a source XML document, and I have discovered that the
stylesheet is only usable in IE.
> Unfortunately it barfs in Chrome and Firefox, because whatever XSL 
> processor they use in those browsers does not support document(). The 
> Xopus documentation implies that whatever I am trying to achieve in 
> this stylesheet could be achieved using XIncludes (but they don't 
> supply a useful example for my requirement).

What kind of URI are you supplying to document()? Are you trying to get a
document from the server using HTTP, or a document in the local filestore of
the client machine?

The problem with document() in client-side transformations is (a) requests
to the server will typically be synchronous, which is bad news in the
browser; also you get into difficulties with cross-site scripting; (b)
requests to get files from the client machine are usually banned for
security reasons, though you may be abe to override the security settings.
> 
> I have to concede that I was even less informed when I wrote this 
> stylesheet than I am now, so it may be horribly over-engineered and 
> misguided - but at least it has been working in IE (and in other 
> contexts outside Xopus-in-a-browser).
> 
> If anyone is able to direct me to a useful example, or provide some 
> tips on how to achieve what I am doing without using document(), I 
> would be very grateful.
> 
You could consider using Saxon-JS, which supports asynchronous HTTP requests
to get resources (and also supports XSLT 3.0 rather than 1.0)

> By the way, can anyone tell me what has happened to Dave Pawson's 
> invaluable XSLT FAQ? I remember using it almost daily for a while and 
> I feel a great loss now that its seems to have vanished from the web
> 

Ask Dave? But it had become rather sprawling, and in some respects rather
out of date.

Michael Kay
Saxonica

Current Thread