Subject: RE: [xsl] XSL Transformation From: "Josh Canfield" <Josh.Canfield@xxxxxxxxxxxx> Date: Mon, 15 Mar 2004 10:27:56 -0800 |
Here, this might not be pretty, but it does what you ask... <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" encoding="utf-8"/> <xsl:variable name="alpha-upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:variable name="alpha-lower" select="'abcdefghijklmnopqrstuvwxyz'"/> <xsl:variable name="alpha-rtf"> <A/><B/><C/><D/><E/><F/><G/><H/><I/><J/><K/><L/><M/><N/><O/><P/><Q/><R/><S/><T/><U/><V/><W/><X/><Y/><Z/> </xsl:variable> <xsl:template match="/"> <xsl:variable name="alpha-nodes" select="document('')/xsl:stylesheet/xsl:variable[@name='alpha-rtf']"/> <xsl:variable name="root" select="XML"/> <xsl:for-each select="$alpha-nodes/*"> <Keyword Letter="{name()}"> <xsl:apply-templates select="$root/row[ translate(substring(@Keyword,1,1), $alpha-lower, $alpha-upper) = name(current()) ]"> <xsl:sort select="@Keyword"/> </xsl:apply-templates> </Keyword> </xsl:for-each> </xsl:template> <xsl:template match="row"> <Term> <Id><xsl:value-of select="@Key_ID"/></Id> <Name><xsl:value-of select="@Keyword"/></Name> <Description><xsl:value-of select="@Description"/></Description> <status><xsl:value-of select="@Status"/></status> </Term> </xsl:template> </xsl:stylesheet> Josh -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Jim Han Sent: Monday, March 15, 2004 9:19 AM To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] XSL Transformation I've trying to work on this XSL transformation but I am running into a wall. Can some help me get started? I need an xsl to conver this xml: <XML> <row Key_ID="2" Keyword="A-10" Description="A-10 Warthog ARF w/ Ducted Fans" Status="active"/> <row Key_ID="3" Keyword="Aerobird Challenger" Description="Aerobird Challenger RTF " Status="active"/> <row Key_ID="5" Keyword="CARISMA" Description="CARISMA R/C CARS" Status="active"/> <row Key_ID="4" Keyword="Mech Warrior" Description="Mech Warrior: Fire For Effect Booster Pack " Status="active"/> <row Key_ID="1" Keyword="Mini-T" Description="Mini-T RTR 1/18-Scale Off-Road Truck" Status="active"/> </XML> To: <?xml version="1.0" encoding="UTF-8"?> <Keywords xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Keyword Letter="A"> <Term> <Id>2</Id> <Name>A-10</Name> <Definition>A-10 Warthog ARF w/ Ducted Fans.</Definition> <status>active</status> </Term> <Term> <Id>3</Id> <Name>Aerobird Challenger</Name> <Definition>Aerobird Challenger RTF..</Definition> <status>active</status> </Term> </Keyword> <Keyword Letter="B"> </Keyword> <Keyword Letter="C"> <Term> <Id>5</Id> <Name>CARISMA</Name> <Definition>CARISMA R/C CARS</Definition> <status>active</status> </Term> </Keyword> <Keyword Letter="D"/> <Keyword Letter="E"/> <Keyword Letter="F"/> <Keyword Letter="G"/> <Keyword Letter="H"/> <Keyword Letter="I"/> <Keyword Letter="J"/> <Keyword Letter="K"/> <Keyword Letter="L"/> <Keyword Letter="M"> <Term> <Id>4</Id> <Name>Mech Warrior</Name> <Definition>Mech Warrior: Fire For Effect Booster Pack</Definition> <status>active</status> </Term> <Term> <Id>1</Id> <Name>Mini-T</Name> <Definition>Mini-T RTR 1/18-Scale Off-Road Truck</Definition> <status>active</status> </Term> </Keyword> <Keyword Letter="N"/> <Keyword Letter="O"/> <Keyword Letter="P"/> <Keyword Letter="Q"/> <Keyword Letter="R"/> <Keyword Letter="S"/> <Keyword Letter="T"/> <Keyword Letter="U"/> <Keyword Letter="V"/> <Keyword Letter="W"/> <Keyword Letter="X"/> <Keyword Letter="Y"/> <Keyword Letter="Z"/> </Keywords> Jim XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSL Transformation, Michael Kay | Thread | RE: [xsl] XSL Transformation, bryan . s . schnabel |
[xsl] XSL Transformation, Jim Han | Date | Re: [xsl] XSL Transformation, Jeni Tennison |
Month |