|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: re-ordering nodes
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








