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

Re: re-ordering nodes

Subject: Re: re-ordering nodes
From: Srinivasan Guruswami - CSIS Fellow <srini@xxxxxxxxxxxxxxxxx>
Date: Thu, 20 Dec 2001 17:10:32 -0500 (EST)
guruswami

> Actually I was being lazy. I think that what Srini wanted was:

Jeni, Wendell - 

Thanks for your responses. They were useful, and I was able to play with
it and get what I need.

I ended up writing a SAX parser, and compared it with a small XSL
script, based on your suggestions. I am amazed, at how easy it is with
XSL once you get the hang of it.

And, Sorry folks, for not being too clear. I am researching on how an XML
object model (objects serialized in XML) retrofit over a relational
database can communicate with applications. For simplicity, I designed it
so that all the objects ("<o>" tags with oids) are at the root level with
references from other objects. However, while generating the object data
from relational SQL queries, it is far easier to nest them. So, I thought
of a post-processing step that re-orders all the objects, and bring them
at the same level.

Does anyone know of other tools or similar efforts? Once again, thanks for
all your input.

-Srini

> 
> <xsl:strip-space elements="*" />
> 
> <xsl:template match="list">
>   <xsl:apply-templates select=".//o">
>     <xsl:sort select="count(node())" data-type="number" />
>   </xsl:apply-templates>
> </xsl:template>
> 
> <xsl:template match="o">
>   <o>
>     <xsl:apply-templates select="a | b | text()" />
>   </o>
> </xsl:template>
> 
> <xsl:template match="a | b">
>   <xsl:copy>
>     <xsl:copy-of select="@*" />
>     <xsl:if test="o">
>       <xsl:comment>
>         <xsl:text> for </xsl:text>
>         <xsl:for-each select=".//o[not(o)]">
>           <xsl:value-of select="number()" />
>           <xsl:if test="position() != last()">, </xsl:if>
>         </xsl:for-each>
>         <xsl:text> </xsl:text>
>       </xsl:comment>
>     </xsl:if>
>   </xsl:copy>
> </xsl:template>
> 
> At least it gives the required output for the single sample
> document...
> 
> Jeni
> 
> ---
> Jeni Tennison
> http://www.jenitennison.com/
> 
> 
>  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.