468,773 Members | 2,342 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,773 developers. It's quick & easy.

Combining two XML files for xslt transformation

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;
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;

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

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

Thanks a lot
Feb 27 '07 #1
7 12525
839 Expert 512MB
See this link. It may be easy to merge using a new XSL file.
Feb 27 '07 #2
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
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.

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

Did you solve your problem?
Mar 21 '07 #7
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

Post your reply

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

Similar topics

reply views Thread by Sergio del Amo | last post: by
6 posts views Thread by Pete | last post: by
reply views Thread by Dimitre Novatchev | last post: by
4 posts views Thread by Stephen | last post: by
4 posts views Thread by Philipp Reiss | last post: by
13 posts views Thread by Toby Newman | last post: by
12 posts views Thread by Meglio | last post: by
1 post views Thread by CARIGAR | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.