Solved

Multiple XML files into one XSLT template.

Posted on 2001-06-21
4
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Wayne Bradney
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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, …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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