Combine several XML files with same structure
Hello,
I have several XML files with the same structure and I want to combine them and create a new XML file to be bale to compare that information easily. It does not look very difficult but as I am very new in this I am not bale to get it
The structure of my actual files would be something simlar to:
Root->...-> Name->Address, Telephone
And what I would like to have si something like
Root->.... ->Address-> Name 1,Name 2....
Root -> ...->Telephone-> Name 1, Name 2....
Does anyone know how to do this.
Thanks
You could write a XSL transformation file that does this and transform your input file via
* Transform XML file with a style sheet.
* <p><b>Example:</b><p>
<table align="center" bgcolor="#E0E0E0" border=1 cellpadding="10" cellspacing="0"><tr><td><pre style="margin-top:0; margin-bottom:0">
XMLTransformer t = new XMLTransformer();
FileOutputStream fos = new FileOutputStream("C:/Project/result.html");
String xmlFile = "C:/Project/source.xml";
String styleSheet = "C:/Project/stylesheet.xsl";
t.transform(xmlFile, styleSheet, fos);
</pre></td></tr></table>
* @param xmlfile The XML file to transform.
* @param style Stylesheet to use for transformation.
* @param outputStream OutputStream to write the transformed result to.
public void transform(String xmlfile, String style, OutputStream outputStream) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//factory.setNamespaceAware(true);
//factory.setValidating(true);
//todo: use inputstreams instead of file names
try {
File stylesheet = new File(style);
File datafile = new File(xmlfile);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(datafile);
// Use a Transformer for output
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamSource stylesource = new StreamSource(stylesheet);
Transformer transformer = tFactory.newTransformer(stylesource);
DOMSource source = new DOMSource(document);
StreamResult sr = new StreamResult(outputStream);
transformer.transform(source, sr);
} catch (TransformerConfigurationException tce) {
// Error generated by the parser
System.out.println ("\n**XMLTransformerr Factory error");
System.out.println(" " + tce.getMessage() );
// Use the contained exception, if any
Throwable x = tce;
if (tce.getException() != null) {
x = tce.getException();
x.printStackTrace();
} catch (TransformerException te) {
// Error generated by the parser
System.out.println ("\n** Transformation error");
System.out.println(" " + te.getMessage() );
// Use the contained exception, if any
Throwable x = te;
if (te.getException() != null) {
x = te.getException();
x.printStackTrace();
} catch (SAXException sxe) {
// Error generated by this application
// (or a parser-initialization error)
Exception x = sxe;
if (sxe.getException() != null) {
x = sxe.getException();
x.printStackTrace();
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
pce.printStackTrace();
} catch (IOException ioe) {
// I/O error
ioe.printStackTrace();
}//transform()
Similar Messages
-
Mergeing files of same structure to one file without BPM
Hi XI Gurus,
I want to merge various xml files having same structures(coming as separate files in source directory) to a one file. I want to do it without using BPM.I need this Final structure as an input to another scenario to post an idoc.
e.g -->
<i>File1</i>:
<AR_Posting>
<currency_line_item>1<currency_line_item>
<tax_line_item>2<tax_line_item>
<customer_line_item>3<customer_line_item>
<AR_Posting>
<i>File 2</i>:
<AR_Posting>
<currency_line_item>11<currency_line_item>
<tax_line_item>22<tax_line_item>
<customer_line_item>33<customer_line_item>
<AR_Posting>
<i>File 3</i> :
<AR_Posting>
<currency_line_item>111<currency_line_item>
<tax_line_item>222<tax_line_item>
<customer_line_item>333<customer_line_item>
<AR_Posting>
Target:
<Recordset>
<AR_Posting>
<currency_line_item>1<currency_line_item>
<tax_line_item>2<tax_line_item>
<customer_line_item>3<customer_line_item>
<AR_Posting>
<AR_Posting>
<currency_line_item>11<currency_line_item>
<tax_line_item>22<tax_line_item>
<customer_line_item>33<customer_line_item>
<AR_Posting>
<AR_Posting>
<currency_line_item>111<currency_line_item>
<tax_line_item>222<tax_line_item>
<customer_line_item>333<customer_line_item>
<AR_Posting>
<Recordset>
Please suggest any solution to achieve this.Hi Anurag,,
I guess what Sumit is aiming for, is that if you don't want to use a BPM you will need a two step solution.
Step one:
If the different files have the same structure, read them with a sending file adapter and route the to an receiving file adapter which appends all messages to a new combined file.
Step two:
Read the new combined file with a sending file adapter and route the messages to your target interface.
This approach of-course means that you can not do any correlations as you can in BPM. I.e. you will not "know" when all three files have arrived but just simply read the combined files at certain times and pick-up whatever content it holds.
rgds Johan -
Combining Multiple XML files to use in Flash
I am still fairly new at the whole Flash...XML thing but I
was wondering if it is possible to combine several XML files used
to build photo galleries into one single XML file that Flash could
then read which gallery depending on which gallery is selected.
Basically I have about 10 photo galleries and 10 XML files. Each
XML file is named different and in Flash I have the gallery calling
the XML file. I was thinking it would clean things up a lot and
make editing easier if I can some how make one XML with all the
galleries contained inside the XML then write a variable or
something so Flash knew which gallery to open when activated.
Similar to how you have to write the variables for a text doc file.
Any help would be great.
DHi Nasakick - take a look at this tutorial; essentially
you'll end up with what you need after inserting another layer of
more of the same:
http://www.kirupa.com/web/xml/examples/portfolio.htm
Hope that helps!
Cheers
A -
Can you add to the Lightroom an ability to process several raw files with the same content but with different exposure into the single picture?
Base raw files can be given with exposure bracketing during shooting, for example.
The goal - to get maximum details in darks and lights (if we use the "ligths recovery" or "fill lights" we lose the quality because raw file just have no all required information).
The similar (but not the same, only the idea) thing - is High Dynamic Range Photography in Adobe Photoshop
Thank youThe plugin LR/Enfuse does this already. And of course Photomatix have a plugin available for Lightroom. This essentially amounts to pixel editing, which is beyond the range of Lightroom's metadata editing.
-
One to many xml files with file adaptor
Hi,
I have a scenario HCM-ABAPProxy--XI-File for one structure I need to generate multiple xml files with 100 records per file.
this is my input messag
MT_in
Node
PositionIDs
descrption
job
IsActive
what I was doing on the ABAP side for every node I have 100 PositionID's sub nodes. so each node should be a sperate file.
my output structure is
PositionIDs
PositionID
pid
description
job
so there should be one PositionIDs per file which contains 100 PositionID.
I've multi message mapping without BPM that did not work out just wondering if any one came across the same scenario.
thanks,
JoeYou can not create multiple files without BPM. You can pretty much perform multi mapping to achieve your split but to write it to a file, you will have to call the file adapter for each split which you can not do without using BPM. In BPM, for each split that you perform, you can use a send step in for-each loop which will give you the functionality you require.
Award if helpful,
Sarath. -
How do I combine several pdf files into a single file (MAC OS)?
How do I combine several pdf files into a single file ?
MAC OS 10.6.8
Adobe Reader 11.0.10
Signed: Ken, in UtahNot possible with Reader. You need Acrobat or a subscription to something like PDF Pack to do it.
-
Steps in converting a xml file with an rtf template to a pdf
Hey all,
What are the steps in converting a xml file with an rtf template to a pdf using XML Publisher from command line.
Thanks
RaviI don't have any code to do exactly what you wish, but it shouldn't be too difficult and http://www.dadhi.com/2007/06/generate-and-store-pdf-file-in-same.html is a good starting point.
Paul -
Generation of Xml file with java output
Hi i m new to xml and java combination. I have a name value pair kind of output returning from java program. I want to generate the new xml file with the data. Could some one help me out in generating xml file with the data. Could anyone send me the java code that does this task.
Let me know which parser are you using currently for reading xml files so that i assist you. For now, you can refer to STAX Parser API under this link
http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP3.html -
Transforming XML File to abap structure
Hello,
I am working in a new project for making an input interface.
The problem to resolv is :
1>Reading an XML file on a unix Server
2>Transforming this file in abap structure with the instruction
call transformation.
Format of the input file :
<LISTEART>
<ART code="A01" label="Designation A01"/>
<ART code="A02" label="Designation A02"/>
<ART code="A03" label="Designation A03"/>
<ART code="A04" label="Designation A04"/>
<ART code="A05" label="Designation A05"/>
</LISTEART>
Format of the abap structure :
DATA : BEGIN OF ws_art,
code(4) TYPE c,
label(3) TYPE c,
END OF ws_art.
DATA : wt_art LIKE ws_art OCCURS 0 WITH HEADER LINE.
is it possible to transform the input file to an internal table
with the call transformation ?
CALL TRANSFORMATION transfo
SOURCE XML xml_string
RESULT para = result.
Somebody can explain me how to create links between xml file
and abap structure ?
with regards
JLuc Ledoux
[email protected]Hi,
try like this.
TYPES: BEGIN OF day,
name TYPE string,
work(1) TYPE c,
END OF day.
DATA: BEGIN OF week,
day1 TYPE day,
day2 TYPE day,
day3 TYPE day,
day4 TYPE day,
day5 TYPE day,
day6 TYPE day,
day7 TYPE day,
END OF week.
DATA xml_string TYPE string.
DATA result LIKE week.
week-day1-name = 'Monday'. week-day1-work = 'X'.
week-day2-name = 'Tuesday'. week-day2-work = 'X'.
week-day3-name = 'Wednesday'. week-day3-work = 'X'.
week-day4-name = 'Thursday'. week-day4-work = 'X'.
week-day5-name = 'Friday'. week-day5-work = 'X'.
week-day6-name = 'Saturday'. week-day6-work = ' '.
week-day7-name = 'Sunday'. week-day7-work = ' '.
CALL TRANSFORMATION ...
SOURCE root = week
RESULT XML xml_string.
CALL TRANSFORMATION ...
SOURCE XML xml_string
RESULT root = result.
Regards,
Vijay -
Can i have xml elements with same name but one is having attrbt..?
Hi all,
I am suppose to take input from one system into BPEL.That system is auto gererating xml file. But that file is strange. It has two xml element with
same name but with completely different sequence. First one is having two comlexTypes while second is having 5 simple types.
Now the difference is First element is having attribute while second is not.
So is that file is correct.?
thanks a lot.
/mishitcan you post the file? or load the file into JDeveloper and check the syntax or use XMLSpy for validation of the XML.
-
How to parse XML file with namesapce?
Hi,
I am trying to parse an xml file having namespace. But no data is returned.
Sample Code:
public class XMLFileLoader
var xml:XML = new XML();
var myXML:XML = new XML();
var XML_URL:String = "file:///C:/Documents and Settings/Administrator/Desktop/MyData.xml";
var myLoader:URLLoader = null;
public function XMLFileLoader()
var myXMLURL:URLRequest = new URLRequest(XML_URL);
myLoader= new URLLoader(myXMLURL);
myLoader.addEventListener(Event.COMPLETE,download);
public function download(event:Event):void
myXML = XML(myLoader.data);
var ns:Namespace=myXML.namespace("xsi");
for(var prop:String in myXML)
trace(prop);
//Alert.show(myXML..Parameters);
//trace("Data loadedww."+myXML.toString());
//Alert.show(myXML.DocumentInfo.attributes()+"test","Message");
The XML Contains the following format.
<Network xmlns="http://www.test.com/2005/test/omc/conf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.test.com/2005/test/omc/conf/TestConfigurationEdition3proposal4.xsd">
<TestDomain>
<WAC>
<!--Release Parameter -->
<Parameters ParameterName="ne_release" OutageType="None"
accessRight="CreateOnly" isMandatory="true"
Planned="false"
Reference="true" Working="true">
<DataType>
<StringType/>
</DataType>
<GUIInfo graphicalName="Release"
tabName="All"
description="Describes the release version of the managed object"/>
</Parameters>
</TestDomain>
</Network>
Any sample code how to parse this kind of xml file with namespaces...
Regards,
Purushothami have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
screenshot -
Loading XML file with missing elements dynamically through ODI
Hi Guys ,
I have the below xml file with two nodes Employee and Address. On a daily basis , sometimes the address element might not come in from the source xml file , but my interface has columns mapped to address elements, and hence it can fail due to the source element not being found in the file or data might not get loaded due to the 'and' condition in the sql query generated between the employee and address elements. Is there a way where i can load the data dynamically where i can search in the file only for the elements (Employee) present and load data only for those elements dynamically?
XML File:
<?xml version="1.0" encoding="UTF-8" ?>
<EMP>
<Empsch>
<Employee>
<EmployeeID>12345</EmployeeID>
<Initials>t</Initials>
<LastName>john</LastName>
<FirstName>doe</FirstName>
</Employee>
<Address>
<WorkPhone>12345</WorkPhone>
<WorkAddress>Test 234</WorkAddress>
</Address>
</Empsch>
</EMP>
Thanks ,
Revanth TambisettyI was able to resolve it by using left outer joins and referring the table structure from the XSD
-
How do you display xml file with xlst sheet in jsp
I have an xml file with accompanying xslt file (and several images that are used in a single directory. If I doubleclick on the xml file, it displays perfectly in my browser - Formatting, images and all!
The 100 dollar question - How do I duplicate this behavior in a JSP page in WebLogic 8.1 using the code in the xml and the accompanying xslt (formatting) file? I tried simple embedding the xml code in the jsp, but that didn't seem to work. What is the secret?
Okay, I need to add a bit more information here. I understand that it is really easy to just redirect to the XML file. The issue is really security. I want the XML to be inside a jsp that will only allow validated users to view it.
Another way to look at the problem would be, can I add a jsp security tag to the xml file? Or how to I add the xml code inside a jsp and keep the path references to the xslt and graphics.
Hope the added information helps
Thanks,
Ken
Message was edited by: KLee - 20050609 10:25 MST
[email protected]This proved out to be the answer. Thanks for the direction!
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class XML_XSLT_Servlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String xmlfile = req.getParameter("xmlfile"); if (xmlfile==null) xmlfile = "test.xml";
String xsltfile = req.getParameter("xsltfile"); if (xsltfile==null) xsltfile = "test.xslt";
/* Test if file exists!, or use default file */
File f1 = new File(getServletContext().getRealPath("WEB-INF/displayfiles/"), xmlfile);
File f2 = new File(getServletContext().getRealPath("WEB-INF/displayfiles/"), xsltfile);
if (f1.exists() && f2.exists()) {
// System.out.println("Files Found");
} else {
System.out.println("XML and XSLT Files NOT Found");
System.out.println(f1.getPath());
System.out.println(f1.getName());
xmlfile = "test.xml";
xsltfile = "test.xslt";
InputStream fileXML = getServletContext().getResourceAsStream("WEB-INF/displayfiles/" + xmlfile);
InputStream fileXSLT = getServletContext().getResourceAsStream("WEB-INF/displayfiles/" + xsltfile);
OutputStream os = res.getOutputStream();
TransformerFactory xFactory = TransformerFactory.newInstance();
StreamSource stylesheet = new StreamSource(fileXSLT);
Transformer xformer = null;
try {
xformer = xFactory.newTransformer(stylesheet);
} catch (TransformerConfigurationException tfce) {
tfce.printStackTrace();
StreamSource input = new StreamSource(fileXML);
StreamResult output = null;
try {
output = new StreamResult(os);
} catch (Exception e) {
e.printStackTrace();
try {
xformer.transform(input, output);
} catch (TransformerException xfe) {
xfe.printStackTrace();
<pre></pre><pre></pre> -
1 xml file to multiple xml files with 200 records in each
Hello Experts,
I have below scenario.
Please suggest me which might be the best approch to work on.
1) XML file to XML file
I will have 1 pretty huge XML file which i need to break in multiple XML files with 200 records each.
1) first approch i can have bpm in which i can split the file according to my requirement.
2) Second approch i can create 2 scenarios in which 1st scenario will pick up XML file and create multiple flat files with File content conversion. Second scenario will pick up all these flat files and create XML files.
2) XML file to XML file
Or i can have multiple files with 1 record per file and i need to merge in multiple XML files with 200 records in each.
So its kind of 1:N or M:N scenarios.
Please tell me which is might be better performance and design wise.
Or if you have any idea in any other way i can do this, then please reply as soon as possbile.
Please tell me if you have OS command for the same or some script to run or anything which i can implement.
Thanks,
Hetalwhat is your senario? is it File to File?
You can use multi mapping concept without BPM. You can handle the 200 records per message logic in the multimapping.
Regards,
Praveen Gujjeti. -
Example of xml file with connection pool SAP
Hi Everyone
I need a .xml file with pool connection SAP to run on weblogic 8.1.
Where do I get it?
ThanksStefan
Whether your XML is stored using structured storage or not is determined by the way your initially register the schema, not by the way the XML is delivered into the database. Even when performing, for example, and INSERT using a CLOB value, this CLOB will be 'shredded' into the structured storage tables if you have created them appropriately. If not, it will be stored as a simple CLOB.
Allan
Maybe you are looking for
-
Network error in the business rule
Hello, Experts! I have created a business rule, validated it but when I launch it, I get the message: +"The client or server timed out waiting to receive data using TCP/IP. Check network connections. Increase the NetRetryCount and/or NetDelay values
-
Hp color sphere laser jet cm 1015
Everytime I try to print a color copy it comes up COLOR RESTRICTED. How do I fix this so I can make color copies?
-
Hi there Having a problem here. The RAW images from my Canon 1D Mark IV come in a stop too dark! When I open them, they lookfine; a second later they switch to a too-dark version. I am using Camera Standard, and no other adjustments. It's not just vi
-
I have tried to create a POWL which is called from a WEBDYNPRO However, on execution, I get a problem. My Webdynpro is working, this is not the problem (tried to link a standard class (easy_powl_demo) to my type and this works) The problem occurs whe
-
SOS : Implementing a search layout result
Hay every body, I have some probleme, i want to create my own layout with my own css for search result. In the first a have create a Search Component for KM Search iView using this article : https://media.sdn.sap.com/html/submitted_docs