Re: [xsl] How to create multiple Html files considering attribute values in XML

Subject: Re: [xsl] How to create multiple Html files considering attribute values in XML
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sat, 20 Aug 2011 19:34:54 +0200
Sanjaya Liyanage wrote:
Hi all,
    I want to create multiple Html files considering attribute values in XML.

My XML

<School>

<Student age="17">
<firstname>kasun</firstname>
<lastname>lakpriya<lastname>
</Student>
<Student age="17">
<firstname>thiwanka</firstname>
<lastname>somasiri</lastname>
</Student>
<Student age="20">
<firstname>eshan</firstname>
<lastname>sudharaka</lastname>
</Student>
<Student id="20">
<firstname>haritha</firstname>
<lastname>tennakoon</lastname>
</Student>
<School>

    I want to generate two html files and each should contain the
details of students with same age.(here one html for students with age
17 and the other for age 20).How can I implement this in XSLT?Any help
is welcome.Thank you

XSLT 2.0 as implemented by Saxon 9, AltovaXML, XQSharp can create multiple output files e.g.
<xsl:template match="/">
<xsl:for-each-group select="School/Student" group-by="@age">
<xsl:result-document href="Students-aged-{current-grouping-key()}.xml">
<Students>
<xsl:copy-of select="current-group()"/>
</Students>
</xsl:result-document>
</xsl:for-each-group>
</xsl:template>





--


	Martin Honnen --- MVP Data Platform Development
	http://msmvps.com/blogs/martin_honnen/

Current Thread