Solved

Multiple XML files into one XSLT template.

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now