Re: [xsl] Processing multiple documents

Subject: Re: [xsl] Processing multiple documents
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Sat, 1 Mar 2008 13:20:40 +0100 (CET)
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

Current Thread