xsl-list
[Top] [All Lists]

Re: [xsl] Can I see the main DOM from a doc() DOM?

2015-06-10 15:55:24
There is no implied "parent" relationship when invoking the doc() function. The trees are independent and have no connection. You can create a collection of doc() functions, but there is no sibling relationship. You can copy files into a new tree to create a sibling relationship, but that usually isn't worth the bandwidth to do so.

Using a tunnel parameter on the <xsl:apply-templates> you can pass your current position in file one down into the processing of file two, and then have it handy when in file two.

I typically set a global variable to be the first document's root, and then I always have it handy. This is helpful when, say, I need to look up a key table from the first file when I'm in the middle of the second file:

   key('table-name',look-up-value,$mainRoot)

I hope this helps.

. . . . . . . Ken

At 2015-06-10 19:58 +0000, Craig Sampson craig(_dot_)sampson(_at_)sas(_dot_)com 
wrote:
Hi All,
I am working on a transform that merges a second input (xml) file with the primary input (xml) file to create one deliverable. I am accessing the second input file using the doc() function. Is there a way to look up from the second input file to see attribute values in the first input file?

Here's a snippet of the primary input file:

<refBody>
<refActionSet actionSet="cas.tkcastab" eid="p19uxflykz04i4n166yzdl1o5osr">
<exampleBlock eid="n1nw8ix56o1qx5n1t8woivgwje9g">
<example eid="p0pzu6eop12af6n1j7dnjo7ripkd">


Here's a snippet of the second input file:

<actionSet id="cas.tkcastab" name="tkcastab" scriptname="tkcastab" prmname="tkcastab"> <label id="cas.tkcastab.__label" key="TKCASTAB_LABEL_LIBRARY">Tables and Files</label>
  <action id="cas.tkcastab.view" name="view" entry="View">
<label id="cas.tkcastab.view.__label" key="TKCASTAB_LABEL_VIEW">Create View</label> <desc id="cas.tkcastab.view.__desc" key="TKCASTAB_DESC_VIEW">Define a view from files or tables</desc>

When I am in the action template I want to get the exampleBlock's eid value. I get to the action when the refActionSet element in the primary input file is being processed by its template. The template contains the following: (note: the second file is in the "cas" namespace)

<xsl:variable name="myActionSet" select="doc(concat('file:',translate($casFile,'\','/')))"/> <xsl:apply-templates select="$myActionSet/cas:casActions"> <!-- in xisActionSet.xsl -->
  <xsl:with-param name="actionSetID" select="@actionSet"/>
</xsl:apply-templates>

I tried to get the exampleBlock eid value from the action template using:

<a href="{ancestor::refActionSet/exampleBlock/@eid}.htm">

But got nothing. If it isn't possible (doc is a function after all) to look up to the parent xml I can always pass the attribute value as a parameter from the refActionSet template.

Thanks,
  Craig

BTW I see the list in the digest view so I won't see any responses till tomorrow unless you include my email in your response to the list.
<mailto:craig(_dot_)sampson(_at_)sas(_dot_)com>craig(_dot_)sampson(_at_)sas(_dot_)com


<http://www.mulberrytech.com/xsl/xsl-list>XSL-List info and archive
<-list/96802>EasyUnsubscribe (<>by email)


--
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Free 5-hour lecture:  http://www.CraneSoftwrights.com/links/video.htm |
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                    
mailto:gkholman(_at_)CraneSoftwrights(_dot_)com |
Google+ profile:       http://plus.google.com/+GKenHolman-Crane/about |
Legal business disclaimers:     http://www.CraneSoftwrights.com/legal |


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>