Is it possible to replace/substitute the incoming XSL data?

vB Lider

New Member
I tried to look for an answer on google, but the results i get back is either how to substitute a string or replacing a substring etc. But my question is slightly different.Say I have an existing XSL template, say "hello-world", that processes "data/records/record", but I cannot modify hello-world, so I'm thinking of creating a wrapper template that will massage/modify the data inside each record before passing it to hello-world... is there a way to do that?So far, I've managed to create a function that would filter out the duplicate records, and I was thinking of replacing all the records inside "data/records/*" with the new one...\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:call-template name="get-unique-record"> <xsl:with-param name="records" select="/data/records/record"/> </xsl:call-template> </xsl:template> <!-- This function will filter out the given records and return a unique set of records --> <xsl:key name="kField_ID" match="field[@name='ID']" use="."/> <xsl:template name="get-unique-record"> <xsl:param name="records"/> <xsl:for-each select="$records"> <xsl:variable name="record" select="."/> <xsl:if test="$record//field[generate-id() = generate-id(key('kField_ID', .))]"> <xsl:copy-of select="$record"/> </xsl:if> </xsl:for-each> </xsl:template></xsl:stylesheet>\[/code\]Now... is it possible to do something like:\[code\]<xsl:variable name="/data/records/record"> <xsl:call-template name="get-unique-record"> <xsl:with-param name="records" select="/data/records/record"/> </xsl:call-template></xsl:variable>\[/code\]EDIT: @LasrH, thanks for the quick reply. Is there a way to make a copy of the existing "/" and then replace all the /data/records/record with the filtered one?EDIT2: @LasrH, I created couple of template to modify and rebuild the "data" node. Is it possible to use node-set to "replace" the existing input with my new data as input?\[code\]<xsl:variable name="data"> <xsl:call-template name="rebuild-data-with-record"> <xsl:with-param name="records"> <xsl:copy-of select="$unique-records"></xsl:copy-of> </xsl:with-param> </xsl:call-template></xsl:variable>\[/code\]Then further down I tried to use node-set like this:\[code\]<xsl:apply-templates select="exslt:node-set($data)/data"/>\[/code\]But it doesn't look like is doing it... there is no error thrown either.
 
Back
Top