Solved

Multiple XML files into one XSLT template.

Posted on 2001-06-21
4
381 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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 Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 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