I don't think I see enough of your files to give you a complete answer, but you
can read the external file into the XSLT with the document() function, as in
<xsl:variable name="updates" select="document('updates.xml')" />
From this point on in your XSLT file, you can refer the value of /updates/elem
[(_at_)xpath="/employee/address/country" ]/@xvalue from the external document
as
<xsl:value-of select='$updates/updates/elem
[(_at_)xpath="/employee/address/country" ]/@xvalue' />
which should return the string "USA".
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
-----Original Message-----
From: Jianyu Lai <jlai(_at_)esri(_dot_)com>
Sent: Tue, 1 Feb 2005 08:57:59 -0800
To: "'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'"
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: [xsl] Merging two xml documents using xslt
Hi all,
I'm rather new to XSL. I am struggling trying to come up with an xslt to
solve the following problem:
First I have the source xml that looks like this:
<employee>
<name>
<first>Bob</first>
</name>
</employee>
I have another xml (updates.xml) that contains information about how to
update the above source. Notice that this updates.xml is dynamically
generated, and its contents vary.
<updates>
<elem xpath="/employee/address/country" xvalue="USA" />
<elem xpath="/employee/name/first" xvalue="Bill" />
</updates>
I want to write an xslt that reads information from updates.xml, and updates
source.xml based on these criteria:
- if xpath in updates.xml exist in source.xml, replace source xml node with
xvalue;
- otherwise, create xml node in source(recursively if necessary), with
xvalue defined in updates.xml;
Basically here is the result xml that I need:
<employee>
<name>
<first>Bill</first>
</name>
<address>
<country>USA</country>
</address>
</employee>
Is this something that can be done by xslt? If so, could any one shed some
light on this? Your help is greatly appreciated.
Jianyu Lai
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--