![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Convert attributes to elements and lower case >Thread Next - Re: Convert attributes to elements and lower case Re: Convert attributes to elements and lower caseTo: NULL Date: 9/6/2007 11:36:00 AM
<sog2k7@g...> wrote in message
news:1189011666.431390.68010@5......
> I have an XML document where, for each node, I want to convert all the
> attributes of the node to elements. Also, whenever I have a value of
> "True" or "False" for an attribute, I want to convert it to lower case
> ("true", "false").
>
> This XSLT fragment will convert attributes to elements:
>
> <xsl:template match="/Lenders/LenderEntry">
> <LenderEntry xmlns="http://tempuri.org/SecuredLoansDataSet.xsd">
>
> <xsl:for-each select="@*">
> <xsl:element name="{name()}">
> <xsl:value-of select="."/>
> </xsl:element>
> </xsl:for-each>
>
> </LenderEntry>
> </xsl:template>
>
> Any ideas on how to convert boolean strings to lower case?
>
> Like...
>
> if attribute value == "True" write "true"
> if attribute value == "False" write "false"
>
Replace <xsl:value-of select="." /> with:-
<xsl:choose>
<xsl:when test=". = 'True'"><xsl:text>true</xsl:text></xsl:when>
<xsl:when text=". = 'False'"><xsl:text>false</xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
</xsl:choose>
--
Anthony Jones - MVP ASP/ASP.NET
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
