Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Replace attribute value >Thread Next - Re: Replace attribute value Re: Replace attribute valueTo: NULL Date: 2/8/2008 2:08:00 PM Thanks for that, Is there a way to lower case the attribute value before trying to match with the constant ? If you know a good tutorial about XSLT I'm interresting. TIA. "Martin Honnen" <mahotrash@y...> wrote in message news:O#JWq6kaIHA.5164@T...... > Olivier MATROT wrote: > >> I would like to replace attribute values in an XML file if it matches >> another value. >> >> Given this XML fragment : >> <Users> >> <User fistName = "Olivier" advancedViewing="VRAI"/> >> <User fistName = "Olivier" advancedViewing="FAUX"/> >> </Users> >> >> It should become : >> <Users> >> <User fistName = "Olivier" advancedViewing="true"/> >> <User fistName = "Olivier" advancedViewing="false"/> >> </Users> >> >> How can I do this ? > > An XSLT stylesheet is one way > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:template match="@* | node()"> > <xsl:copy> > <xsl:apply-templates select="@* | node()"/> > </xsl:copy> > </xsl:template> > > <xsl:template match="User/@advancedViewing[. = 'VRAI']"> > <xsl:attribute name="{name()}"> > <xsl:text>true</xsl:text> > </xsl:attribute> > </xsl:template> > > <xsl:template match="User/@advancedViewing[. = 'FAUX']"> > <xsl:attribute name="{name()}"> > <xsl:text>false</xsl:text> > </xsl:attribute> > </xsl:template> > > </xsl:stylesheet> > > Both MSXML and the .NET framework support XSLT 1.0 transformations, with > the .NET framework you use System.Xml.Xsl.XslCompiledTransform. > > > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
