Subject: Re: [xsl] Merging and sorting multiple XML files From: Herve Dubreuil <hervedub@xxxxxxxxx> Date: Thu, 29 Jul 2004 05:54:31 -0700 (PDT) |
Thanks for this quick answer ! It seems to be working but I've having a problem / bug? Here is the error that is generated: [hdubreui@gange vcd test]$ sabcmd -L=log.sabcmd merge4.xslt 1.xml out.xml Error [code:4] [URI:file:///home/hdubreui/Projects/TAST/development/modules/cc_wave/vcd test/2.xml] [line:19] cannot open file '/home/hdubreui/Projects/TAST/development/modules/cc_wave/vcd test/2.xml3.xml' and if I check the log: Parsing 'file:///home/hdubreui/Projects/TAST/development/modules/cc_wave/vcd test/merge4.xslt'... Parse done in 0.003 seconds Parsing 'file:///home/hdubreui/Projects/TAST/development/modules/cc_wave/vcd test/1.xml'... Parse done in 0.000 seconds Executing stylesheet 'file:///home/hdubreui/Projects/TAST/development/modules/cc_wave/vcd test/merge4.xslt'... Parsing 'file:///home/hdubreui/Projects/TAST/development/modules/cc_wave/vcd test/list.xml'... Parse done in -0.000 seconds Parsing 'file:///home/hdubreui/Projects/TAST/development/modules/cc_wave/vcd test/2.xml'... Parse done in 0.000 seconds cannot open file '/home/hdubreui/Projects/TAST/development/modules/cc_wave/vcd test/2.xml3.xml' So it means it correctly opens the first file of the list but don't manage to open the second one because it is looking at a wrong adress... it this a bug of the software (sablotron) If I just put one file on the list, it is parsed correctly (but I need to merge ~50 ;-) ) Here is the list: <?xml version="1.0" ?> <listoffile> <wave filename="2.xml" /> <wave filename="3.xml" /> </listoffile> And the xsl modified with your input: <?xml version="1.0" ?> <!-- We first start by defining the xsl/xml header --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/> <!-- The first file is passed directly to the parser and then a list is read from list.xml --> <xsl:variable name="docs" select="document(document('list.xml')/listoffile/wave/@filename)"/> <!-- we apply the template to the whole document --> <xsl:template match="/"> <xsl:apply-templates select="PreVCD"/> </xsl:template> <!--We apply the template component to the node component and the same to dump --> <xsl:template match="PreVCD"> <xsl:copy> <xsl:apply-templates select="component" /> <xsl:apply-templates select="dump" /> </xsl:copy> </xsl:template> <!-- In the template component, we copy <component>, then add its attribute (name) and then copy the subpathes --> <xsl:template match="component"> <xsl:copy> <!-- copy the attribute name --> <xsl:copy-of select="@*" /> <!-- Apply the template subpath1 and add the nodes into the path where the subpath have the same name (regroup) --> <xsl:apply-templates select="subpath | $docs/PreVCD/component/subpath[not(@path = current()/subpath/@path)]"> <!-- Sort the nodes by name --> <xsl:sort select="@path" data-type="text" order="ascending" /> </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="subpath"> <xsl:variable name="curPath" select="@path" /> <xsl:copy> <xsl:copy-of select="@*" /> <xsl:copy-of select="* | $docs/PreVCD/component/subpath[@path =$curPath]/*" /> </xsl:copy> </xsl:template> <!-- In Dump, we have to regroup elements and sort by time --> <xsl:template match="dump"> <xsl:copy> <xsl:apply-templates select="time | $docs/PreVCD/dump/time[not(@t = current()/time/@t)]" > <xsl:sort select="@t" data-type="number" order="ascending" /> </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="time"> <xsl:variable name="curTime" select="@t" /> <xsl:copy> <xsl:copy-of select="@*" /> <xsl:copy-of select="* | $docs/PreVCD/dump/time[@t =$curTime]/*" /> </xsl:copy> </xsl:template> </xsl:stylesheet> --- David Carlisle <davidc@xxxxxxxxx> wrote: > > > But, is there a way to provide a list and merge all those file at > once > like: > > list.xml: > <listoffile> > <wave filename="1.xml"> > <wave filename="2.xml"> > <wave filename="3.xml"> > ...... > <wave filename="50.xml"> > </listoffile> > > > > > given that file you can do > > <xsl:variable name="docs" > select="document(document('list.xml')/listoffile/wave/@filename)"/> > > then $docs will be a set of / nodes one for each file in your list. > > David > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star Internet. The > service is powered by MessageLabs. For more information on a > proactive > anti-virus service working around the clock, around the globe, visit: > http://www.star.net.uk > ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Merging and sorting multi, David Carlisle | Thread | [xsl] UK based Freelance XML/XSLT C, Mulberry Technologie |
RE: [xsl] Name of files being proce, Michael Kay | Date | RE: [xsl] Name of files being proce, xptm |
Month |