[xsl] xsl document function not returning desired node list

Subject: [xsl] xsl document function not returning desired node list
From: "Christian C. Schouten" <info@xxxxxxxxx>
Date: Thu, 21 Jan 2010 09:34:52 +0100
Hi all,
I want to create an xsl file that can be called generically by a bunch of
xml files. These xml files contain information about visual links between
some svg (xml) graphics. The xsl should create a html display that shows the
svg and adds clickable map information based on coordinates found when
parsing the svg.
To be precise, my xml's are made up as follows:
---
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="ClickableProcessView.xsl"?> <process
label="Authorisation request" filename="AuthorisationRequest">  <link
label="Request&#xd;&#xa;Whitelist check" filename="WhitelistCheck" />  <link
label="Request&#xd;&#xa;Authorisation check" filename="AuSPCheck" />
</process>
---
This means that the file AuthorisationRequest.svg contains two visual links
to subprocesses defined as WhitelistCheck and AuSPCheck. The clickable map
should therefore receive two <area shape="rect"> elements. The coordinates
of the rect can be found in a <rect> element within the svg file (it has
attributes x, y, width, height) and it can be cross-referenced with my xml
since rect has an attribute bpmn:activity-label that has the same value as
the "label" attribute of the link element in my xml. I would therefore
assume an xpath statement like //rect[@bpmn:activity-label=$linklabel]/@x to
retrieve the "x" attribute.

I figured the document() function would be handy here and it does seem to
work somewhat (i.e. all text values are displayed) but I can't convince it
to execute an xpath statement on the nodeset. It seems I've only got a
string of resulting values.
My XSL is as follows: (note how it is still far from being complete and
generic regarding filenames, which it should be.)
---
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:bpmn="http://www.intalio.com/bpms";>
 <xsl:template match="/">
  <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en">
   <head> (.) </head>
   <body>
    <div style="font-family: Verdana; font-size: 18pt; color: #000099"> (.)
</div>
    <img src="AuthorisationRequest.png" width="1130" height="538"
alt="Authorisation request" usemap="#processmap" />
    <map name="processmap">
     <!-- Call link template -->
     <xsl:apply-templates select="/process/link" />
    </map>
   </body>
  </html>
 </xsl:template>
 <xsl:template match="/process/link">
  <!--area shape="rect" coords="152,257,259,314" alt="Request Whitelist
Check" href="WhitelistCheck.html" /-->

  <xsl:variable name="processfilename" select="/process/@filename" />
  <xsl:variable name="linklabel" select="@label" />
  <xsl:value-of select="document(concat($processfilename,
'.svg'))//rect[@bpmn:activity-label=$linklabel]/@x" />

 </xsl:template>
</xsl:stylesheet>
---

Problem: the xsl:value-of with document function returns nothing.
If I remove the xpath statement from it, i.e. <xsl:value-of
select="document(concat($processfilename, '.svg'))" /> a result is printed
but it is not xml but plain text without the tags.
Note that debug statements like <xsl:value-of
select="concat($processfilename, '.svg'))" /> and <xsl:value-of
select="$linklabel" /> produce exactly the expected results (proper filename
and label to search for.
The problem also does not seem to be my exact xpath statement since
<xsl:value-of select="document(concat($processfilename, '.svg'))//rect" />
which I believe should return the first <rect> element, also does not return
anthing.

Most likely, I'm missing some initialization or configuration step but I
give up. Can anyone see my error?

PS1: I'm running this mainly in IE8, though I've also tried it in Chrome.
Have referenced the files with relative paths and absolute paths, both on a
local hard drive as well as on an apache http server and on a apache tomcat
server.
PS2: Sorry if this is double-posted, tried to post yesterday but didn't find
it in the daily digest.

Met vriendelijke groet,
 
Christian C. Schouten
 
 
Standard Business Reporting Programma
Een initiatief van de Nederlandse overheid
t: +31 (70) 392 2209
f: +31 (70) 392 2276
w: www.xbrl-ntp.nl

Current Thread