Writing to separate XML files
I'm not too familiar with XML yet, so I don't know what its called, but you know how you can "include" another XML file in this fashion:
<?xml version="1.0"?>
<!DOCTYPE configuration SYSTEM "my.dtd" [
<!ENTITY include SYSTEM "include.xml">
]>
<root>
&include;
</root>... and all the stuff in include.xml gets essentially copied into yours whenever the file is read. Well how can I generate a file that looks like this. I basically want to be able to choose which nodes underneath the root node I can put in separate files. I'm doing this by converting a DOM to XML with this code...
Document d = MY_DOCUMENT;
DOMSource domSource = new DOMSource(d);
TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute("indent-number",4);
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"ems.dtd");
FileOutputStream fileOut = new FileOutputStream(filename);
transformer.transform(domSource, new StreamResult(new OutputStreamWriter(fileOut,"utf-8")));
fileOut.close();
You can also use commands like bcp withT-SQL query to get the shredded XML values saved as separate xml files. You've xpath function like query() available which will shred out parts of XML from your main column
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page
Similar Messages
-
Export XML data to Separate XML Files
A table which has a column with nText data type. I can cast it to XML and then save it manually. (file.xml)
Let's say if I have 100 rows and I need 100 separate XML files under "C:\xml\" folder, I could do it easily by using
SSIS with Export Column Task.
Is that possible with T-SQL too?
Cheers,
Vaibhav Chaudhari
[MCTS],
[MCP]You can also use commands like bcp withT-SQL query to get the shredded XML values saved as separate xml files. You've xpath function like query() available which will shred out parts of XML from your main column
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Writing and updating XML file on client side
Hello,
I'm looking for a simple example which permit to write and
update a xml file on the client side.
Someone can help me, please?meghashyamgr ,
Because of security reasons a swf running in a browser cannot
read or write xml files to a user's computer. What can be done,
however, is write xml to what is known as a SharedObject.
SharedObjects act as cookies for Flashplayer.
If you would like an example of this I'd be more than happy
to show you... -
Loading data held in separate XML files
I think I am probably just having a slow brain day, but I have a requirement that I can't think of a neat solution for.
We will be receiving a number (200-400 ish) xml files twice a day. These files will have a standard naming structure - 850xxxx_ATT_850LLLL_zzz.xml
xxx will be a 4 digit school number - we will get a file for each school twice a day and yyy is a numeric identifier. The identifiers won't necessarily be consecutive for a particular school, they will in general be increasing, but they will wrap around eventually (only a 3 digit number)
I want to merge all of the data into a table, twice a day, the details for an existing row can be updated and new ones inserted. Once I have the data in oracle I can then process it however I like, I'm comfortable with that bit. It's loading the data I'm not sure about
database version is
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
running on Windows Server 2003
I'd prefer a mainly oracle based solution if possible. Otherwise I could just loop through the files programatically, strip the data out via XPATH or using some sort of DOM and then do a series of insert/updates. Getting messy though and I would prefer to keep the loading of the data with the processing of the data.
Any suggestions? A gentle Nudge in the right direction should do it - I'm happy to work out the details (Which is why I haven't gone into the details of the XML or the data)
Regards,
CarlCarlovski wrote:
1 - It's going to have to be a process scripted outside of the database (Although I guess i could use DBMS_SCHEDULER to kick off the SQL Load command?)You can schedule sqlloader initialization by using windows scheduler, which would then execute some *.bat script with sqlloader commands.
2- how will this handle the multiple file names? Doesn't the control file need to specify the source of the file? Would I need to dynamically generate control files?Sqlloader can load multiple files using one control file.
Example is Re: sql loader multiple files
Generating control file dynamically can be done in several ways, depending on the os and tools you have.
One example is here. -
Writing to a xml file using DOM API
Hi,
I try to write some elements in an existing xml file.
Document doc = null;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
try
builder = factory.newDocumentBuilder();
doc = builder.parse("c:/WUTEMP/rules.xml");
Element rules = doc.getDocumentElement();
Element eRule = doc.createElement("rule");
rules.appendChild(eRule);
Element ruleSyntax = doc.createElement("rule-syntax");
eRule.appendChild(ruleSyntax);
ruleSyntax.appendChild(doc.createTextNode(syntax));
It runs without errors but the xml file isn't changed. Some ideas ?
Structure of xml file:
<rules>
</rules>
And executing code above must resulting in :
<rules>
<rule-syntax> </rule-syntax>
</rules>
But nothing happens with the file.Code below did the trick:
Transformer xformer = TransformerFactory.newInstance().newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File("c:/WUTEMP/rules.xml"));
xformer.transform(source, result); -
How do I import one xml file into 3 separate tables in db?
I need to utilize xslt to import one xml file into 3 separate tables: account, accountAddress, streetAddress
*Notice the missing values in middleName, accountType
sample xml
<account>
<firstName>Joe</firstName>
<middleName></middleName>
<lastName>Torre</lastName>
<accountAddress>
<streetAddress>
<addressLine>myAddressLine1</addressLine>
<addressLine>myAddressLine2</addressLine>
</streetAddress>
<city>myCity</city>
<state>myState</state>
<postalCode>mypostalCode</postalCode>
</accountAddress>
<accountId>A001</accountId>
<accountType></accountType>
<account>
I need the following 3 results in 3 separate xml files in order for me to upload into my 3 tables.
Result #1
<rowset>
<row>
<firstName>Joe</firstName>
<lastName>Torre</lastName>
<accountId>A001</accountId>
<row>
<rowset>
Result #2
<rowset>
<row>
<addressId>1</address>
<city>myCity</city>
<state>myState</state>
<postalCode>myPostalCode</postalCode>
<row>
<rowset>
Result #3
<rowset>
<row>
<addressId>1</addressId>
<addressLineSeq>1</addressLineSeq>
<addressLine>myAddressLine1</addressLine>
<row>
<row>
<addressId>1</addressId>
<addressLineSeq>2</addressLineSeq>
<addressLine>myAddressLine2</addressLine>
<row>
<rowset>Use XSU to store in multiple tables.
"XSU can only store data in a single table. You can store XML across tables, however, by using the Oracle XSLT processor to transform a document into multiple documents and inserting them separately. You can also define views over multiple tables and perform insertions into the views. If a view is non-updatable (because of complex joins), then you can use INSTEAD OF triggers over the views to perform the inserts."
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#i1007013 -
Writing XML file from a jsp page
how can i write a xml file from my jsp and store the values and after sometime, for example when the user clicks on the submit button, i check the values from xml file and compare those values from the data base.
it means both writing and reading xml file from a jsp page...
urgent help needed......thanksYou need some API like XSL or JDOM to read data from/to XML file
you can get a best tutorial from
http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom.html
and
http://www.javaworld.com/javaworld/jw-07-2000/jw-0728-jdom2.html
after reading both articals you will be able to do both the tasks -
Reading an xml file in the web services java file
I want to read some data in the webservices file.so i am writing my own xml file through which i want to read data.but i am not able to read xml file from web services file.also , i am not able to put xml file in the .ear file,as there is no such tag in servicegen script through which i can add xml file in the .ear file.
i know in case of servlets,i will specify context-param attributes in web.xml,and i can access those in my servlet.can i do anything like this for webservices,and i am not using any servlets for web services.
kindly tell any solution.One possible option to parse an xml-file to a flex XML object:
public function parseConXML(source:String):void
xmlLoader = new URLLoader();
xmlLoader.load(new URLRequest(source));
// Eventlistener: if URL loaded --> onLoadComplete function
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
public function xmlLoadComplete(evt:Event):void{
var xml:XML = new XML();
// ignore comments in XML-File
XML.ignoreComments = true;
//ignore whitespaces in XML-File
XML.ignoreWhitespace = true;
// XML-Objekt erstellen
xml = new XML(evt.target.data);
//AFTERWARDS use your xml as your wish -
Setting up a Form Application to write to an XML file on a local computer
First, I'm using Flash CS3, and Actionscript3.
I'm trying to set up a data collection form that will save
the results to a file that can later be imported into a database.
This is going to be in a Kiosk at a tradeshow and it won't have
internet access, so I can't send it to an online PHP or ASP, etc,
script.
The form also has several screens, so i thought I'd try to
use the Form Application (I know I can only have one frame on the
timeline when using this flash template with the data components).
I want to try and write the data to a XML file. All the information
I've found is for importing data from an XML file to a web server
rather than sending data to an XML file on a local computer.
I'm trying to use the XML connector,and an XML file that
resides in the same folder as my Flash file, but so far I've had
very little luck writing to that XML file. Do I need to set up a
dataset to send the form data to that will then send the data to an
XML Connector component that will then send the data to the XML
file. Should I use LoadVars instead, and if I do, will I have to
write to a script, or can it also write to an XML file.
If any one has a better idea to do this, please let me know.
Thanks.Hi,
Flash itself has no filewriting capabilities other then the
SharedObject
stuff.
But why can't you call a php script? You could install
apache, PHP and
MYSQL on the computer running the Flash app and get it all
into the
database in one go.
Otherwise you either need to get going with AIR (Adobe
Integrated
Runtime), or use a wrapper application like Adobe Director
(which has
tons of ways to write to file through it's plethora of
Xtras.) Director
may be 'a bit' hard on your budget if you only use it for
this purpose
though.
The XMLSocket is for connections to some server, local or
remote, not to
a file.
Manno
graphic_pawn wrote:
> First, I'm using Flash CS3, and Actionscript3.
>
> I'm trying to set up a data collection form that will
save the results to a
> file that can later be imported into a database. This is
going to be in a Kiosk
> at a tradeshow and it won't have internet access, so I
can't send it to an
> online PHP or ASP, etc, script.
>
> The form also has several screens, so i thought I'd try
to use the Form
> Application (I know I can only have one frame on the
timeline when using this
> flash template with the data components). I want to try
and write the data to a
> XML file. All the information I've found is for
importing data from an XML file
> to a web server rather than sending data to an XML file
on a local computer.
>
> I'm trying to use the XML connector,and an XML file that
resides in the same
> folder as my Flash file, but so far I've had very little
luck writing to that
> XML file. Do I need to set up a dataset to send the form
data to that will then
> send the data to an XML Connector component that will
then send the data to the
> XML file. Should I use LoadVars instead, and if I do,
will I have to write to a
> script, or can it also write to an XML file.
>
> If any one has a better idea to do this, please let me
know.
>
> Thanks.
>
Manno Bult
http://www.aloft.nl -
Batching of multiple IDOCs into 1 IDOC-XML file
Hi PI experts,
I would like to send all idocs from the same payment run (based on run date & run id) as 1 idoc-xml file to PI.
The number of idocs is variable depending on the payment run.
Is this possible without using ccBPM?
I understand it can be achieved according to /people/stefan.grube/blog/2006/09/18/collecting-idocs-without-using-bpm by using FILE adapter. But I don't want to save the idocs into a file system and the number of records in a file is also fixed.
Is there other alternative solution?
Thanks,
Ken.Hi Michal,
Yes, I have seen your blog and also would like to use the IDoc packaging feature which comes with 7.0 EHP1 onwards, but I am not sure whether the IDoc collecting can be based on the payment run date and run id.
The sending of the collected IDocs is based on when the program RSEOUT00 is executed.
If we perform 2 separate payment runs before the RSEOUT00 is executed, would PI receive 2 Idoc-XML files or 1 combined Idoc-XML file. We would like to receive 2 separate XML files.
Hope you can confirm this.
Thanks. -
I have a website that uses Spry Data XML DataSet to list common pests for the current month. http://www.shspestcontrol.com/
Each month's list of pests is in a separate xml file (e.g. pests-august.xml)
Rather than manually updating the file name each month, can it be setup to automatically change the name
For instance on January 1st, file name changes to pests-january.xml, Feb 1st changes to pests-february.xml. etc.
<script type="text/javascript">
<!--
var dsPests1 = new Spry.Data.XMLDataSet("xml_files/pests-august.xml", "gallery/pests/pest");
//-->
</script>
Any advice if this can be done and if so how to go about doing it would be much appreciated
Thanks, Toni<script>
var dsPests1 = new Spry.Data.XMLDataSet("pests-september.xml", "gallery/pests/pest");
function setPestsFile(){
var months = new Array(13);
months[0] = "january";
months[1] = "february";
months[2] = "march";
months[3] = "april";
months[4] = "may";
months[5] = "june";
months[6] = "july";
months[7] = "august";
months[8] = "september";
months[9] = "october";
months[10] = "november";
months[11] = "december";
var now = new Date();
var monthnumber = now.getMonth();
var monthname = months[monthnumber];
dsPests1.setURL("pests-"+monthname+".xml");
dsPests1.loadData();
window.onload = setPestsFile();
</script> -
How to create a build.xml file ??
Hi there,
I am learning j2ee at the moment. I have been throught the tutorial and got everything working (finally). however, now that I have started writing my own code, I am stuck with writing the build.xml file (as this is not covered in the tutorial, it is just provided). Does anyone know a good link that will give me step by step instructions on how to create my own build.xml file for my application.
thanksYou need to learn ant. Go here:
http://jakarta.apache.org/ant/
I also recommend "Java Development with Ant" by Hatcher and Loughran, just published. -
How can I make an XML file print �, � and �
When I write an xml file by hand I can use the European alphabet and the letters �,� and �. I can also write to an ordinary text file from my Java code and still be able to display the letters as they should.
But when writing to an xml file in my Java code the letters are converted to some weird mishmash characters.
Why is this? What can I do?
// ElinI'm assuming you are working on a Windows computer (although you can run into this on any computer.)
If you don't tell java the kind of character encoding you want, then you get an assumed desired character encoding - in Windows, the OEM characterset which does not include the characters you are trying to write.
A way to handle this is to output the kind of file you really want - that is - with the encoding you want. I suggest you might try UTF-8, which you can get by simply instantiating your output writer with the encoding string "UTF-8". -
How to read configuration data from an xml file (not web.xml)?
Hi,
I want to separate the application specific configuration parameters in a separate xml file and read them as and when they are needed? I know that I can use the wb.xml but I want to separate them in a different xml file because I don't want the web.xml file to be played around later after deployment. If any change is needed then it should be done in the application-config.xml.
How can I read the parameters from this xml file in my jsp code and also what should be the location of this file if I have
../webapps/Root/application
directoty structure ?
Any help is greatly appreciated.can you give an example of a property file and also
it is loaded in the jsp ?Hmm... loading properties in a JSP is not a very good idea. You should do it in a separate class, rather than mixing the logic with the display logic.
Properties properties = new Properties();
properties.load(UtilClass.class.getResourceAsStream("config.properties"));
// Add a try - catch block around the load
// for IOException... -
Deploying xml file alone in sun application server 8.1
Hi all,
I am having an xml file which should be pasted or put in sun systemapplication server 8.1. so that i could make access of the xml file alone....
i tried it..but i couldn't deploy a xml file alone...it needs any war file or ear file to be deployed other wise it deploys the whole project....
even after deployed xml file with a project....i couldn't get address of the separate xml file...
this is working easily in tomcat....as i pasted the xml file in webapps folder and now i amable to retrieve the file thru server....
how could this be done in sun server.....
pls help me....this is very important
Urgent plsssif you download SJAS 8.2, Derby is included and pre-configured as a DataSource
Using 8.1, you will need to add the jars to either the lib or domains/domains1/lib/ext directory and manually configure a DataSource using
javax.sql.DataSource org.apache.derby.jdbc.ClientDataSource
javax.sql.XADataSource org.apache.derby.jdbc.ClientXADataSource
Maybe you are looking for
-
Thank u Scott Orshan We use the "dispatcher" service because we wanted to supply a general interface to the Client Tier. Do you have some better suggestion? Is it nessary? or, We use a control class to tp_call the service? Scott Orshan <[email protec
-
[SOLVED]gcc-libs and gcc-libs-multilib are in conflict
Can't update today. [glow@GlowArch ~]$ sudo pacman -Syuv :: Synchronizing package databases... core is up to date extra is up to date community is up to date multilib is up to date catalyst is up to date :: Starting full system upgrade... warning: an
-
I have a iBook G4 running 10.3.9, and I just started using it again after leaving it idle for a few months. When I tried to launch Skype, it made me upgrade to a newer version, and since then Skype won't launch, or more specifically, the launch abort
-
Track ball mouse buttons and Logitech driver not fully working on Core Duo
I have a Ligitech cordless optical TrackMan ball bluetooth ball mouse which works for me. Unfortunately, I could not map the buttons properly (the back button kept doing an F9 function rather than 'back' in Safari). The driver in System Preferences p
-
How to control dimension-ID for External dimensions
Everytime I load External dimensions, dimension Ids are automatically populated. I want to use same id for existing dimensions. How can I do it?