[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Using doc( ) to get a second input file


Subject: Re: [xsl] Using doc( ) to get a second input file
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 14 Apr 2015 20:30:33 -0000

>  My transform fails due to the root element template being executed a
> second time.


A neat general way to avoid such problems is to use modes.

So, instead of:

     <xsl:apply-templates select="$myActionSet"/>

use:

    <xsl:apply-templates select="$myActionSet" mode="doc2OrABetterName"/>

And, you need to provide a different matching template (in the specified
mode).

Cheers,
Dimitre

On Tue, Apr 14, 2015 at 1:15 PM, Craig Sampson craig.sampson@xxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi All,
>
>   I am trying to use the doc( ) function, in XSLT 2.0, to get a second
input
> file in one of my transforms. The primary input contains an element
> brefActionSetb that triggers the logic to fetch the second input.
>
>
>
>   Within that template I do:
>
>
>
>         <xsl:variable name="myActionSet"
>
>
>
select="doc('file://sashq/root/pub/pubs_xiswork/sascrs/prod/v16/eclipse/works
pace/castest/xml/actions.xml')"/>
>
>
>
>   Which is successfully getting the second file. I know this because I can
> write out to the log the contents of the file and I see the text (no
> markup).
>
>
>
>   But when I try to process this second file using:
>
>
>
>         <xsl:apply-templates select="$myActionSet"/>
>
>
>
>   My transform fails due to the root element template being executed a
> second time. In the root template I setup some java extension processes
that
> can only be run once so the second time through they cause the transform to
> fail.
>
>
>
>   Ibve tried to solve the problem two different ways, but neither works.
> First I tried adding a xpath specification to the doc function so that the
> returned XML would start at the element I was interested in, like so:
>
>
>
>         <xsl:variable name="myActionSet"
>
>
>
select="doc('file://sashq/root/pub/pubs_xiswork/sascrs/prod/v16/eclipse/works
pace/castest/xml/actions.xml')//actionSet[@id=babcb]"/>
>
>
>
> but that caused the function to fail and not fetch the second file. I also
> tried a fragment specification b#actionSetb but this also failed.
>
>
>
>   I then tried to kick the second input files root element out of my root
> template with a test for ancestor-or-self::casActions and a test for
> descendant-or-self::casActions. But neither of these tests worked on the
> fetched second file.
>
>
>
>   Any help would be appreciated in solving this problem.
>
>
>
>
>
> Herebs a few lines from the second input file that I am trying to
process.
> It does have a namespace and I wonder if that could be part of the problem
> since my first input file is in no namespace.
>
>
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <casActions version="1.0" xml:lang="en"
> xmlns="http://www.sas.com/xml/namespace/sas_doc_cas_actions-1.0" date="Tue
> Apr 14 07:31:01 2015" branch="v9cas">
>
>    <actionSet id="cas.tkds1" date="Mon Apr 13 22:18:33 2015" name="tkds1"
> dvdname="cas" scriptname="tkds1" prmname="tkds1">
>
>       <label id="cas.tkds1.__label" key="TKDS1_LABEL_LIBRARY" dvd="cas"
> msgfile="tkmds1">DATA Step</label>
>
>       <action id="cas.tkds1.execPgm" name="execPgm" entry="execpgm">
>
>          <label id="cas.tkds1.execPgm.__label" key="TKDS1_LABEL_EXECPGM"
> dvd="cas" msgfile="tkmds1">Execute DATA Step</label>
>
>
>
>
>
> Thanks for the help,
>
>   Craig
>
>
>
> BTW I follow this list in the daily digest so I wonbt see any responses
till
> tomorrow unless you copy me in your response to the list.
>
> My email is: craig.sampson@xxxxxxx
>
>
>
>
>
> XSL-List info and archive
> EasyUnsubscribe (by email)



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.


Current Thread
Keywords