Declare a namespace prefix in your stylesheet, e.g.
xmlns:ca="http://www.sas.com/xml/namespace/sas_doc_cas_actions-1.0",
and then select ca:actionSet,
$myActionSet/ca:casActions/ca:actionSet[1], etc.
On 14.04.2015 23:07, Craig Sampson craig.sampson@xxxxxxx wrote:
> Thanks to Gerrit and Michael I am closer but not quite all the way there
> yet.
>
>
>
> I removed the namespace from the second input file and modified my
> apply-templates to:
>
>
>
> *<**xsl:apply-templates
> **select*=/"$myActionSet/casActions/actionSet[1]"//*>*
>
> * *
>
>
>
> I now get to the actionSet templates.
>
>
>
> How do I include the namespace info in the apply-templates call? I donbt
> see how to do this so thatbs why I temporarily removed the namespace
> declaration from my second input and the declaration for it from my
> transform.
>
>
>
> Ibll try adding modes tomorrow to see if that also helps.
>
>
>
> Thanks,
>
> Craig
>
>
>
> *From:* Michael Kay [mailto:mike@xxxxxxxxxxxx]
> *Sent:* Tuesday, April 14, 2015 4:34 PM
> *To:* xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> *Cc:* Craig Sampson
> *Subject:* Re: Using doc( ) to get a second input file
>
>
>
>
>
> On 14 Apr 2015, at 21:15, Craig Sampson craig.sampson@xxxxxxx
> <mailto:craig.sampson@xxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
> <mailto: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/workspace/castest/xml/actions.xml'
> <file:///\\sashq\root\pub\pubs_xiswork\sascrs\prod\v16\eclipse\workspace\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.
>
>
>
> The usual way to solve this problem is with modes. Use
>
>
>
> *<xsl:apply-templates select*=/"$myActionSet" mode="actionSet"/*/>*
>
>
>
> and add mode="actionSet" to the template rules for the second input file.
>
>
>
>
>
>
>
> 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/workspace/castest/xml/actions.xml'
> <file:///\\sashq\root\pub\pubs_xiswork\sascrs\prod\v16\eclipse\workspace\castest\xml\actions.xml'>)//actionSet[@id=babcb]"/*/>*
>
> * *
>
> but that caused the function to fail and not fetch the second file.
>
>
>
> I think it did fetch the second file. But the path expression
> //actionSet didn't select anything, because the actionSet elements are
> in a namespace, and you didn't tell it to use a namespace.
>
>
>
> 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.
>
>
>
> Again, that's because you overlooked the namespace declaration.
>
>
>
> Any help would be appreciated in solving this problem.
>
>
>
>
>
> Note the
> namespace: xmlns="http://www.sas.com/xml/namespace/sas_doc_cas_actions-1.0"
>
>
>
> Michael Kay
>
> Saxonica
>
>
>
>
>
>
>
> <?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 <mailto:craig.sampson@xxxxxxx>
>
>
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>
> EasyUnsubscribe <-list/293509> (by email)
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <-list/225679>
> (by email <>)
--
Gerrit Imsieke
GeschC$ftsfC<hrer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930
GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard VC6ckler
|