Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Processing multiple documents

From: "bryan rasmussen" <rasmussen.bryan@--------->
To:
Date: 3/1/2008 8:31:00 AM
<xsl:apply-templates select="$doc2/xpath follows here"/>

Cheers,
Bryan Rasmussen
On Fri, Feb 29, 2008 at 9:38 PM, Sean Tiley <sean.tiley@xxxxxxxxx> wrote:
> Hello,
>  I created a XSL 2.0 stylesheet that processes a MS Word document
>  (saved in xml format).
>
>  Basically I am extracting information,(test case results), from a
>  table in the document to create xml output in the following format
>
>  <?xml version="1.0" encoding="UTF-8"?>
>  <?mso-application progid="Word.Document"?>
>  <w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
>                 xmlns:v="urn:schemas-microsoft-com:vml"
>                 xmlns:w10="urn:schemas-microsoft-com:office:word"
>                 xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
>                 xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
>                 xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
>                 xmlns:o="urn:schemas-microsoft-com:office:office"
>                 xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
>                 xmlns:st1="urn:schemas-microsoft-com:office:smarttags">
>    <testresults testfile="TestScript.xml">
>       <TestCase TestID="TC-01" result="Pass" DateExecuted="2008.02.27"
>  CriticalIndicator="Y"/>
>       <TestCase TestID="TC-02" result="Pass" DateExecuted="2008.02.27"
>  CriticalIndicator="Y"/>
>       <TestCase TestID="TC-03" result="Pass" DateExecuted="2008.02.27"
>  CriticalIndicator="N"/>
>       <TestCase TestID="TC-04" result="Pass" DateExecuted="2008.02.27"
>  CriticalIndicator="N"/>
>       <TestCase TestID="TC-05" result="Pass" DateExecuted="2008.02.27"
>  CriticalIndicator="N"/>
>    </testresults>
>  </w:wordDocument>
>
>
>
>  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" />
>
>     <!-- 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: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:template>
>
>     <!-- If this is not here I get alot of additional info I do not want-->
>     <xsl:template match="@* | node()">
>         <xsl:copy>
>             <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:copy>
>     </xsl:template>
>  </xsl:stylesheet>
>
>
>  All this works fine.
>  My issue now is that I want to process multiple documents and merge in
>  <TestCase/> elements from another test result document.
>
>  I know there is the document() function that I can use like the following
>  <xsl:variable name="doc2" select="document('another.file.xml')
>
>  But I am at a loss as to how to tell the processor to apply the
>  template to that doc as well.
>
>  Once I figure that out, I would like to be able to generalize this to
>  process 1 to N documents in a given directory.
>
>  Any guidance is greatly appreciated
>
>  --
>  Sean Tiley
>  sean.tiley@xxxxxxxxx


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent