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

RE: XML to XML

Subject: RE: XML to XML
From: Jim Han <jhan@xxxxxxxxxxxxxxxx>
Date: Wed, 26 Mar 2003 17:06:00 -0600
jim han
Wow Wendell,

Thank you so much for your solution as well as your explanation.
It worked great.

I am still learning about xslt.
I purchased wrox xslt 2nd edition but it seems a bit too complicated for me.
I went through few basic books.

Can you suggest me any resources?  
Again than you!




Jim Han


Web Developer


-----Original Message-----
From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx]
Sent: Wednesday, March 26, 2003 4:54 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  XML to XML


Jim,

Ken's solution is also a good one (assuming he wrote what he intended to 
write in his untested code ;-). Note that he's optimized for performance on 
the assumption the nodes are correctly ordered in the input. If they're 
not, his solution will be slow on large datasets compared to mine, but it 
has the advantage of not caring how many levels deep you have to go. 
(Except for the output element naming bit: tricky, that. If you could name 
them 'Level2Category' instead of 'LevelTwoCategory', etc., this problem 
would go away).

Cheers,
Wendell

At 04:49 PM 3/26/2003, he wrote:
>Untested but try the following approach
>
><xsl:template match="Categories">
>         <Categories>
>                 <xsl:apply-templates 
> select="Category[length(string(Code))=1]" />
>         </Categories>
></xsl:template>
>
><xsl:template match="Category">
>         <xsl:variable name="code" select="string(Code)"/>
>         <xsl:variable name="code-length" select="length(string(Code))"/>
>         <xsl:variable name="name">
>                 <xsl:choose>
>                         <xsl:when 
> test="length(string(Code))=1">LevelOneCategory</xsl:when>
>                         ...etc
>                 </xsl:choose>
>         </xsl:variable>
>         <xsl:element name="{$name}" Code="{$code}" 
> Description="{Description}">
>                 <xsl:apply-templates 
>
select="following-sibling::Category[substring(string(Code),1,$code-length)=s
tring($code)]" 
> />
>         </xsl:element>
></xsl:template>
>
>following-sibling:: could be replaced with ../ if the order is not
guaranteed.


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


 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.