Hi,
I would like to make a xslt function which looks in the bodytext of a node and when 1 of the words in the bodytext contains a word that is also in the 'Verklarende woordenlijst' (see image) as a node then the word in the bodytext gets linked to the node in the 'Verklarende woordenlijst'
I was "playing" with xslt to achieve this but my xslt knowledge..........
I've put the bodytext in a variable:
[code][/code]
and to get all subnodes from 'Verklarende woordenlijst' I had:
[code][/code]
To start I had for example:
[code][/code]
where I would change 'aanpassen' bij $Woordenlijst but that won't work because $Woordenlijst doesn't break up the nodes as seperate variables.........Any help on this will highly be appreciated!! I probarly starting of wrongly with my XSLT but if someone can put me in the right direction?! #-o
Create automatic link with XSLT
Hi,
I would like to make a xslt function which looks in the bodytext of a node and when 1 of the words in the bodytext contains a word that is also in the 'Verklarende woordenlijst' (see image) as a node then the word in the bodytext gets linked to the node in the 'Verklarende woordenlijst'
I was "playing" with xslt to achieve this but my xslt knowledge..........
I've put the bodytext in a variable:
[code][/code]
and to get all subnodes from 'Verklarende woordenlijst' I had:
[code][/code]
To start I had for example:
[code][/code]
where I would change 'aanpassen' bij $Woordenlijst but that won't work because $Woordenlijst doesn't break up the nodes as seperate variables.........Any help on this will highly be appreciated!! I probarly starting of wrongly with my XSLT but if someone can put me in the right direction?! #-o
I think you have to do it this way: (didn't test it though)
[code][/code]
A step closer to your finale solution would be: (though this only works for 1 hit per $getBodyText...)
[code][/code]
Maybe you have to put string() around the elements in the contains() and Replace() if you get an error otherwise. As said I didn't test it.
Great work Arjan! Almost there........=d>
Right now I have this for XSLT:
[code]
]>
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
[/code]
The way it goes now that it repeats the bodyText for every node under id/1075 (4 right now). I've tright (position):
[code][/code]
and the bodytext is shown 1 time but nothing within the bodytext that contains a name from the 'Woordenlijst' nodes is replaced......
Another thing is that I don't understand what you mean with putting string() around certain elements....8-[
Any ideas?!
Chris
Yes it is not very easy to modify a variable value in a loop in XSLT. I guess you will have to make a recursive xsl:template.
Another solution would be to use regular expressions:
First put al of your Verklarende woordenlijst items in a string variable seperated by | so it wil look like "Nodename 1|Nodename 2|Nodename 3" etc.
[code]
[/code]
This example is not ready to use because it has no solution for the href part of the anchors (it just puts the nodename there for now).
In order to use exslt regexps put xmlns:exslt.regexp="urn:Exslt.ExsltRegularExpressions" in your xsl:stylesheet.
Could be there is a max length for the regular expression so I don't know if this is the way to go.
You will also have to pevent that anchors are generated within anchors which will break your html.
Maybe the best thing in terms of flexibillity and performance is not to use a XSLT macro but a C# usercontrol to make your automatic links.
is working on a reply...