Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - CHANGE AN XSL FROM A WEB PAGE [Thread Next] Re: CHANGE AN XSL FROM A WEB PAGETo: NULL Date: 10/5/2004 8:16:00 PM Siu wrote: > I have to develop a web page which is able to change an xsl or the xml tags > and not the contents. For example: this is an xml file > > <location> > <building> > <office> > <printer> > </printer> > <printer> > </printer> > <printer> > </printer> > </office> > </building> > </location> > > From my web application I want my user to change the tag <printer> into > <PRINTER>. How can I devlop this web page in C# (.NET)? The following XSLT stylesheet will change element names defined in $from parameter to a name defined in $to parameter, while preserving the rest as is: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="from" select="'printer'"/> <xsl:param name="to" select="'PRINTER'"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="*"> <xsl:choose> <xsl:when test="name()=$from"> <xsl:element name="{$to}" namespace="{namespace-uri()}"> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> And for developing web pages using C# ask in more appropriate newsgroup. -- Oleg Tkachenko [XML MVP] http://blog.tkachenko.com | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
