[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Processing multiple input files and writing to one out

Subject: Processing multiple input files and writing to one output
From: "Sean Tiley" <sean.tiley@xxxxxxxxx>
Date: Thu, 20 Mar 2008 09:41:46 -0400
 Processing multiple input files and writing to one out
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:tr/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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.