XSU - IDREFS??
Hi,
"Object references and referential constraints are mapped to XML IDREFs" - from technet article. How does this work then? I've got table's with foreign key constraints between them, but I don't get IDREF's in the resulting XML.
Lee
Try using nested cursor in your multi-table query
Similar Messages
-
Hi,
How does XSU deal with ID and IDREF in XML document? Are they treated as normal attributes?
nullDo you mean XML Parser? To my knowledge the XML SQL Utility (XSU) does not do anything with ID and IDREF's since it's producing XML from SQL statement result sets.
-
How To Install and run XML/XSU/XDK?
Hello,
I have installed Oracle 8.1.7, have downloaded the utilities
and xdk but how to get all this integrated so I can work with
the sample codes?
I dont see the $ORACLE_HOME/rdbms/admin/dbmsxsu.sql -- this is
the SQL script which builds the XSU's PL/SQL API. xsu12.jar
need to be loaded into the database before dbmsxsu.sql is
executed. This script is automatically ..Nor do I see catxsu.sql.
I assume this creates the xdkdemo/xdkdemo (user/password)? I
also re-run the runInstaller and attempt to see on the list any
XSU related installed or to be installed and not seeing it on the
list. What do I need to download?
A nice step by step how to install and test the install would
be nice.
Thanks in advance for any response.I entered "install XSU" into the "search" box and got the
following back:
http://www.oracle.com/pls/use/use_query_html_v3.submit_query_inpu
t?p_adv_query_text=install+XSU&p_origin=OTN&p_person_id=100081&p_
community=technet_adv&p_doc_location_array=Place+Holder&p_doc_loc
ation_array=document&p_location_array=&p_keyword_array=100017&p_v
alue_array=technet.oracle.com%2C+Discussion+Groups&p_date_begin=q
date&pdate_end=q_date&p_max_return=200
(GOD I hope that worked!)
In any case, 2 documents came back. I think this one is probably
what you want.
http://download-east.oracle.com/otndoc/oracle9i/901_doc/appdev.90
1/a88894/appgxsu.htm
Mike -
Problem with XSU and DataSources with nested cursors?
We are having a problem with the xsu libraries (OracleXMLQuery) using nested cursor syntax. The class returns nicely nested xml document when a database connection is established in the traditional/legacy manner of "class.forName(); DriverManager.registerDriver();" .
However, when using a DataSouce object within a J2EE container, we get an xml document back that only represents the main level of the resultset with datatypes + memory addresses for the cursor fields (instead of the expected nested xml elements).
Any thoughts?
BTW, we are using the iPlanet Application Server with an Oracle 9i database.
for instance:
SELECT a, b, CURSOR(select m, n, o
from table2
where table1.x = table2.y),
d, e, f
FROM table1
WHERE table1.name = 'Matt'Somebody please answer this question?
-
Problem with XSU when trying to execute pl/sql package returning ref cursor
Hi,
I'm exploring xsu with 8i database.
I tried running sample program which I took from oracle
documentation. Here is the details of these.
------create package returning ref cursor---
CREATE OR REPLACE package testRef is
Type empRef IS REF CURSOR;
function testRefCur return empRef;
End;
CREATE OR REPLACE package body testRef is
function testRefCur RETURN empREF is
a empREF;
begin
OPEN a FOR select * from emp;
return a;
end;
end;
---------package successfully created-----
Now I use java program to generate xml data from ref cursor
------------java program ----------
import org.w3c.dom.*;
import oracle.xml.parser.v2.*;
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.xml.sql.query.OracleXMLQuery;
import java.io.*;
public class REFCURt
public static void main(String[] argv)
throws SQLException
String str = null;
Connection conn = getConnection("scott","tiger"); //
create connection
// Create a ResultSet object by calling the PL/SQL function
CallableStatement stmt =
conn.prepareCall("begin ? := testRef.testRefCur();
end;");
stmt.registerOutParameter(1,OracleTypes.CURSOR); // set
the define type
stmt.execute(); // Execute the statement.
ResultSet rset = (ResultSet)stmt.getObject(1); // Get the
ResultSet
OracleXMLQuery qry = new OracleXMLQuery(conn,rset); //
prepare Query class
try
qry.setRaiseNoRowsException(true);
qry.setRaiseException(true);
qry.keepCursorState(true); // set options (keep the
cursor alive..
System.out.println("..before printing...");
while ((str = qry.getXMLString())!= null)
System.out.println(str);
catch(oracle.xml.sql.OracleXMLSQLNoRowsException ex)
System.out.println(" END OF OUTPUT ");
qry.close(); // close the query..!
// qry.close(); // close the query..!
// Note since we supplied the statement and resultset,
closing the
// OracleXMLquery instance will not close these. We would
need to
// explicitly close this ourselves..!
stmt.close();
conn.close();
// Get the connection given the user name and password..!
private static Connection getConnection(String user, String
passwd)
throws SQLException
DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@xxxx:1521:yyyy",user,passwd);
return conn;
when I ran the program after successful compilation,I got the
following error
==========
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException:
1
at oracle.xml.sql.core.OracleXMLConvert.getXML(Compiled
Code)
at oracle.xml.sql.query.OracleXMLQuery.getXMLString
(OracleXMLQuery.java:263)
at oracle.xml.sql.query.OracleXMLQuery.getXMLString
(OracleXMLQuery.java:217)
at oracle.xml.sql.query.OracleXMLQuery.getXMLString
(OracleXMLQuery.java:194)
at REFCURt.main(Compiled Code)
============================
Can anybody tell me why I'm getting this error.Am I missing any
settings?
thanksWe are using 8.1.7 Oracle db with latest xdk loaded.
am I missing any settings? -
Can xsu not be used to update more than one table at a time.
I would like to update two or more tables using the same XML package. However when I use XML that contains tags using column names from both tables I get an error that the second table's columns names can not be found in the first table even if I use setUpdateColumnList and build an array that contains only columns from the first table.
Xsu does not do me a lot of good if only one table at a time can be updated.Assuming you are using Oracle 8i you may want to bone up on 'Object Views' and 'instead of' triggers. This is the functionality that is commonly used to perform multiple table updates from a single data source such as XML.
An object view can be based on a query such as 'select a.col1, a.col2, b.col1, b.col2 from a, b where a.key1 = b.key1'.
The object view is then used by the XSU to perform the XML query/update rather than using tables a and b.
You would then write an 'instead of' trigger on the object view. The trigger would update the appropriate table (a or b) based on the columns provided in the update list.
Steve's book 'Building Oracle XML Applications' in Chapter 12 explains how to do it and has sample code that demonstrates the process.
The book is available everywhere and you can download the sample code from the book at o'reilly's web site.
Good luck! -
Whe tryign to load the XSU package into the DBMS I get the following error:
<---------------------->
C:\Oracle\OracleXSU12\lib>echo "Loading jar files..."
"Loading jar files..."
C:\Oracle\OracleXSU12\lib>echo "Loading xmlparser..."
"Loading xmlparser..."
C:\Oracle\OracleXSU12\lib>call loadjava -r -v -u "SSDR/IPT@ipt" xmlparserv2.jar
initialization complete
loading : oracle/xml/parser/v2/XSLResultElement
creating : oracle/xml/parser/v2/XSLResultElement
Error while creating class oracle/xml/parser/v2/XSLResultElement
ORA-29516: Aurora assertion failure: Assertion failure at eox.c:187
Uncaught exception Root of all Java exceptions:
loading : oracle/xml/parser/v2/XSLCopy
creating : oracle/xml/parser/v2/XSLCopy
Error while creating class oracle/xml/parser/v2/XSLCopy
ORA-29516: Aurora assertion failure: Assertion failure at eox.c:187
Uncaught exception Root of all Java exceptions:
loading : oracle/xml/parser/v2/XMLByteReader
creating : oracle/xml/parser/v2/XMLByteReader
<----------------->
the initjvm.sql is performed wo errors
nullhi
i am also doing the same..but the same worked for me....which version of xsu ur trying to install??
i am working with xsu111
my problem is something else...when i am trying to execute the SQL statement..i am getting a JVM error and Java is terminating the program
any idea what might be the reason??
aniket
null -
Problem inserting value in CLOB column from an XML file using XSU
Hi,
When I try to insert CLOB value into Oracle9i database from an XML document using XSU, I get an exception as below.
09:37:32,392 ERROR [STDERR] oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException: ORA-03237: Initial Extent of specified size cannot be allocated
ORA-06512: at "SYS.DBMS_LOB", line 395
ORA-06512: at line 1
' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
All Element tags in XML doc. is mapped to columns in the database. One of the table columns is CLOB. That is the one that gives the above exception. Here is the xml...
ID - is autogenerated value.
<?xml version="1.0" ?>
<ROWSET>
<ROW num="1">
<ID></ID>
<SEQ>
GCATAGTTGTTATGAAGAAATGGAAGAAAAATGCACTCAAAGTTGGGCTGTCAGGCTGTCTGGGGCTGAATTCTGGTGTGACAGTGTGATGAAGCCATCTTTGAGCCTAAATTTGATAATGAGCCAGTCATGATCTGGTTGTGATTACTATAACAAGATTAAATCTGAATAAGAGAGCCACAACTTCTTTAAAGACAGATTGTCAAGTCATTACATGGAAGAGGGAGATTGCTCCTTTGTAAATCAGGCTGTCAGGCCAACTGAATGAAGGACGTCATTGTACAGTAACCTGATGAAGATCAGATCAACCGCTCACCTCGCCG
</SEQ>
</ROW>
</ROWSET>
Can anyone identify what's the problem.. and suggest a solution for this..?
Thanks in advance..
VijiWould you please specify the XDK verison and database version?
-
AnnotatedNoClassDefFound error when using OracleXMLSQL (XSU) in oc4j 10.1.3
This topic has been canvassed before in this forum, however, none of the replies/suggestions have worked in my case.
I am running on a Solaris x86 5.10 64 bit server, oc4j is 10.1.3 standalone production, jdeveloper is 10.1.3 production. My app is using the Oracle XMLSQL libraries. I migrated an application from JRE 1.4.2 to JRE 1.5.0, and migrated the dev and oc4j standalone environments at the same time. The app worked originally without the need to do more than import the requisite libraries used in the app. You will see from the error reported below, that despite the correct importation of the XSU libraries (IE no compile errors), that oracle.xdb.XMLType is deemed to be missing.
Here is the stack trace:
500 Internal Server Error
oracle.classloader.util.AnnotatedNoClassDefFoundError:
Missing class: oracle.xdb.XMLType
Dependent class: the.package.path.XML
Loader: the_app.web.the_app:0.0.0
Code-Source: /opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes/
Configuration: WEB-INF/classes/ in /opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes
The missing class is available from the following locations:
1. Code-Source: /opt/oc4j/j2ee/home/shared-lib/xdb/10.1.3/xdb.jar (from <code-source> in /opt/oc4j/j2ee/home/config/server.xml)
This code-source is available in loader xdb:10.1.3.
2. Code-Source: /opt/oc4j/j2ee/home/lib/ext/xdb.jar (from system property oc4j.ext.dirs)
This code-source is available in loader oc4j:10.1.3.
at oracle.classloader.PolicyClassLoader.handleClassNotFound (PolicyClassLoader.java:2051) [opt/oc4j/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@1482257]
at oracle.classloader.PolicyClassLoader.internalLoadClass (PolicyClassLoader.java:1665) [opt/oc4j/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@1482257]
at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1621) [opt/oc4j/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@1482257]
at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1606) [opt/oc4j/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@1482257]
at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:319) [jre bootstrap, by jre.bootstrap]
at the.package.path.XML.writeFromXMLtoDB (XML.java:268) [opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes/ (from WEB-INF/classes/ in /opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes), by the_app.web.the_app:0.0.0]
at au.gov.tas.dier.data.DataInterface.xmlToDBWrite (DataInterface.java:889) [opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes/ (from WEB-INF/classes/ in /opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes), by the_app.web.the_app:0.0.0]
at au.gov.tas.dier.data.Control.doWriteAuditRecord (Control.java:248) [opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes/ (from WEB-INF/classes/ in /opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes), by the_app.web.the_app:0.0.0]
at au.gov.tas.dier.data.Security.checkCredentials (Security.java:421) [opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes/ (from WEB-INF/classes/ in /opt/oc4j/j2ee/home/applications/the_app/the_app/WEB-INF/classes), by the_app.web.the_app:0.0.0]
at checkSecurity.jspService (_checkSecurity.java:386) [opt/oc4j/j2ee/home/application-deployments/the_app/the_app/persistence/_pages/ (from *.jsp in /opt/oc4j/j2ee/home/application-deployments/the_app/the_app/persistence/_pages), by the_app.web.the_app.jsp11671509:0.0.0]
at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.0.0) ].http.OrionHttpJspPage.service (OrionHttpJspPage.java:59) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at oracle.jsp.runtimev2.JspPageTable.service (JspPageTable.java:416) [opt/oc4j/j2ee/home/lib/ojsp.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at oracle.jsp.runtimev2.JspServlet.internalService (JspServlet.java:478) [opt/oc4j/j2ee/home/lib/ojsp.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at oracle.jsp.runtimev2.JspServlet.service (JspServlet.java:401) [opt/oc4j/j2ee/home/lib/ojsp.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at javax.servlet.http.HttpServlet.service (HttpServlet.java:856) [opt/oc4j/j2ee/home/lib/servlet.jar (from <code-source> (ignore manifest Class-Path) in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by api:1.4.0]
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke (ServletRequestDispatcher.java:719) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal (ServletRequestDispatcher.java:376) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.doProcessRequest (HttpRequestHandler.java:870) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.processRequest (HttpRequestHandler.java:451) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.serveOneRequest (HttpRequestHandler.java:218) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run (HttpRequestHandler.java:119) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run (HttpRequestHandler.java:112) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run (ServerSocketReadHandler.java:260) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket (ServerSocketAcceptHandler.java:230) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at oracle.oc4j.network.ServerSocketAcceptHandler.access$800 (ServerSocketAcceptHandler.java:33) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run (ServerSocketAcceptHandler.java:831) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run (ReleasableResourcePooledExecutor.java:303) [opt/oc4j/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in /opt/oc4j/j2ee/home/oc4j.jar), by oc4j:10.1.3]
at java.lang.Thread.run (Thread.java:595) [jre bootstrap, by jre.bootstrap]
The app works perfectly still in jdeveloper itself - the missing class referred to when running in standalone oc4j, oracle.xdb.XMLType, is present as part of xdb.jar, which lives in the rdbms folder in oc4j in jdev. It is not available in oc4j standalone.
The following was attempted to fix this problem:
1. I copied xdb.jar to rdbms folder in srtandalone oc4j, and still got the problem.
2. I included the jar specifically in the web app itelsf, so that it became available in WEB-INF/lib. No go.
3. I included the code in classes by including the output in the WEB-INF classes folder. No go.
4. I copied the library to applib to be picked up in the oc4j global sharing. No go.
5. I created a shared library under shared-lib. No go.
6. I copied the jar to j2ee/home/lib. No go.
7. I copied the jar to j2ee/home/lib/ext. No go.
8. Finally, the sledgehammer - I copied the jar to $JAVA_HOME/jre/lib/ext, and the library was found. In all I had to copy dms.jar, xdb.jar, servlet.jar and ojdbc14dsm.jar to the global external folder before the app would work.
In all cases 1-7 above I stopped and restarted oc4j. In all cases 1-7 the loader found the jar file in the intended location, but announced that it still could not load the class, even though it had been located, and was loaded in a loader of the same name! The above stack trace shows examples of two of the attempts.
The final "solution" isn't one - its an ugly kludge.
My question is, how does jdeveloper do it - how does it establish the right context for the load - if I could work that out, I could work at establishing the right context for XSU loading the XMLType class in the standalone environment.
Your assistance would be greatly appreciated in this matter.
Geoff Sharp
Message was edited by:
geoffshSorry, that should be AnnotatedNoClassDefFound
-
XSU doesn't support bind variables - how dumb is that?
I am using XSU to generate XML from a SQL statement using class OracleXMLQuery. Either I am blind or stupid or there is no support for bind variables in this class! I have used DBMS_xmlquery in PL/SQL before and this does support bind variables, I naturally assumed the Java equivalent would also have this. The lack of bind variable support means a huge performance hit as every single SQL statement will be treated as unique and will require hard parsing on the server!
Is there another Java XML utility I can use for generating XML from a SQL statement that does support bind variables? I have trawled through the Oracle documentation and I am getting very confused and lost.
Thanks,
Stevemakaidog,
Read get rid of community toolbar: Apple Support Communities. -
Storing XML using XSU, object VIEW and INSTEAD OF trigger
Here is the point:
I've got 2 tables which are linked:
CREATE TABLE dept (
deptno NUMBER PRIMARY KEY,
deptname VARCHAR2(20)
CREATE TABLE emp (
empno NUMBER PRIMARY KEY,
empname VARCHAR2(20),
deptno NUMBER REFERENCES dept(deptno)
I've got the following message, which I want to insert in the tables using XSU (I already have a PL/SQL stored procedure which work perfectly for insertion into 1 table, using DBMS_XMLSave.insertXML or xmlgen.insertXML):
<DEPT>
<DEPTNO>10</DEPTNO>
<DEPTNAME>IT</DEPTNAME>
<EMP>
<EMPNO>1</EMPNO>
<EMPNAME>John</EMPNAME>
</EMP>
<EMP>
<EMPNO>1</EMPNO>
<EMPNAME>Phil</EMPNAME>
</EMP>
</DEPT>
So I've created the following object:
CREATE TYPE emp_t AS OBJECT
empno NUMBER,
empname VARCHAR2(20)
CREATE TYPE emplist_t AS TABLE OF emp_t;
CREATE TYPE dept_t AS OBJECT
deptno NUMBER,
deptname VARCHAR2(20),
emplist emplist_t
Now I understand that I should create an object VIEW and an INSTEAD OF trigger (That's what I read many times),
but I don't know how to structure the view and the trigger.
Could you help? (Example of a similar context, piece of code)
Thanks a lot
MarionHi John,
I have exactly the same issue as you experienced back in January. I have a complex data modelling requirement which requires the need to pivot rows into columns using ROW_NUMBER() and PARTITION clauses. To hide the complexity from the middle tier, I have created a database view and appropriate INSTEAD OF triggers and mapped my EO to the view. I have overriden the lock() method on the EO implementation class (to avoid ORA-02014) and would like to try the same solution you used with the pl/sql call to lock the record.
My question is, how did you manage the release of the lock if the transaction was not rolled back or committed by your application i.e. if the user closed the browser for instance.
In my naivity, I would like to think that the BC4J framework would release any locks for the database session when it found the servlet session to be terminated however my concern is that the lock would persist and cause complications.
Any assistance greatly appreciated (if you would be willing to supply your lock() method and pl/sql procedure logic I would be even more grateful!).
Many thanks,
Dave
London -
Can XSU version 2.1.0 be installed on 8.1.6.2?
I'm trying to include attributes in my tags, and I get errors like, "Character '@' is not allowed in an XML tag name.", when I use a column alias in my query of the form, SELECT routine_id as "@id". I'm assuming this is supproted in versions of the XSU available to 9i.
Also, is there a way to check what version of the XSU I have installed?The version can be found in ..\xdk\doc\java\xsu\history.html
It says that from version 2.1.0 there is support for XML attributes. Could you give me the full path to XSU v.2.1.0? -
I've encountered an attribute mapping problem when using the Java OracleXMLQuery class in XSU (Oracle XML Developer's Kit for PL/SQL on Windows NT - 9i 9.2.0.1.0). As an example, take a look at the following object type containing one field whose name is prefaced with "@". This should cause XSU to map the field as an attribute rather than an element:
create or replace type testtype_t as object
"@test_attribute" varchar2(20),
test_element varchar2(30)
Here's the query passed to OracleXMLQuery:
select testtype_t('abc', 'def') "TEST1", testtype_t('ghi', 'jkl') "TEST2" from dual
Here's the output of the getXMLString method:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<TEST1 test_attribute="abc">
<TEST_ELEMENT>def</TEST_ELEMENT>
</TEST1>
<TEST2>
<test_attribute>ghi</test_attribute>
<TEST_ELEMENT>jkl</TEST_ELEMENT>
</TEST2>
</ROW>
</ROWSET>
Notice that the output is correct for the "TEST1" element - it contains a "test_attribute" attribute. The "TEST2" element, however, does not contain a "test_attribute" attribute. Instead, the field was output as a child element of "TEST2" called "test_attribute". To get around this, I had to create another object type as follows:
create or replace type testtype2_t as object
"@test_attribute" varchar2(20),
test_element varchar2(30)
It's format is identical to the "testtype_t" object type described above. Here's the new query passed to OracleXMLQuery:
select testtype_t('abc', 'def') "TEST1", testtype2_t('ghi', 'jkl') "TEST2" from dual
Here's the resulting output of the getXMLString method:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<TEST1 test_attribute="abc">
<TEST_ELEMENT>def</TEST_ELEMENT>
</TEST1>
<TEST2 test_attribute="ghi">
<TEST_ELEMENT>jkl</TEST_ELEMENT>
</TEST2>
</ROW>
</ROWSET>
Now, the "TEST2" element contains an attribute as it should.
It seems that the only time attributes are mapped correctly for a particular object type is when it is first encountered in the query. The mapping fails for each subsequent occurrence. Creating additional object type definitions is a solution, but this can result in the creation of many redundant object type definitions. Is there another solution available? Thanks . . .Hi,
Please tell me when you are getting this error and please explain a bit more what exactly you want to do..
Thanks
--Anil -
Error with XSU: oracle.jdbc2.Clob
When I try to insert data I get the following error.
java.lang.NoClassDefFoundError: oracle.jdbc2.Clob
void samp10.main(java.lang.String[])
Exception in thread main.
I use classes112.zip with Oracle 8.1.7.
I have Included following libraries in JDeveloper: Oracle XML SQL Utility, Oracle XML Parser 2.0, JServer, Connection Manager and Oracle 8.1.6 JDBC.
The sourcecode of my .java file is:
/** Simple example on using Oracle XMLSQL API; this class inserts the data from a XML document into the database*/
import oracle.xml.sql.dml.*;
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.jdbc.*;
import java.net.*;
public class samp10
//========================================
// main() - public static void
public static void main(String args[]) throws SQLException
String tabName = "XMLTEST_TAB1"; // table into which to insert
String fileName = "sampdoc.xml"; // file name containing the xml doc
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//initiate a JDBC connection
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:SJEFEN",
"scott","tiger");
OracleXMLSave sav = new OracleXMLSave(conn, tabName);
URL url = sav.createURL(fileName);
int rowCount = sav.insertXML(url);
System.out.println(" successfully inserted "+rowCount+
" rows into "+ tabName);
conn.close();
The source code for the XML Document is:
<?xml version="1.0"?>
<ROWSET>
<ROW num="1">
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
</ROW>
<ROW num="2">
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<JOB>SALESMAN</JOB>
</ROW>
<ROW num="3">
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
<JOB>SALESMAN</JOB>
</ROW>
</ROWSET>
I hope someone can help me!
nullThis occurs when you mismatch the xsu jar file with the classes1x.zip file (the jdbc driver).
xsu12.jar goes with classes12.zip
xsu111.jar goes with classes111.zip -
How to apply XSLT to XML file while importing XML data using XSU plsql API
I need to load XML file with nested repeating elements into Oracle tables and I am using XSU PLSQL API utility package dbms_xmlSave.insertXML. Can use XMLGen package also!!
I found out through documentation that I need to have XML file with ROWSET/ROW tags around the elements. As I have no control of XML file coming from external source, so I wish to apply XSLT to XML. I found setXSLT/setStylesheet procedures but it's not working as expected.
Can you help me with some sample code for the purpose.
ThanksI'm new at XML and XSL as well, but maybe the following code I built can help:
CREATE OR REPLACE PACKAGE Xml_Pkg AS
/* this record and table type are used for the transformTags procedure */
TYPE TagTransform_t IS RECORD (
old_tag VARCHAR2(255),
new_tag VARCHAR2(255) );
TYPE TagTransformList_t IS TABLE OF TagTransform_t INDEX BY BINARY_INTEGER;
/* use DBMS_OUTPUT to print out a CLOB */
PROCEDURE printClobOut(p_clob IN OUT NOCOPY CLOB);
/* using a list of old/new tags, transform all old into new in XML2 */
PROCEDURE transformTags(
p_List TagTransformList_t,
p_XML1 IN OUT NOCOPY CLOB,
p_XML2 IN OUT NOCOPY CLOB);
END Xml_Pkg;
CREATE OR REPLACE PACKAGE BODY Xml_Pkg AS
/* print a CLOB using newlines */
PROCEDURE printClobOut(p_clob IN OUT NOCOPY CLOB) IS
buffer_overflow EXCEPTION;
PRAGMA EXCEPTION_INIT(buffer_overflow,-20000);
l_offset NUMBER;
l_len NUMBER;
l_o_buf VARCHAR2(255);
l_amount NUMBER; --}
l_f_amt NUMBER := 0; --}To hold the amount of data
l_f_amt2 NUMBER; --}to be read or that has been
l_amt2 NUMBER := -1; --}read
l_offset2 NUMBER;
l_amt3 NUMBER;
l_chk NUMBER := 255;
BEGIN
l_len := DBMS_LOB.GETLENGTH(p_clob);
l_offset := 1;
WHILE l_len > 0 LOOP
l_amount := DBMS_LOB.INSTR(p_clob,CHR(10),l_offset,1);
--Amount returned is the count from the start of the file,
--not from the offset.
IF l_amount = 0 THEN
--No more linefeeds so need to read remaining data.
l_amount := l_len;
l_amt2 := l_amount;
ELSE
l_f_amt2 := l_amount; --Store position of next LF
l_amount := l_amount - l_f_amt; --Calc position from last LF
l_f_amt := l_f_amt2; --Store position for next time
l_amt2 := l_amount - 1; --Read up to but not the LF
END IF;
/* divide the read into 255 character chunks for dbms_output */
IF l_amt2 != 0 THEN
l_amt3 := l_amt2;
l_offset2 := l_offset;
WHILE l_amt3 > l_chk LOOP
DBMS_LOB.READ(p_clob,l_chk,l_offset2,l_o_buf);
DBMS_OUTPUT.PUT_LINE(l_o_buf);
l_amt3 := l_amt3 - l_chk;
l_offset2 := l_offset2 + l_chk;
END LOOP;
IF l_amt3 != 0 THEN
DBMS_LOB.READ(p_clob,l_amt3,l_offset2,l_o_buf);
DBMS_OUTPUT.PUT_LINE(l_o_buf);
END IF;
END IF;
l_len := l_len - l_amount;
l_offset := l_offset+l_amount;
END LOOP;
EXCEPTION
WHEN buffer_overflow THEN
RETURN;
END printClobOut;
/* shortcut "writeline" procedure for CLOB buffer writes */
PROCEDURE wr(p_clob IN OUT NOCOPY CLOB, s VARCHAR2) IS
BEGIN
DBMS_LOB.WRITEAPPEND(p_clob,LENGTH(s)+1,s||CHR(10));
END;
/* the standard XSLT should include the identity template or the output XML will be malformed */
PROCEDURE newXsltHeader(p_xsl IN OUT NOCOPY CLOB, p_identity_template BOOLEAN DEFAULT TRUE) IS
BEGIN
DBMS_LOB.TRIM(p_xsl,0);
/* standard XSL header */
wr(p_xsl,'<?xml version="1.0"?>');
/* note that the namespace for the xsl is restricted to the w3 1999/XSL */
wr(p_xsl,'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">');
IF p_identity_template THEN
/* create identity template (transfers all "other" nodes) */
wr(p_xsl,' <xsl:template match="node()">');
wr(p_xsl,' <xsl:copy>');
wr(p_xsl,' <xsl:apply-templates/>');
wr(p_xsl,' </xsl:copy>');
wr(p_xsl,' </xsl:template>');
END IF;
END newXsltHeader;
PROCEDURE newXsltFooter(p_xsl IN OUT NOCOPY CLOB) IS
BEGIN
/* standard xsl footer */
wr(p_xsl,'</xsl:stylesheet>');
END newXsltFooter;
/* using the stylesheet in p_xsl, transform p_XML1 into p_XML2 */
PROCEDURE transformXML(p_xsl IN OUT NOCOPY CLOB, p_XML1 IN OUT NOCOPY CLOB, p_XML2 IN OUT NOCOPY CLOB) IS
l_parser XMLPARSER.Parser;
l_doc XMLDOM.DOMDocument;
l_xsl_proc XSLPROCESSOR.Processor;
l_xsl_ss XSLPROCESSOR.Stylesheet;
BEGIN
/* parse XSL CLOB */
l_parser := XMLPARSER.newParser;
BEGIN
XMLPARSER.showWarnings(l_parser,TRUE);
XMLPARSER.parseClob(l_parser,p_xsl);
l_doc := XMLPARSER.getDocument(l_parser);
XMLPARSER.freeParser(l_parser);
EXCEPTION
WHEN OTHERS THEN
XMLPARSER.freeParser(l_parser);
RAISE;
END;
/* get Stylesheet from DOMDOC */
l_xsl_ss := XSLPROCESSOR.newStylesheet(l_doc,NULL);
BEGIN
/* parse XML1 CLOB */
l_parser := XMLPARSER.newParser;
BEGIN
XMLPARSER.showWarnings(l_parser,TRUE);
XMLPARSER.parseClob(l_parser,p_xml1);
l_doc := XMLPARSER.getDocument(l_parser);
XMLPARSER.freeParser(l_parser);
EXCEPTION
WHEN OTHERS THEN
XMLPARSER.freeParser(l_parser);
RAISE;
END;
/* process doc to XML2 */
l_xsl_proc := XSLPROCESSOR.newProcessor;
BEGIN
XSLPROCESSOR.processXSL(l_xsl_proc, l_xsl_ss, l_doc, p_xml2);
XSLPROCESSOR.freeProcessor(l_xsl_proc);
EXCEPTION
WHEN OTHERS THEN
XSLPROCESSOR.freeProcessor(l_xsl_proc);
RAISE;
END;
XSLPROCESSOR.freeStylesheet(l_xsl_ss);
EXCEPTION
WHEN OTHERS THEN
XSLPROCESSOR.freeStylesheet(l_xsl_ss);
RAISE;
END;
END transformXML;
/* transform XML1 into XML2 using list p_List of old/new tags */
PROCEDURE transformTags(p_List TagTransformList_t, p_XML1 IN OUT NOCOPY CLOB, p_XML2 IN OUT NOCOPY CLOB) IS
l_xsl CLOB;
BEGIN
/* create XSL CLOB */
DBMS_LOB.CREATETEMPORARY(l_xsl,TRUE);
/* create standard header with identity template */
newXsltHeader(l_xsl,TRUE);
/* create one template for each node translation */
FOR i IN 1..p_List.COUNT LOOP
wr(l_xsl,' <xsl:template match="'||p_List(i).old_tag||'">');
wr(l_xsl,' <'||p_List(i).new_tag||'><xsl:apply-templates/></'||p_List(i).new_tag||'>');
wr(l_xsl,' </xsl:template>');
END LOOP;
/* create standard footer */
newXsltFooter(l_xsl);
-- dbms_output.put_line('l_xsl:');
-- dbms_output.put_line('--------------------');
-- printClobOut(l_xsl);
-- dbms_output.put_line('--------------------');
transformXML(l_xsl, p_XML1, p_XML2);
DBMS_LOB.FREETEMPORARY(l_xsl);
/* -- unit testing
set serveroutput on size 100000
Declare
queryContext DBMS_XMLQUERY.ctxType;
xList XML_PKG.TagTransformList_t;
xmlCLOB CLOB;
xmlCLOB2 CLOB;
Begin
DBMS_LOB.CREATETEMPORARY(xmlCLOB,true);
DBMS_LOB.CREATETEMPORARY(xmlCLOB2,true);
xList(1).old_tag := 'A';
xList(1).new_tag := 'MyTag1';
xList(2).old_tag := 'B';
xList(2).new_tag := 'MyTag2';
queryContext := DBMS_XMLQUERY.newContext('Select * from t');
xmlCLOB := DBMS_XMLQUERY.getXML(queryContext);
DBMS_XMLQuery.closeContext(queryContext);
dbms_output.put_line('xmlCLOB:');
dbms_output.put_line('--------------------');
XML_PKG.printClobOut(xmlCLOB);
dbms_output.put_line('--------------------');
xml_pkg.transformTags(xList,xmlCLOB,xmlCLOB2);
dbms_output.put_line('xml2CLOB:');
dbms_output.put_line('--------------------');
XML_PKG.printClobOut(xmlCLOB2);
dbms_output.put_line('--------------------');
DBMS_LOB.FREETEMPORARY(xmlCLOB);
DBMS_LOB.FREETEMPORARY(xmlCLOB2);
End;
END transformTags;
END Xml_Pkg;
Maybe you are looking for
-
I put in My IMEI code and ICLOUD tells me THAT THE product has been replaced. I am doing This to TRY TO ACTIVATE MY IPHONE5 AS it wont Accept My 4 digit code after downloading IOS7 So My phone in disabaled, wont let me backup,restore kos FIND MY PHON
-
Click Bios II Won't Load?
Anyone else having an issue with Click Bios II in Windows 8.1 Pro?? Here is the setup.. Z77A-GD65 Windows 8.1 Pro Windows 7 Ultimate I have it setup for dual boot because i still provide tech support for a ton of 7 users so its just nice to have both
-
Local_listener name is different from listener.ora
I'm on 11g R2 solaris10 platform. lsnrctl status adv_sec_listener2 shows all the correct items I would expect including the Alias = adv_sec_listener2 but when I do lsnrctl status listener_farley it shows the same thing with Alias = adv_sec_listener2
-
Should Apple TV appear on my mac's network? Home Sharing
just hooked up my Apple TV and set up to home share on my itunes. the TV is not finding my itunes which is set up to home share and i cant see the apple tv in my finder, networks. Should i see the Apple TV on my mac? and any suggestions what to do to
-
Hi Friends, Is it advisable to use LDB to fetch details from HR infotypes. I know there would be advantages like Selection screen, Authorisation and so on.. these things can be achieved ourselves in code.. but I feel when i use LDB like PNP and sele