Solved

Multiple XML files into one XSLT template.

Posted on 2001-06-21
4
379 Views
Last Modified: 2008-03-03
Is it possible to input 2 or more XML documents into one XSLT template.

I have to XML file and i would like to create one XML file as the result.

Is this possible ?  I am using Xanlan.
0
Comment
Question by:jefftk
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
djokov earned 300 total points
ID: 6218091
Yes, it is possible:
If you want to input XML file into another XML, use:
<!DOCTYPE document_element [
<!ENTITY second SYSTEM "secondfile.xml">
<!ENTITY other SYSTEM "otherfile.xml">
]>
after <?xml version="1.0"?> which is the top of any XML file and then, anywhere in the file after the root you could use:
&second; or
&other;
in order to include XML file 'secondfile' in the current XML file. 'document_elemnt' is the name of the root element of your xml file.

If you want to include one stylesheet into another, you should use:
<xsl:include href="templateHeader.xsl"/>

In your case you should include one of the XML files into another and then to execute transformation with Xalan and a stylesheet. So your main xml file that you should pass to Xalan as a input xml file will look as:

<?xml version="1.0"?>
<!DOCTYPE blabla [
<!ENTITY second SYSTEM "secondfile.xml">
]>

<blabla>
<something>.....
.....
</something>
&second;
</blabla>

Hope it will help.

Regards,
Djokov
0
 

Author Comment

by:jefftk
ID: 6218549
Hi Djokov,

Here is my issue, I have a servlet that reads in a character stream of data from a client.  This character stream is an XML message.  I will open the stream and read the data and act on the message.

When i am done processing this message i need to send a response XML message.  I would like to use XSLT to create the response XML.  
My inputs to the XSLT processor will be the input XML message and a small XML message i created when i processed the input XML.

These two inputs will reside in memory and not on disk.
I believe i can do this if I transform the XML twice.  First using the input XML and then a second time using the new XML.  However, this would require two stylesheets and two transforms.

Can this be done in one pass ?
Any examples would be appreciated.
0
 

Author Comment

by:jefftk
ID: 6232588
Hi Djokov,

Do you have any comments for my last comment ?
0
 
LVL 6

Expert Comment

by:wbradney
ID: 6233480
jefftk,

You could include your small XML file into your larger one by just appending the documentElement of the smaller XML document under the documentElement of the larger one. Then you have all of the XML in a single document and a single stylesheet can transform it.

Before appending, you'll need to importNode first. By default, nodes aren't allowed to cross DOM boundaries.

Regards,
WMB
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question