Loading an XML File in an Application!
Hy Guys!
I'm quite new on Java, so I'm missing some important knowledge, for example: how to load an XML file in an Application downloaded by Java WebStart:
In Details:
I'm downloading an Application which needs an XML File for setting up an Legend. As far as I know, the XMLParser needs a File as argument to parse. By Java WebStart/jnlp, I can't download the XML-File to the local machine, and trying to create an instance by the url (as String), doesn't work. So now I'm missing some information, and I hope you can help me:
Is there a possiblility to download the XML file via the application explicitly,
or is there a possibility to "convert" the ResourceInputStream into a "parseable" class?
I'm happy for every suggestion ..
some code:
public class EvalXML extends org.xml.sax.helpers.DefaultHandler {
/** Creates a new instance of EvalXML */
public EvalXML() {
* @param args the command line arguments
public static int main(String[] args) {
DefaultHandler handler = new EvalXML();
SAXParserFactory factory = SAXParserFactory.newInstance();
String url = new String();
//String url = EvalXML.class.getClassLoader().getResource("com/msgis/res/Lcc_Test_XML_Addressen.xml").getPath();
//String url= "msgis.jar!/com/msgis/res/Lcc_Test_XML_Addressen.xml";
if (args[0] + "empty" != "empty") url = args[0];
else{
System.out.println("no argument");
return 0;
System.out.println("PATH: \n" + url + "\n");
try{
SAXParser saxParser = factory.newSAXParser();
//saxParser.parse(new File(EvalXML.class.getClassLoader().getResource("com/msgis/res/Lcc_Test_XML_Addressen.xml").getPath()), handler);
saxParser.parse(new File(url), handler);
System.out.println("pascht");
catch(Throwable t){
System.out.println(t.getMessage());
return 1;
regards dominik
Although nobody wrote back, it is the quality of a forum depends on soluted problems so:
the following function loads the file from the server to the box:
public boolean loadResource(String pURL){
DownloadService ds;
URL lURL;
boolean lLoaded = true;
try{
lURL = new URL(pURL);
try {
ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
} catch (UnavailableServiceException e) {
ds = null;
lLoaded = false;
if (ds != null) {
try {
// determine if a particular resource is cached
//URL url = new URL("http://java.sun.com/products/javawebstart/lib/draw.jar");
boolean cached = ds.isResourceCached(lURL, "1.0");
// remove the resource from the cache
if (cached) {
ds.removeResource(lURL, "1.0");
// reload the resource into the cache
DownloadServiceListener dsl = ds.getDefaultProgressWindow();
ds.loadResource(lURL, "1.0", dsl);
} catch (Exception e) {
e.printStackTrace();
lLoaded = false;
catch(MalformedURLException mue)
System.out.println(mue.getMessage());
lLoaded =false;
return lLoaded;
dominik
Similar Messages
-
Loading XML files into flex application
Hi Im trying to load an xml file into my app. The only thing is that its not in the same directory as the application. I'm very new to flex/air and have read alot of articles but cant seem to figure out what i'm doing wrong. I have this so far
var data:File = new File("C:/listener/AuditTrail");
var Data:XML = new XML(data.data);
I dont even know if this is how you are supposed to do it but my ultimate goal is to load the xml and display it on a datagrid.
this is what my xml file looks like
<data>
<audit id="7011611">
<comment>Opened</comment>
<date>14261</date>
<time>79367</time>
<userid>20</userid>
<employee>JEFF SANCHEZ</employee>
</audit>
</data>
This is what my datagrid looks like
<mx:AdvancedDataGrid x="11" y="9" id="AuditTrailList" dataProvider="{Data.audit}" designViewDataType="flat" width="866" height="490">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Comments" width="400" dataField="comment"/>
<mx:AdvancedDataGridColumn headerText="Date" width="70" dataField="date"/>
<mx:AdvancedDataGridColumn headerText="Time" width="70" dataField="time"/>
<mx:AdvancedDataGridColumn headerText="ID" width="55" dataField="userid"/>
<mx:AdvancedDataGridColumn headerText="Employee ID" width="90" dataField="employee"/>
</mx:columns>
</mx:AdvancedDataGrid>Hi,
To load XML to an AdvancedDataGrid, you might want to take a look at this article:
Populating an AdvancedDataGrid from an XML file using HTTPService
Hope this helps,
Chris -
Loading an xml file from jws : a nightmare !
Hi all:
I'm trying to load a xml file packed inside a jar file, and when i call getresource it keeps always returning null !!!
When i run the application (not in JWS) the file is loaded, but when i run it from a jnlp file with jws no !!
I tried all possible solutions wihout success :(
the last portion of code i used is :
ClassLoader cl = this.getClass().getClassLoader();
URL xmlFile=cl.getResource("configure.xml"); why is it working when run from Eclipse but fails when using jws ?
I packed all my .class files together with xml file in one jar.
please help me ! this stuff is driving me crazy :(
thanks.Hi phasse !
Yes I've fortenatly managed to solve my problem .here is the desription:
Actually my problem was not with loading the xml file but in reading it .
my problem was in the statement builder.parse(xmlFile.getPath()); this will not work with jws .I replaced this with : Document document = null;
try {
ClassLoader cl = this.getClass().getClassLoader();
DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
document=builder.parse(cl.getResourceAsStream("resources/configure.xml"));I would suggest to use ClassLoader and getResourceAsStream("xmlfile") method .
I hope this would be helpfull for you .Good luck ! -
Runtime loading of XML file off a ComboBox selection
I need to load an XML file at runtime based on a ComboBox
selection that has the XML file path as its data.
I figured out how to load an XML file at runtime by defining
an HTTPService
<mx:HTTPService id="stocksXML" url="xml/StockList.xml"
resultFormat="e4x"/>
and setting the <mx:Application
creationComplete="stocksXML.send();"
But when I now try to set the HTTPService url dynamically in
the ComboBox change event handler
private function loadData_changeHandler(event:ListEvent):void
stocksXML.url = event.target.selectedItem.path;
stocksXML.send();
no data gets retrieved and the stocksXML.lastResult is null.
What am I missing here? Why doesn't that work?
Thanks in advance for any pointersI suggest adding a resultHandler to the HTTPService and check
the results there. Also add a faultHandler so that you will know
what the error was. -
Creation of xml file in r3 application server (AL11)
Hi All
I need to create xml file in r3 application server (AL11) using PI.Can we achieve this using file adapter or we need to proceed with proxy. As I tried with file adapter with FTP transport protocol. Its giving the error as "Unable to create new pooled resource:FTPEx:Login incorrect".
Thanks in advance
Regards,
KartikeyaHi
need to create xml file in r3 application server (AL11) using PI.Can we achieve this using file adapter or we need to proceed with proxy.
To generate file at AL11 file directory use File adapter. Proxy is not required for this
Its giving the error as "Unable to create new pooled resource:FTPEx:Login incorrect".
1. Check with the Login credentials for the FTP service.
2. FTP User you use in communication channel must have 777 access to FTP location.
Thanks
Gaurav -
XML Parse error while loading an XML file
HI Folks,
I was trying to load and XML file into BODS.. The XML file is well-formed and the same when tested in other tools is getting loaded without any issues..
I have created a XML-File format with the corresponding XSD..
But here in BODS it is giving - Parse error
1) when i try to view the data of the source XML in my dataflow ..it is giving "XML Parser Failed".. and not able to show data..
2) When I run my job i get the same pares error - with details as under..
---> Error here is "Unable to recognize element 'TAB' " or some time is say " Element TAB should be qualified"
Please guide with this if you have any info..thanks
I'm pasting the XML source file format here for your reference:--
<?xml version="1.0" encoding="iso-8859-1" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
- <asx:values>
- <TAB>
- <items>
+ <CUSTOMER_RECORD>
<CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
<NAME_1>ABC</NAME_1>
<NAME_2>OFM/COMMERCIAL ACCOUNTS</NAME_2>
<STREET_1>31 CENTER DRIVE MCS2045</STREET_1>
<STREET_2 />
<CITY>BETHESDA</CITY>
<STATE_CODE>MD</STATE_CODE>
<POSTAL_CODE>20892-2045</POSTAL_CODE>
<COUNTRY_CODE>US</COUNTRY_CODE>
<ORDER_BLOCK />
<ERP_CREATE_DATE>20040610</ERP_CREATE_DATE>
<ERP_CREATED_BY>DGUPTA</ERP_CREATED_BY>
<ERP_MODIFY_DATE>20120201</ERP_MODIFY_DATE>
<ERP_MODIFIED_BY>LWOHLFEI</ERP_MODIFIED_BY>
<INDUSTRY_CODE>0103</INDUSTRY_CODE>
<ACCOUNT_GROUP_ID>0001</ACCOUNT_GROUP_ID>
<SALES_NOTE />
<ADDRESS_NOTE />
<CUSTOMER_CLASSIFICATION_CODE>02</CUSTOMER_CLASSIFICATION_CODE>
<GLN_NUMBER />
<PREVIOUS_ACCT_NO />
<ACCOUNT_TYPE />
<GAG />
<SDI_ID />
<HOSP_ID />
<HIN />
<DUNS />
<PO_BOX />
<POB_CITY />
<POB_ZIP />
<PHONE_NUMBER>77777</PHONE_NUMBER>
<EMAIL_DOMAIN />
<REQUESTER />
<ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
</CUSTOMER_RECORD>
- <SALES_ORG_DATA>
+ <item>
<CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
<SALES_ORG>0130</SALES_ORG>
<CUSTOMER_GROUP>03</CUSTOMER_GROUP>
<ORDER_BLOCK_CODE />
<ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
</item>
+ <item>
<CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
<SALES_ORG>0120</SALES_ORG>
<CUSTOMER_GROUP>11</CUSTOMER_GROUP>
<ORDER_BLOCK_CODE />
<ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
</item>
</SALES_ORG_DATA>
</items>
</TAB>
</asx:values>
</asx:abap>Pierre,
Depending on the object "myLastFile", the method openDlg might not even exist (if the myLastFile object is not a File object, for instance). And I do not see any need for the myLastFile anyhow, as you are presenting a dialog to select a file to open. I recommend using the global ChooseFile( ) method instead. This will give you a filename as string in full path notation, or null when no file was selected in the dialog. I am not sure what your ExtendScript documentation states about the return value for ChooseFile, but if that differs from what I am telling you here, the documentation is wrong. So, if you replace the first lines of your code with the following it should work:
function openXMLFile ( ) {
var filename = ChooseFile ( "Choose XML file ...", "", "*.xml", Constants.FV_ChooseSelect );
While writing this, I see that Russ has already given you the same advice. Use the symbolic constant value I indicated to use the ChooseFile dialog to select a single file (it can also be used to select a directory or open a file - but you want to control the opening process yourself). Note that this method allows you to set a start directory for the dialog (second parameter). The ESTK autocompletion also gives you a fifth parameter "helplink" which is undocumented and can safely be ignored.
Good luck
Jang -
How to load a XML file into a table using PL/SQL
Hi Guru,
I have a requirement, that i have to create a procedure or a package in PL/SQL to load XML file into a table.
How we can achive this.ODI_NewUser wrote:
Hi Guru,
I have a requirement, that i have to create a procedure or a package in PL/SQL to load XML file into a table.
How we can achive this.
Not a perfectly framed question. How do you want to load the XML file? Hoping you want to parse the xml file and load it into a table you can do this.
This is the xml file
karthick% cat emp_details.xml
<?xml version="1.0"?>
<ROWSET>
<ROW>
<EMPNO>7782</EMPNO>
<ENAME>CLARK</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>09-JUN-1981</HIREDATE>
<SAL>2450</SAL>
<COM>0</COM>
<DEPTNO>10</DEPTNO>
</ROW>
<ROW>
<EMPNO>7839</EMPNO>
<ENAME>KING</ENAME>
<JOB>PRESIDENT</JOB>
<HIREDATE>17-NOV-1981</HIREDATE>
<SAL>5000</SAL>
<COM>0</COM>
<DEPTNO>10</DEPTNO>
</ROW>
</ROWSET>
You can write a query like this.
SQL> select *
2 from xmltable
3 (
4 '/ROWSET/ROW' passing xmltype
5 (
6 bfilename('SDAARBORDIRLOG', 'emp_details.xml')
7 , nls_charset_id('AL32UTF8')
8 )
9 columns empno number path 'EMPNO'
10 , ename varchar2(6) path 'ENAME'
11 , job varchar2(9) path 'JOB'
12 , mgr number path 'MGR'
13 , hiredate varchar2(20)path 'HIREDATE'
14 , sal number path 'SAL'
15 , com number path 'COM'
16 , deptno number path 'DEPTNO'
17 );
EMPNO ENAME JOB MGR HIREDATE SAL COM DEPTNO
7782 CLARK MANAGER 7839 09-JUN-1981 2450 0 10
7839 KING PRESIDENT 17-NOV-1981 5000 0 10
SQL> -
An example about how to load a XML file
Hi,
I've been working on Oracle for many years but fot the first time I was asked to load a XML file into a table.
As an example, I've found this on the web, but it doesn't work.
Can someone tell me why? I hoped this example could help me.
the file acct.xml is this:
<?xml version="1.0"?>
<ACCOUNT_HEADER_ACK>
<HEADER>
<STATUS_CODE>100</STATUS_CODE>
<STATUS_REMARKS>check</STATUS_REMARKS>
</HEADER>
<DETAILS>
<DETAIL>
<SEGMENT_NUMBER>2</SEGMENT_NUMBER>
<REMARKS>rp polytechnic</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>3</SEGMENT_NUMBER>
<REMARKS>rp polytechnic administration</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>4</SEGMENT_NUMBER>
<REMARKS>rp polytechnic finance</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>5</SEGMENT_NUMBER>
<REMARKS>rp polytechnic logistics</REMARKS>
</DETAIL>
</DETAILS>
<HEADER>
<STATUS_CODE>500</STATUS_CODE>
<STATUS_REMARKS>process exception</STATUS_REMARKS>
</HEADER>
<DETAILS>
<DETAIL>
<SEGMENT_NUMBER>20</SEGMENT_NUMBER>
<REMARKS> base polytechnic</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>30</SEGMENT_NUMBER>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>40</SEGMENT_NUMBER>
<REMARKS> base polytechnic finance</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>50</SEGMENT_NUMBER>
<REMARKS> base polytechnic logistics</REMARKS>
</DETAIL>
</DETAILS>
</ACCOUNT_HEADER_ACK>
For the two tags HEADER and DETAILS I have the table:
create table xxrp_acct_details(
status_code number,
status_remarks varchar2(100),
segment_number number,
remarks varchar2(100)
before I've created a
create directory test_dir as 'c:\esterno'; -- where I have my acct.xml
and after, can you give me a script for loading data by using XMLTABLE?
I've tried this but it doesn't work:
DECLARE
acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
BEGIN
insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
select x1.status_code,
x1.status_remarks,
x2.segment_number,
x2.remarks
from xmltable(
'/ACCOUNT_HEADER_ACK/HEADER'
passing acct_doc
columns header_no for ordinality,
status_code number path 'STATUS_CODE',
status_remarks varchar2(100) path 'STATUS_REMARKS'
) x1,
xmltable(
'$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
passing acct_doc as "d",
x1.header_no as "hn"
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS'
) x2
END;
This should allow me to get something like this:
select * from xxrp_acct_details;
Statuscode status remarks segement remarks
100 check 2 rp polytechnic
100 check 3 rp polytechnic administration
100 check 4 rp polytechnic finance
100 check 5 rp polytechnic logistics
500 process exception 20 base polytechnic
500 process exception 30
500 process exception 40 base polytechnic finance
500 process exception 50 base polytechnic logistics
but I get:
Error report:
ORA-06550: line 19, column 11:
PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
ORA-06550: line 4, column 2:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
and if I try to change the script without using the column HEADER_NO o keep track of the header rank inside the document:
DECLARE
acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
BEGIN
insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
select x1.status_code,
x1.status_remarks,
x2.segment_number,
x2.remarks
from xmltable(
'/ACCOUNT_HEADER_ACK/HEADER'
passing acct_doc
columns status_code number path 'STATUS_CODE',
status_remarks varchar2(100) path 'STATUS_REMARKS'
) x1,
xmltable(
'/ACCOUNT_HEADER_ACK/DETAILS'
passing acct_doc
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS'
) x2
END;
I get this message:
Error report:
ORA-19114: error during parsing the XQuery expression:
ORA-06550: line 1, column 13:
PLS-00201: identifier 'SYS.DBMS_XQUERYINT' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-06512: at line 4
19114. 00000 - "error during parsing the XQuery expression: %s"
*Cause: An error occurred during the parsing of the XQuery expression.
*Action: Check the detailed error message for the possible causes.
My oracle version is 10gR2 Express Edition
I do need a script for loading xml files into a table as soon as possible
Thanks in advance!Hello,
Your code is not readable (no code tags).
Anyway, you can use SQL*Loader to load a XML document into a table.
Here is the link of the documentation with both description and an example at the end of the
article.
http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb25loa.htm
Regards,
Dariyoosh -
How to load a XML file into a table
Hi,
I've been working on Oracle for many years but for the first time I was asked to load a XML file into a table.
As an example, I've found this on the web, but it doesn't work
Can someone tell me why? I hoped this example could help me.
the file acct.xml is this:
<?xml version="1.0"?>
<ACCOUNT_HEADER_ACK>
<HEADER>
<STATUS_CODE>100</STATUS_CODE>
<STATUS_REMARKS>check</STATUS_REMARKS>
</HEADER>
<DETAILS>
<DETAIL>
<SEGMENT_NUMBER>2</SEGMENT_NUMBER>
<REMARKS>rp polytechnic</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>3</SEGMENT_NUMBER>
<REMARKS>rp polytechnic administration</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>4</SEGMENT_NUMBER>
<REMARKS>rp polytechnic finance</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>5</SEGMENT_NUMBER>
<REMARKS>rp polytechnic logistics</REMARKS>
</DETAIL>
</DETAILS>
<HEADER>
<STATUS_CODE>500</STATUS_CODE>
<STATUS_REMARKS>process exception</STATUS_REMARKS>
</HEADER>
<DETAILS>
<DETAIL>
<SEGMENT_NUMBER>20</SEGMENT_NUMBER>
<REMARKS> base polytechnic</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>30</SEGMENT_NUMBER>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>40</SEGMENT_NUMBER>
<REMARKS> base polytechnic finance</REMARKS>
</DETAIL>
<DETAIL>
<SEGMENT_NUMBER>50</SEGMENT_NUMBER>
<REMARKS> base polytechnic logistics</REMARKS>
</DETAIL>
</DETAILS>
</ACCOUNT_HEADER_ACK>
For the two tags HEADER and DETAILS I have the table:
create table xxrp_acct_details(
status_code number,
status_remarks varchar2(100),
segment_number number,
remarks varchar2(100)
before I've created a
create directory test_dir as 'c:\esterno'; -- where I have my acct.xml
and after, can you give me a script for loading data by using XMLTABLE?
I've tried this but it doesn't work:
DECLARE
acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
BEGIN
insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
select x1.status_code,
x1.status_remarks,
x2.segment_number,
x2.remarks
from xmltable(
'/ACCOUNT_HEADER_ACK/HEADER'
passing acct_doc
columns header_no for ordinality,
status_code number path 'STATUS_CODE',
status_remarks varchar2(100) path 'STATUS_REMARKS'
) x1,
xmltable(
'$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
passing acct_doc as "d",
x1.header_no as "hn"
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS'
) x2
END;
This should allow me to get something like this:
select * from xxrp_acct_details;
Statuscode status remarks segement remarks
100 check 2 rp polytechnic
100 check 3 rp polytechnic administration
100 check 4 rp polytechnic finance
100 check 5 rp polytechnic logistics
500 process exception 20 base polytechnic
500 process exception 30
500 process exception 40 base polytechnic finance
500 process exception 50 base polytechnic logistics
but I get:
Error report:
ORA-06550: line 19, column 11:
PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
ORA-06550: line 4, column 2:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
and if I try to change the script without using the column HEADER_NO to keep track of the header rank inside the document:
DECLARE
acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
BEGIN
insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
select x1.status_code,
x1.status_remarks,
x2.segment_number,
x2.remarks
from xmltable(
'/ACCOUNT_HEADER_ACK/HEADER'
passing acct_doc
columns status_code number path 'STATUS_CODE',
status_remarks varchar2(100) path 'STATUS_REMARKS'
) x1,
xmltable(
'/ACCOUNT_HEADER_ACK/DETAILS'
passing acct_doc
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS'
) x2
END;
I get this message:
Error report:
ORA-19114: error during parsing the XQuery expression:
ORA-06550: line 1, column 13:
PLS-00201: identifier 'SYS.DBMS_XQUERYINT' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-06512: at line 4
19114. 00000 - "error during parsing the XQuery expression: %s"
*Cause: An error occurred during the parsing of the XQuery expression.
*Action: Check the detailed error message for the possible causes.
My oracle version is 10gR2 Express Edition
I do need a script for loading xml files into a table as soon as possible, Give me please a simple example for understanding and that works on 10gR2 Express Edition
Thanks in advance!The reason your first SQL statement
select x1.status_code,
x1.status_remarks,
x2.segment_number,
x2.remarks
from xmltable(
'/ACCOUNT_HEADER_ACK/HEADER'
passing acct_doc
columns header_no for ordinality,
status_code number path 'STATUS_CODE',
status_remarks varchar2(100) path 'STATUS_REMARKS'
) x1,
xmltable(
'$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
passing acct_doc as "d",
x1.header_no as "hn"
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS'
) x2
returns the error you noticed
PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
is because Oracle is expecting XML to be passed in. At the moment I forget if it requires a certain format or not, but it is simply expecting the value to be wrapped in simple XML.
Your query actually runs as is on 11.1 as Oracle changed how that functionality worked when 11.1 was released. Your query runs slowly, but it does run.
As you are dealing with groups, is there any way the input XML can be modified to be like
<ACCOUNT_HEADER_ACK>
<ACCOUNT_GROUP>
<HEADER>....</HEADER>
<DETAILS>....</DETAILS>
</ACCOUNT_GROUP>
<ACCOUNT_GROUP>
<HEADER>....</HEADER>
<DETAILS>....</DETAILS>
</ACCOUNT_GROUP>
</ACCOUNT_HEADER_ACK>
so that it is easier to associate a HEADER/DETAILS combination? If so, it would make parsing the XML much easier.
Assuming the answer is no, here is one hack to accomplish your goal
select x1.status_code,
x1.status_remarks,
x3.segment_number,
x3.remarks
from xmltable(
'/ACCOUNT_HEADER_ACK/HEADER'
passing acct_doc
columns header_no for ordinality,
status_code number path 'STATUS_CODE',
status_remarks varchar2(100) path 'STATUS_REMARKS'
) x1,
xmltable(
'$d/ACCOUNT_HEADER_ACK/DETAILS'
passing acct_doc as "d",
columns detail_no for ordinality,
detail_xml xmltype path 'DETAIL'
) x2,
xmltable(
'DETAIL'
passing x2.detail_xml
columns segment_number number path 'SEGMENT_NUMBER',
remarks varchar2(100) path 'REMARKS') x3
WHERE x1.header_no = x2.detail_no;
This follows the approach you started with. Table x1 creates a row for each HEADER node and table x2 creates a row for each DETAILS node. It assumes there is always a one and only one association between the two. I use table x3, which is joined to x2, to parse the many DETAIL nodes. The WHERE clause then joins each header row to the corresponding details row and produces the eight rows you are seeking.
There is another approach that I know of, and that would be using XQuery within the XMLTable. It should require using only one XMLTable but I would have to spend some time coming up with that solution and I can't recall whether restrictions exist in 10gR2 Express Edition compared to what can run in 10.2 Enterprise Edition for XQuery. -
How to load a XML file into the database
Hi,
I've always only loaded data into the database by using SQL-Loader and the data format was Excel or ASCII
Now I have to load a XML.
How can I do?
The company where I work has Oracle vers. 8i (don't laugh, please)
Thanks in advance!Hi,
Tough job especially if the XML data is complex. The have been some similar question in the forum:
Using SQL Loader to load an XML File -- use 1 field's data for many records
SQL Loader to upload XML file
Hope they help.
Regards,
Sujoy -
Error while extracting XML file from the application server
Hi ,
I am writing a XML file into the application server, after which when i try to extract the file to the local server using the report - RFASLDPC ,
the file is extracted, but with a '#' symbol at the first position.
Because of which the XML File does not open. But after i open the file in notepad and manually delete the '#' symbol and then reopen the file, it works fine.
Is there any way to remove the '#' symbol while extracting itself ??
Thanks in advance,
Vikas.Select the option "No Character Set Conversion" in stead of Code page 1100.
However, I still have troubles -> the downloaded xml file misses a space on several places. This causes errors too. -
Help in loading the xml file using AS 2.0
Hi
I try to load the Xml file in As file but i need do all the
fetching details from the __LoadXmlFile file function
but it's working fine can any one help me for this issue
~~SkYou can't! Well, at least Flex cannot do this. All Flex can
do is send this data -- any data -- to the server and it's up to
you how you want to append this data to a file on the server.
You see, flex can't write to local files. If you looking for
client side file manipulation, take a look at Flex's desktop
brother call AIR!
ATTA -
Issue: XML File Downloading to Application Server
Hi All,
I am experiencing an issue downloading an XML File to the Application Server.
I'm using FM SAP_CONVERT_TO_XML_FORMAT to convert SAP data to XML Format.
After getting the XML data into XMLTAB, I'm using:
OPEN DATASET pfile_fs FOR OUTPUT IN BINARY MODE .
LOOP AT xmltab INTO xmltab_w.
TRANSFER xmltab_w TO pfile_fs.
CLEAR xmltab_w.
ENDLOOP.
CLOSE DATASET pfile_fs.
The xml file is downloaded show an Error in 'XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Invalid at the top level of the document. Error processing resource 'file:/shared/TEST/2009'
But when i download xml file using the FM WS_Download , the XML page has no errors .
I am unable to figure out what could be the issue, If this issue is due to some characters like Chinese or Japanese then .. is there any solution for this .
Please, give me your valuable suggestions.
Thank you,
PraseadDear Prasead,
Hope things are good at your end, i have got the same issue as well, could you please care to share the solution...Wud be of a gr8 help if you could do that, hope to have your response back.
Regards,
Abdul. -
Hi,
I have downloaded a XML file to the application server.....
File is created but i am not able to open the file there....
Plz advice ....how to open it.....
Regards.Use Notepad. Drag and drop in notepad.
Aman -
Loading an xml file from an xml file
I'm trying to load an xml file from an xml file, but I'm
having problems. My first xml file is really simple - it only
contains one attribute with the name of another xml file in it
(eventually I will have multiple xml files in here and run a loop
on them...this is why I want to load an xml file from an xml file).
Currently, with the code below, I can get the main xml file
to load ("main.xml"), but I cannot get the secondary xml files to
load FROM the main.xml.
I want to then take childNode values from the secondary xml
file and use them within my .swf in text boxes and whatnot.
Any guidance? I think I'm going wrong on the line where I'm
saying "i.newxml.load(i.attributes.location);"
- How can I get this to work?johnypeter:
I tried changing the code inside the loop to use just
"newxml" instead of "i.newxml", and I declared with "var newxml =
new XML();" - was this what you were thinking?
kglad:
The reason I tried to use the loadXML() function in the loop
was so that for each node in my "main.xml" it would load the new
xml file listed - this is a no-no? Do you have any ideas as to what
I could do?
For the for-loop, what should I change in it? I'm not great
with loops so I tried to modify some code from another loop I found
in another forum thread - not the right way to do it here?
Also, what should I trace? The value of the _root.address, or
i.attributes.location? I have created dynamic text boxes on my
stage to see if the correct value from the xml file loads (ie. the
name of the xml file within the xml file) and it does, but now I
don't know how to put that information into ANOTHER loadXML()
function and get the node information from it - does that make
sense???
Below are the examples of the xml files I am using. In the
first one, main.xml, I will have a list of multiple xml files, each
with the same nodes and elements as in the details.xml file
(different values, of course).
This is just to give you an example of what I'm trying to
accomplish - pulling ALL the addresses and phone numbers from
multiple xml files. I cannot manually collect this information, as
it is dynamic, and will be updated in each individual details.xml.
I was hoping to collect the information by simply adding to and
updating ONE xml file - main.xml.
Do you think this can be done? Am I going about it the wrong
way? I'm quite limited in AS knowledge, which is why I'm piecing
together code from other posts!
Maybe you are looking for
-
Receipt of EBS multiple times in a day (Electronic Bank Statement)
Hi Gurus, We had a requirement for receipt of Bank statement, in a single day we have to receive bank statement twice a day, but in both statements some transactions will be repeated. Now my question is once in the morning statement came, then postin
-
SSIS package runs from BIDS and by Executing package, but failing with Job
I have SQL Serve 2012 SSIS. I have problems to run from SQL Server Agent Job. Steps runs SSIS package without configuration file. Package Run64BitRuntime is False in BIDS. Package is runned by SQL Server Agent Service Account. Server does not have Of
-
Remove Lines in a Drop Down?
Hi -- Is there an "easy" way to remove the line that is appearing between options in my combo box? This is Flash CS3/Action Script 3. Thanks Rich
-
Integrated Server has Empty DefaultDomain
Hello, I just installed the new 11gR2 Jdeveloper. However, when I create a new application, with one empty jspx page, and try to run it, I am getting the following error: The Server Instance cannot be started because the Integrated Weblogic domain wa
-
Problem installing JWSDP-2.0 on linux ! ?
when I try to execute the jwsdp-2_0-unix.sh installer on Fedora Core 5, x86, I get the following error indication: Using /var/tmp as temporary directory... Searching for Java(TM) 2 Platform, Standard Edition... tail: cannot open `+368' for reading: N