Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XSLT modifying an xml dom tree? >Thread Next - Re: XSLT modifying an xml dom tree? Re: XSLT modifying an xml dom tree?To: NULL Date: 8/1/2005 2:21:00 PM Prashanth Ellina wrote: > I am an XSLT newbie. I need to solve something which I will express in > pseudo-code. > > function f1() > { > xmltree = <emptydom> > addnamevaluepair(xmltree, "size","100") > addnamevaluepair(xmltree, "color","blue") > } > > function addnamevaluepair(dom, name, value) > { > //add element : <attrib> > // <name>....</name> > // <value>...</value> > // </attrib> > //to the dom and return it > return xmldom > } > > What would the equivalent be in XSLT? <xsl:template match="/"> <root> <xsl:call-template name="addnamevaluepair"> <xsl:with-param name="name" select="'size'" /> <xsl:with-param name="value" select="100" /> </xsl:call-template> <xsl:call-template name="addnamevaluepair"> <xsl:with-param name="name" select="'color'" /> <xsl:with-param name="value" select="'blue'" /> </xsl:call-template> </root> </xsl:template> <xsl:template name="addnamevaluepair"> <xsl:param name="name" /> <xsl:param name="value" /> <attrib> <name><xsl:value-of select="$name" /></name> <value><xsl:value-of select="$value" /></value> </attrib> </xsl:template> -- Martin Honnen http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
