Ik probeer een XSLT-stylesheet te maken, dat o.a. links binnen een text (dus omgeven door text-nodes vervangt.
Op zich niet al te moeilijk leek me, maar de onderstaande oplossing lijkt me niet echt perfect/efficiënt... (Google, ZVON.org en o'Reilly's XSLT en het XSLT-cookbook gaven geen antwoord op mijn vraag).
xml-file:
xsl-file:
Op zich niet al te moeilijk leek me, maar de onderstaande oplossing lijkt me niet echt perfect/efficiënt... (Google, ZVON.org en o'Reilly's XSLT en het XSLT-cookbook gaven geen antwoord op mijn vraag).
xml-file:
code:
1
2
3
4
5
6
7
8
| <?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<test>
<name>
dit <lin href="test2.xml">is</lin> een test
</name>
</test> |
xsl-file:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| <?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="html" version="1.0" encoding="ISO-8859-1" />
<xsl:template match="/">
<html>
<head>
<title>Test</title>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="name">
<xsl:for-each select=".">
<xsl:apply-templates />
</xsl:for-each>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="." />
</xsl:template>
<xsl:template match="lin">
<a href="{@href}"><xsl:value-of select="text()" /></a>
</xsl:template>
</xsl:transform> |