Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSLT modifying an xml dom tree?

From: "Prashanth Ellina" <prashanthellina@-----.--->
To: NULL
Date: 8/1/2005 11:26:00 PM
Hi,

That looks great. I will "muench" that. Thanks a lot.

Prashanth

Joris Gillis wrote:
> Tempore 15:35:06, die Monday 01 August 2005 AD, hinc in foro {comp.text.xml} scripsit Prashanth  Ellina <prashanthellina@g...>:
>
> > I find the XSLT programming model very alien and un-intuitive.
> You'll be used to it in no time;) It's just another way of thinking.
>
> > This is what I am looking to do
> > ...
>
> This a grouping problem, here's a solution with the Muenchian grouping technique, one of the most alien things for beginners:-)
>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" indent="yes"/>
>
> <xsl:key name="author" match="author" use="."/>
> <xsl:variable name="allAuthors" select="//author[generate-id()=generate-id(key('author',.)[1])]"/>
>
> <xsl:template match="booksinformation">
> <xsl:copy>
> 	<bookdata>
> 		<xsl:apply-templates/>
> 	</bookdata>
> 	<authordata>
> 		<xsl:for-each select="$allAuthors">
> 			<author id="{position()}" name="{.}"/>
> 		</xsl:for-each>
> 	</authordata>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template match="book">
> <xsl:variable name="author" select="author"/>
> <xsl:copy>
> 	<xsl:attribute name="author">
> 		<xsl:for-each select="$allAuthors">
> 			<xsl:if test=". = $author"><xsl:value-of select="position()"/></xsl:if>
> 		</xsl:for-each>
> 	</xsl:attribute>
> 	<xsl:copy-of select="title"/>
> </xsl:copy>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> regards,
> --
> Joris Gillis (http://users.telenet.be/root-jg/me.html)
> Deserta faciunt et innovationem appelant



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent