xsl-list
[Top] [All Lists]

Re: [xsl] Processing multiple documents

2008-03-01 05:21:05
Sean Tiley wrote:

  Hi

 <xsl:variable name="doc2" select="document('TestScript2.xml')"/>
 <xsl:variable name="wordposition"
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:apply-templates select="$wordposition"/>
            <xsl:apply-templates select="$doc2/$wordposition"/>

  $wordposition is not a kind of path that is evaluated each time it is
used, depending on the context.  The variable is bound to a sequence,
holding some values (in this case zero or more w:tbl elements).

  The context item of a global variable is the document node of the
main input, so the w:tbl element is from this document.  If you want
the same expression to be evaluated within the context of the second
document, use the path explicitely:

    <xsl:variable name="wordposition2" select="
        $doc2/w:wordDocument/w:body/..."/>

  But if you want to reuse the path and evaluates it to different
contexts, use a function:

    <xsl:function name="my:word-position" as="element(w:tbl)">
       <xsl:param name="doc" as="document-node()"/>
       <xsl:sequence select="
           $doc2/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:function>

and use it like that:

    <xsl:apply-templates select="(/, $doc2)/word-position(.)"/>

  Regards,

--drkm






















      
_____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
http://mail.yahoo.fr


--~------------------------------------------------------------------
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>