[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSL Transformation

Subject: RE: XSL Transformation
From: bryan.s.schnabel@xxxxxxxxxxxxxx
Date: Mon, 15 Mar 2004 11:11:09 -0800
aerobird challenger
Hi Jim,

There are many ways to do this.

>From my point of view, the goal would be to make this portable to other
alphabets.  A kind of unique way might be to put a little look-up table in
your stylesheet (it would be even better to refer to an external file, but
the concept is still sort of the same):

So if you put this at the stylesheet level:

<xsl:param name="letters">
 <alphabet-char character="A"/>
 <alphabet-char character="B"/>
 <alphabet-char character="C"/>
 <alphabet-char character="D"/>
 <alphabet-char character="E"/>
 <alphabet-char character="F"/>
 <alphabet-char character="G"/>
 <alphabet-char character="H"/>
 <alphabet-char character="I"/>
 <alphabet-char character="J"/>
 <alphabet-char character="K"/>
 <alphabet-char character="L"/>
 <alphabet-char character="M"/>
 <alphabet-char character="N"/>
 <alphabet-char character="O"/>
 <alphabet-char character="P"/>
 <alphabet-char character="Q"/>
 <alphabet-char character="R"/>
 <alphabet-char character="S"/>
 <alphabet-char character="T"/>
 <alphabet-char character="U"/>
 <alphabet-char character="V"/>
 <alphabet-char character="W"/>
 <alphabet-char character="X"/>
 <alphabet-char character="Y"/>
 <alphabet-char character="Z"/>
</xsl:param>

Where the character attribute could be substituted for any character set,
you could then make use of the document('') function to get your desired
results, something like this:

<xsl:template match="/">
 <xsl:variable name="terms">
  <xsl:copy-of select="XML" />
 </xsl:variable>
 <letters>
  <xsl:for-each select="document('')/*/xsl:param/alphabet-char">
   <xsl:variable name="term-letter" select="@character" />
    <xsl:for-each select="$terms">
     <keyword letter="{$term-letter}">
       <xsl:for-each select="*/*[starts-with(@Keyword,$term-letter)]">
         <term>
           <name><xsl:copy-of select="@Keyword" /></name>
           <id><xsl:copy-of select="@Key_ID" /></id>
           <definition><xsl:copy-of select="@Description" /></definition>
           <status><xsl:copy-of select="@Status" /></status>
         </term>
       </xsl:for-each>
     </keyword>
    </xsl:for-each>
  </xsl:for-each>
 </letters>
</xsl:template>

-----Original Message-----
From: Jim Han [mailto:jhan@xxxxxxxxxxxxxxxx] 
Sent: Monday, March 15, 2004 9:19 AM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.