[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] merging and regrouping multiple xml files
I think this is a problem of grouping. I want to tranform a number of xml files into one. At the same time regrouping them. The masterfile contains the list of files to be merged and file 08 and file09 give representative input data. The last list is the desired outcome. I have looked up this type of problem but.. Salud John <masterfile> <doc filename="file08.xml"/> <doc filename="file09.xml"/> <doc filename="file10.xml"/> <doc filename="file11.xml"/> <doc filename="file12.xml"/> <doc filename="file13.xml"/> <doc filename="file14.xml"/> <doc filename="file15.xml"/> <doc filename="file16.xml"/> <doc filename="file17.xml"/> <doc filename="file18.xml"/> <doc filename="file19.xml"/> <doc filename="file20.xml"/> </masterfile> file08 <xchange> <asx> <code>AAB</code> <date>030905</date> <op>88</op> <hi>88</hi> <lo>88</lo> <cl>88</cl> <vol>10</vol> </asx> <asx> <code>AAC</code> <date>030905</date> <op>129</op> <hi>129</hi> <lo>127</lo> <cl>128</cl> <vol>99757</vol> </asx> </xchange> file09 <xchange> <asx> <code>AAB</code> <date>030906</date> <op>88</op> <hi>88</hi> <lo>86</lo> <cl>88</cl> <vol>20</vol> </asx> <asx> <code>AAC</code> <date>030906</date> <op>129</op> <hi>129</hi> <lo>127</lo> <cl>128</cl> <vol>99888</vol> </asx> </xchange> Merged OutPut <merged> <asx id="AAB"> <day id="030905"> <op>88</op> <hi>88</hi> <lo>88</lo> <cl>88</cl> <vol>10</vol> </day> <day id="030906"> <op>88</op> <hi>88</hi> <lo>86</lo> <cl>88</cl> <vol>20</vol> </day> </asx> <asx id="AAC"> <day id="030905"> <op>129</op> <hi>129</hi> <lo>127</lo> <cl>128</cl> <vol>99757</vol> </day> <day id="030906"> <op>129</op> <hi>129</hi> <lo>127</lo> <cl>128</cl> <vol>99888</vol> </day> </asx> Ken Holman gave the below code for something similar and while I feel that I should be able to adapt it, I could not. <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:template match="masterfile"> <merged> <xsl:variable name="clients" select="document(doc/@filename)/client"/> <xsl:for-each select="$clients"> <xsl:if test="generate-id(.)= generate-id($clients[name=current()/name])"> <client> <xsl:copy-of select="name"/> <xsl:copy-of select="$clients[name=current()/name]/subclient"/> </client> </xsl:if> </xsl:for-each> </merged> </xsl:template> </xsl:stylesheet> </merged> 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
|