[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi,
Tempore 16:08:57, die 09/13/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Mehta, Chirag <chirag.mehta@xxxxxxxxxxxxxxxxx>:
<xsl:template match="dictionary"><xsl:apply-templates/></xsl:template>
</xsl:stylesheet>
Re: [xsl] Attribute and Element Formatting Issues
Subject: Re: [xsl] Attribute and Element Formatting Issues From: "Joris Gillis" <roac@xxxxxxxxxx> Date: Tue, 13 Sep 2005 16:56:48 +0200 |
Hi,
Tempore 16:08:57, die 09/13/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Mehta, Chirag <chirag.mehta@xxxxxxxxxxxxxxxxx>:
<?xml version="1.0" encoding="utf-8"?> <portfolio name="CBOT" version="1"> <trade name="Future" quantity="1"> <instrument instType="Bond"> <dictionary> <dict name="expiry date" type="t"> </dict>
<dict name="strike" type="d">0.95</dict>
<dict name="option type" type="s">EuropeanCall</dict> </dictionary> </instrument> </trade> </portfolio>
TO:
<?xml version="1.0" encoding="utf-8"?> <portfolio name="CBOT" version="1"> <trade name="Future" quantity="1"> <instrument instType="Bond"> <expiryDate> </expiryDate>
<strike>0.95</strike>
<optionType>EurpoeanCall</optionType> </instrument> </trade> </portfolio>
Try this stylesheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/>
<xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*" /> </xsl:copy> </xsl:template>
<xsl:template match="dictionary"><xsl:apply-templates/></xsl:template>
<xsl:template match="dict"> <xsl:variable name="new_name"> <xsl:call-template name="capitalize"> <xsl:with-param name="string" select="@name"/> </xsl:call-template> </xsl:variable> <xsl:element name="{$new_name}"><xsl:apply-templates/></xsl:element> </xsl:template>
<xsl:template name="capitalize"> <xsl:param name="string"/> <xsl:param name="caps" select="false()"/> <xsl:if test="contains($string,' ')"> <xsl:if test="$caps"> <xsl:value-of select="translate(substring(substring-before($string,' '),1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> <xsl:value-of select="substring(substring-before($string,' '),2)"/> </xsl:if> <xsl:if test="not($caps)"> <xsl:value-of select="substring-before($string,' ')"/> </xsl:if> <xsl:call-template name="capitalize"> <xsl:with-param name="string" select="substring-after($string,' ')"/> <xsl:with-param name="caps" select="true()"/> </xsl:call-template> </xsl:if> <xsl:if test="not(contains($string,' '))"> <xsl:if test="$caps"> <xsl:value-of select="translate(substring($string,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> <xsl:value-of select="substring($string,2)"/> </xsl:if> <xsl:if test="not($caps)"> <xsl:value-of select="$string"/> </xsl:if> </xsl:if> </xsl:template>
</xsl:stylesheet>
regards, -- Joris Gillis (http://users.telenet.be/root-jg/me.html) B+Et ipsa scientia potestas estB; - Francis Bacon , Meditationes sacrae
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Attribute and Element Formatt, Mehta, Chirag | Thread | Re: [xsl] Attribute and Element For, Mukul Gandhi |
Re: [xsl] IXSLProcessor - input in , andrew welch | Date | RE: [xsl] IXSLProcessor - input in , Gabriel |
Month |