XSLT-functie document() haalt geen externe XML op

Status
Niet open voor verdere reacties.

SchoutenCC

Gebruiker
Lid geworden
23 jul 2008
Berichten
14
Hallo allemaal,

Ik probeer via de XSLT-functie document() gegevens uit een (tweede) XML-bestand toegankelijk te krijgen in een eerste xml-bestand (die de xslt aanroept).
Totaalplaatje is een xml-file die een paar links definieert, de xsl maakt hier een mooie display/html (clickable map op basis dus van de links uit de xml) van, maar het gaat om de links want daar zijn coordinaten voor nodig uit een tweede (svg) bestand. Het matchen gaat op een label-attribuut.

Nu is mijn probleem dat de meeste voorbeelden van document(), ook al kopieer ik ze 1-op-1 met enkel de aanpassingen van de te selecteren nodes, niet bij mij lijken te werken. Ergens mis ik dus een configuratie of instelling lijkt het. Ik werk overigens met IE8.

Wie kan mij een eind op weg helpen naar een stukje XML/XSLT dat wèl goed werkt?

Alvast bedankt voor elke hulp,
Vriendelijke groet,
Christian Schouten

*** XML-file linkdefinitie ***
[xml]
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="ClickableProcessView.xsl"?>
<process label="Authorisation request" filename="AuthorisationRequest">
<link label="Request
Whitelist check" filename="WhitelistCheck" />
<link label="Request
Authorisation check" filename="AuSPCheck" />
</process>
[/xml]
*** XSL-file displaymodus ***
[xml]
<?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:variable name="processfilename" select="/process/@filename" />
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>SBR Processes :: Click-through view</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<style type="text/css">
</style>
</head>
<body>
<div style="font-family: Verdana; font-size: 18pt; color: #000099">
SBR Process:
<!-- Select filename attribute of (root) process element -->
<xsl:value-of select="$processfilename" />
</div>
<!--img src="AuthorisationRequest.png" width="1130" height="538" alt="Authorisation request" usemap="#processmap" /-->
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="concat($processfilename, '.png')" />
</xsl:attribute>
<xsl:attribute name="width">
<!-- probleem: document() geeft niets terug -->
<xsl:for-each select="document(concat($processfilename, '.svg'))">
<xsl:value-of select="//svg/@width" />
</xsl:for-each>
<!--xsl:value-of select="document(concat($processfilename, '.svg'))/svg/@width" /-->
</xsl:attribute>
<xsl:attribute name="height">
<xsl:for-each select="document(concat($processfilename, '.svg'))">
<xsl:value-of select="//svg/@height" />
</xsl:for-each>
<!--xsl:value-of select="document(concat($processfilename, '.svg'))/svg/@height" /-->
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="/process/@label" />
</xsl:attribute>
<xsl:attribute name="usemap">#processmap</xsl:attribute>
</xsl:element>
<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" /-->
<!-- Hier dus ook op magische wijze een verwijzing naar filename.svg -->
<xsl:element name="area">
<xsl:attribute name="shape">rect</xsl:attribute>
<xsl:attribute name="coords">
<xsl:value-of select="concat(@x, ',', @y, ',', @x+@width, ',', @y+@width)" />
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="@label" />
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="concat(@filename, '.html')" />
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
[/xml]
*** SVG-file ***
[xml]
<?xml version='1.0' encoding='UTF-8'?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-dasharray="none" shape-rendering="auto" font-family="'Dialog'" width="1130" text-rendering="auto" fill-opacity="1" contentScriptType="text/ecmascript" color-interpolation="auto" color-rendering="auto" preserveAspectRatio="xMidYMid meet" font-size="12" viewBox="0 0 1130 538" fill="black" stroke="black" image-rendering="auto" stroke-miterlimit="10" zoomAndPan="magnify" version="1.0" stroke-linecap="square" stroke-linejoin="miter" contentStyleType="text/css" font-style="normal" height="538" stroke-width="1" stroke-dashoffset="0" font-weight="normal" stroke-opacity="1" xmlns:bpmn="http://www.intalio.com/bpms">
(...)
<g>
(...)
<g fill="rgb(232,232,255)" stroke-miterlimit="0" font-family="'Arial'" stroke-linejoin="round" stroke="rgb(232,232,255)">
(...)
<rect x="152" y="257" clip-path="url(#clipPath38)" fill="white" width="107" rx="4.5" ry="4.5" height="57" stroke="none" bpmn:process-id="_b5s6kM7aEd6EHZCgZOOBSw" bpmn:activity-id="_f4sgWNNnEd6blfkDFQyuTQ" bpmn:activity-label="Request
Whitelist check"/>
(...)
[/xml]
 
Laatst bewerkt door een moderator:
de docement() functie werkt alleen als de naam van de file tijdens compilatie van de xsl al bekend is.
werkt niet:
<xsl:variable name="b" select="extern.xml" />
<xsl:value-of select="document($b)/data"/>

werkt wel:
<xsl:value-of select="document('extern.xml')/data"/>

werkt ook:
<xsl:value-of select="document(@href)/data"/>

Je zult dus de ".svg" in je bron bestand erbij moeten plaatsen.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan