473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Combining two XML files for xslt transformation

4
I’m able using Javascript to transform a XML file using XSLT to a nice HTML output. What I need to do now is to combine two XML files and transform them together using XSLT. Here an abstract example:
Load(xml1); Load(xml2);
Xml = xml1 + xml2;
Xml.transformNode(xslt);
In my xslt document I need to access then nodes from both xml documents therefore the combination (the select=”document(myXML)” in xslt is to late since I can’t use a path variable here) .

Any hint I much appreciated since I couldn’t find a solution in the web and with trying.

See below the html file(for Firefox)


// Load XSL
var processor = new XSLTProcessor();
var xslt = document.implementation.createDocument("", "", null);
xslt.async = false;
xslt.load("style.xsl");
processor.importStylesheet(xslt);

// Load XML
var src_doc = document.implementation.createDocument("","", null);
var src_doc1 = document.implementation.createDocument("","", null);
src_doc.async = false;
src_doc1.async = false;
src_doc.load("server.xml");
src_doc1.load("pool.xml");

// Transform
var result = processor.transformToDocument(src_doc + src_doc1); // it doesn’t work
var xmls = new XMLSerializer();
var output = xmls.serializeToString(result);
document.write(output);



Thanks a lot
Feb 27 '07 #1
7 12804
dorinbogdan
839 Expert 512MB
See this link. It may be easy to merge using a new XSL file.
Feb 27 '07 #2
dorinbogdan
839 Expert 512MB
It depends of the 2 xml structures if you want to merge or to concatenate them. See also these samples .
Feb 27 '07 #3
HP17
4
Thank you for this input.
But as mentioned i can't do it using xslt becasue i'm using a "path-variable" to read and convert the xml files. So the xml files will be always in a different location and the problem is that I'm using in one xslt file a reference from to an other xml file so select=”document(XML1)" but this path changes as well.
so my plan is to combine the xml files before and be able to access any other node lateron in the xslt file.
I hope there is also a way using JavaScript.

Thanks
Feb 27 '07 #4
dorinbogdan
839 Expert 512MB
You just need to use as a model the code from figure 1.
Feb 27 '07 #5
dorinbogdan
839 Expert 512MB
Also, you can use XSL for merge having the xml file names as parameters.
See this example.
Feb 27 '07 #6
dorinbogdan
839 Expert 512MB
Hi,

Did you solve your problem?
Mar 21 '07 #7
HP17
4
Sorry for the late feedback,

I could solve my issue with the the help of the parameter. in transformation i add a "path" parameter to the docProcessor which i'm able to access the via <xsl:param name="path" /> and <xsl:value-of select="$path">.


Thank you once more for the help.
Jun 27 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
0
by: Dimitre Novatchev | last post by:
You seem to be unaware of the xslt processing which uses the built-in rules in the absence of templates that match some selected node. http://www.w3.org/TR/xslt#built-in-rule According to the...
1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
4
by: Stephen | last post by:
I have the following that outputs an xml file to a div using ajax: <script type="text/javascript"> function ajaxXML(url,control_id){ if (document.getElementById) { var x =...
3
by: Showjumper | last post by:
I need to do a transform using 2 xsl files? How would i go about this? This is what am doing now - just a single transform. Dim XMLDoc As New XmlDocument...
4
by: Philipp Reiss | last post by:
Hello group, I'm new in this topic and I run into problems where google can't help me. I have a XML-file, wich is bound to a XSLT-file, and this works fine in a browser. How do I show the same...
13
by: Toby Newman | last post by:
I started learning XML on Monday. I have an XML file and have written an XSL file to render it to HTML for formatted viewing in a browser. I'd like to create a second alternative view of the...
12
by: Meglio | last post by:
Hi. I'm going to make in auto some tasks that I'm doing manually every day. I'm uploading big XML file (~20mb) and then I'm using XSLT schema to transform it to MySQL queries file. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.