473,804 Members | 2,673 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

returning to the main input document from XSLT

Say I am in an XSLT template with the context node set to a node from an
alternative document (i.e. read by the document() function). Is there any
way to select nodes from the original document again?

e.g.

<xsl:template match="foo">
<xsl:apply-templates select="documen t(doc.xml)" mode="otherdoc" />
</xsl:template>

<xsl:template match="bar" mode="otherdoc" >
now my context node is a node in doc.xml. how can I select a node from the
main document?
</xsl:template>

Andy
Jul 20 '05 #1
2 1384


Andy Fish wrote:
Say I am in an XSLT template with the context node set to a node from an
alternative document (i.e. read by the document() function). Is there any
way to select nodes from the original document again?

e.g.

<xsl:template match="foo">
<xsl:apply-templates select="documen t(doc.xml)" mode="otherdoc" />
You could pass a parameter with the main root node (or any other nodes
you want to pass) e.g.
<xsl:apply-templates select="documen t(doc.xml)" mode="otherdoc" >
<xsl:with-param name="primary-root" select="/" />
</xsl:apply-templates>

<xsl:template match="bar" mode="otherdoc" >


<xsl:template match="/" mode="otherdoc" >
<xsl:param name="primary-root" />
<!-- access $primary-root or descendants e.g.
$primary-root/* here
-->
</xsl:template>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Martin Honnen <ma*******@yaho o.de> writes:
Andy Fish wrote:
Say I am in an XSLT template with the context node set to a node from an
alternative document (i.e. read by the document() function). Is there any
way to select nodes from the original document again?

e.g.

<xsl:template match="foo">
<xsl:apply-templates select="documen t(doc.xml)" mode="otherdoc" />


You could pass a parameter with the main root node (or any other nodes
you want to pass) e.g.

or (simpler) define
<xsl:variable name="origroot" select="/"/>
as a global variable outside any template then it is available in all
templates without having to be explictly passed from one to the other.

If there are lots of documents and nested calls from one to the other
then of course you do need to explictly pass parameters with the nodes
giving the right context and Martin's more general solution is your
friend in that case.

David
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4257
by: Christian Roth | last post by:
Hello, when using this "identity" processing sheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="iso-8859-1" /> <xsl:template match="@*|node()">
3
2126
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim is to process the contacts in a single-pass XSLT process. That is why the "document()" function is what I need. I call the "document()" XPath function from a "for-each" instruction.
3
1961
by: Filip Hendrickx | last post by:
Hi all. I am processing two documents with an XSLT, one is the input document, the other is loaded with the document() function in a variable $doc2. Inside a template that matches an element from $doc2, I need to check a value from the original input document. However, inside this template, the context is $doc2. What XPath expression should I use to refer to the input document? I've tried using /inputNamespace:inputElement, where...
3
1913
by: msnews.microsoft.com | last post by:
Hi Does anybody know if XSLT can process several XML file at a time I have two xml document which stored in memory stream and wanna to combine it together under several rules. I am tring to use a XSLT file but donon how to process several xml at a time
3
2012
by: thomas.porschberg | last post by:
Hi, I want to read records from a database and export it in an arbitrary format. My idea was to feed a class with a String array fetched from the database and let this class fire SAX events as processor input. The basic class hierarchy is:
3
1919
by: Greg | last post by:
Hi, I want to create a web based interface that uses a form + Javascript (in an XHTML namespace) to construct an XPath to query and modify the attributes of some SVG (in an SVG namespace). There are lots of Google hits on each of these specifications and related technology, shuch as namespaces but there's almost nothing I can find that shows useful examples of the different ways they might be combined?
12
11604
by: Chris | last post by:
Hi, Just wondering if anyone out there knows if it is possible to convert a CSV to xml using XSLT? I've seen a lot of examples of xml to CSV, but is it possible to go back the other way? I don't want to have to use some external program or script to parse the csv first if possible
3
7916
by: H. Martins | last post by:
I need to use command line input to a tinny c# application: It goes like this: ** program.cs ** using System; using System.Collections.Generic;
2
1501
by: dutone | last post by:
Is it possible to use a template and then, in the same transformation, reuse it for a call to document()? I have a document that has a child. If necessary, I need to include another document's (same structure) child. I'd like to reuse a template but it doesn't seem to be working out for me. <xsl:template match="/root"> <id><xsl:value-of select="name"/></id> <children>
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10315
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.