xsl-list
[Top] [All Lists]

Re: [xsl] Processing multiple input files and writing to one output

2008-03-20 07:07:00
Thanks Michael,
Previously I had never tried running the transformation from a command line.
I downloaded the necessary libraries and was able to execute just fine.

Sorry for the misunderstanding

Sean

On Thu, Mar 20, 2008 at 9:52 AM, Michael Kay <mike(_at_)saxonica(_dot_)com> 
wrote:
If you use a relative URI in xsl:result-document, then it is interpreted
 relative to the "base output URI", which in Saxon is the file/URI supplied
 as the -o option on the command line.

 A useful tip in Saxon: if you don't know where the output documents are
 being written, the -t option on the command line will tell you.

 However, if you're only writing one output file, it's not clear why you are
 using xsl:result-document at all.

 Michael Kay
 http://www.saxonica.com/



 > -----Original Message-----
 > From: Sean Tiley [mailto:sean(_dot_)tiley(_at_)gmail(_dot_)com]
 > Sent: 20 March 2008 13:42
 > To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
 > Subject: [xsl] Processing multiple input files and writing to
 > one output
 >
 > Hello,
 > I have a stylesheet that processes all xml documents in a
 > specified directory.
 >
 > My problem is a small one...
 >
 > During the creation of this stylesheet I used Oxygen as my
 > editor and I was able to configure the application to output
 > the results to a file.
 >
 > My question is how do I use properly use
 > <xsl:result-document> to output the results to a file so when
 > I am not calling the transformation from Oxygen, so a file
 > gets produced?
 >
 > I have tried to put the <xsl:result-document/> in a few
 > places with varying degrees of success. Rather than blindly
 > trying all sorts of silly permutations, I thought it would be
 > wise to get the right answer with an explanation as to how to
 > use the result-document instruction.
 >
 >
 > My stylesheet is as follows
 >
 > <?xml version="1.0" encoding="UTF-8"?>
 > <xsl:stylesheet
 > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0"
 >     xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml";
 >     xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint";>
 >
 >     <xsl:output  method="xml" indent="yes" />
 >
 >     <xsl:variable name="xmlResultsDirectory"
 > select="document('file:///c:/sean/xsl/MSWordDocument/')"/>
 >
 >     <!-- Main template-->
 >     <xsl:template
 > match="/w:wordDocument/w:body/wx:sect/wx:sub-section/w:tbl[w:t
 > r/w:tc/w:p/w:r/w:t
 > = 'Test Case ID #']" >
 >         <xsl:result-document href="output2.xml" >
 >             <xsl:element name="testresults">
 >                 <xsl:attribute name="testfile" >
 >                     <xsl:value-of select
 > ="tokenize(document-uri(/), '/')[last()]"/>
 >                 </xsl:attribute>
 >                 <xsl:for-each select="w:tr">
 >                     <xsl:choose>
 >                         <!-- Only process rows with a test case id.
 > They begin with TC- -->
 >                         <xsl:when
 > test="w:tc/w:p/w:r[starts-with(w:t,'TC-')]">
 >                             <xsl:element name="TestCase">
 >                                 <xsl:attribute name="TestID">
 >                                     <xsl:value-of
 > select="w:tc[1]/w:p/w:r/w:t"/>
 >                                 </xsl:attribute>
 >                                 <xsl:attribute name="result">
 >                                     <xsl:value-of
 > select="w:tc[6]/w:p/w:r/w:t"/>
 >                                 </xsl:attribute>
 >                                 <xsl:attribute name="DateExecuted">
 >                                     <xsl:value-of
 > select="w:tc[5]/w:p/w:r/w:t"/>
 >                                 </xsl:attribute>
 >                                 <xsl:attribute
 > name="CriticalIndicator">
 >                                     <xsl:value-of
 > select="w:tc[7]/w:p/w:r/w:t"/>
 >                                 </xsl:attribute>
 >                             </xsl:element>
 >                         </xsl:when>
 >                         <xsl:otherwise/>
 >                     </xsl:choose>
 >                 </xsl:for-each>
 >             </xsl:element>
 >         </xsl:result-document>
 >     </xsl:template>
 >
 >
 >     <!-- Only copy what I am interested in-->  <xsl:template
 > match="@* | node()" >
 >      <xsl:copy>
 >          <!-- execute against all documents in the directory
 > $xmlResultsDirectory -->
 >          <xsl:for-each select="collection(concat($xmlResultsDirectory,
 > '?select=*.xml'))">
 >              <xsl:apply-templates
 > select="/w:wordDocument/w:body/wx:sect/wx:sub-section/w:tbl[w:
 > tr/w:tc/w:p/w:r/w:t
 > = 'Test Case ID #']"/>
 >       </xsl:for-each>
 >   </xsl:copy>
 > </xsl:template>
 >
 > </xsl:stylesheet>
 >
 > I am using XSLT 2.0 - Saxon 8B as my processor
 >
 > Any insight is greatly appreciated
 >
 > Sean
 >
 > --~------------------------------------------------------------------
 > XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
 > To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
 > or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
 > --~--
 >


 --~------------------------------------------------------------------
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
 To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
 or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
 --~--





-- 
Sean Tiley
sean(_dot_)tiley(_at_)gmail(_dot_)com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>