473,769 Members | 6,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combining two XML files for xslt transformation

4 New Member
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.transformNo de(xslt);
In my xslt document I need to access then nodes from both xml documents therefore the combination (the select=”documen t(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.implem entation.create Document("", "", null);
xslt.async = false;
xslt.load("styl e.xsl");
processor.impor tStylesheet(xsl t);

// Load XML
var src_doc = document.implem entation.create Document("","", null);
var src_doc1 = document.implem entation.create Document("","", null);
src_doc.async = false;
src_doc1.async = false;
src_doc.load("s erver.xml");
src_doc1.load(" pool.xml");

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



Thanks a lot
Feb 27 '07 #1
7 12832
dorinbogdan
839 Recognized Expert Contributor
See this link. It may be easy to merge using a new XSL file.
Feb 27 '07 #2
dorinbogdan
839 Recognized Expert Contributor
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 New Member
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=”documen t(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 Recognized Expert Contributor
You just need to use as a model the code from figure 1.
Feb 27 '07 #5
dorinbogdan
839 Recognized Expert Contributor
Also, you can use XSL for merge having the xml file names as parameters.
See this example.
Feb 27 '07 #6
dorinbogdan
839 Recognized Expert Contributor
Hi,

Did you solve your problem?
Mar 21 '07 #7
HP17
4 New Member
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
2712
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 extension responsible for the xslt functions. The problem i have is that the obtained transformation is not the waited one. I try to proccess the same XML file with XSL file with a program called XMLspy and i obtained the desire and waited...
6
2747
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 straight XML file http://www.discovertravelandtours.com/test/templates/test.xml?Location=Germany To another XML file http://www.discovertravelandtours.com/test/templates/test2.xml?Location=Germany
0
2086
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 XSLT processing model: http://www.w3.org/TR/xslt#section-Processing-Model the root node will be processed by a built-in rule, because you do not
1
3109
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 Transformer convert that via XSLT to valid XSL-FO. So I define a SAXReader which fires the SAX Events for the Java Object. This works fine and the Transformation to PDF is ok. However, I have one object which contains an XHTML String and the tags
4
5243
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 = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); } if (x) {
3
2368
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 XMLDoc.Load(Server.MapPath("files/rdxmltemplate.xml")) Dim XSLTrans As New Xsl.XslTransform XSLTrans.Load(Server.MapPath("files/nitf-rd.xsl")) Dim ms As New MemoryStream XSLTrans.Transform(XMLDoc, Nothing, ms, Nothing) ms.Seek(0, SeekOrigin.Begin) Dim sr As New StreamReader(ms)
4
1745
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 XML-file with an other XSLT-file? Thanks for your help! Philipp
13
9633
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 same data. I am confused how: If the following line, which dictates which XSL file should be used to transform my XML document for me, is found *in the XML file itself* then how can you use more than one XSL to present multiple views of the same...
12
3356
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 used 3rd tools to process XSLT and it takes few seconds to process my big XML file. But now I'm moving to PHP so I'm trying to use XSL PHP extension to
0
9589
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...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9998
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
6675
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
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
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
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.