Validate certificates from received XML document
Hi,
I'm new to the Cryto API and have read the Java Cert Path API Prog. Guide. But I'm still not crystal clear on some details.
(1) In the code below, at (a), which certificate should I put in the selector? Note that the document may contain a chain of X509Certificates, but PKIBuilderParam seems to take only one cert via X509CertSelector
(2) Is CertPath validation still needed? (At point (b).) I think it is not needed as we build the CP already, but then I'm not sure.
(3) The code runs successfully but the "cp" list is empty. Is that normal? Note: the truststore key store contains the certificate found in the document.
(4) Do I miss anything else?
Thanks a lot!
Here is what my code looks like:
// The XML has certs in the XML signature. (We collect them using
// Apache XML Security library)
ArrayList<X509Certificate> certList = obj.getX509Certificates();
X509CertSelector selector = new X509CertSelector();
selector.setCertificate(certList.get(0)); // (a)
PKIXParameters params =
new PKIXBuilderParameters(trustStore, selector);
CertPathBuilder cpb = CertPathBuilder.getInstance("PKIX");
CertPath cp = cpb.build(params).getCertPath();
List certs = cp.getCertificates();
Iterator i = certs.iterator();
while (i.hasNext()) {
X509Certificate c = (X509Certificate) i.next();
System.out.println(c);
// (b)
CertPathValidator cpv = CertPathValidator.getInstance("PKIX");
CertPathValidatorResult cpvResult = cpv.validate(cp, params);
(1) In the code below, at (a), which certificate
should I put in the selector? Note that the document
may contain a chain of X509Certificates, but
PKIBuilderParam seems to take only one cert via
X509CertSelectorYou should put the end-entity (the signer's) certificate in the X509CertSelector.
(2) Is CertPath validation still needed? (At point
(b).) I think it is not needed as we build the CP
already, but then I'm not sure.No, it is not needed. A PKIX CertPathBuilder will return a chain that has been validated.
(3) The code runs successfully but the "cp" list is
empty. Is that normal? Note: the truststore key store
contains the certificate found in the document.This means that the certificate you are trying to validate is already trusted
(is this the case?, if not you should not include it as a trust anchor),
so there is no path to build (the path returned has length of 0).
--Sean
Similar Messages
-
How to insert data into a table from an xml document
using the XmlSql Utility, how do I insert data into a table from an xml document, using the sqlplus prompt.
if i use the xmlgen.insertXML(....)
requires a CLOB file, which i dont have, only the xml doc.
Cant i insert directly from the doc to the table?
the xmlgen examples I have seen first convert a table to a CLOB xmlString and then insert it into another table.
Isnt there any other way?Your question is little perplexing.
If you're using XML SQL Utility from
the commandline, just use putXML.
java OracleXML putXML
null -
Validate and update a XML document with rules
Hi,
In my project work, I am thinking about using oracle rules BRMS (business rule management system) to validate certain rules on xml document.
Since I am new to the oracle rules, I want to know the feasibility of doing this with oracle rules.
I have a specific question...
I have XML documents that are in different schema versions. these schema are fixed but can add them in future as well.
I have two things to do:
1. transform a given XML document (in a one version) to another version
2. Validate the new XML document against the rules defined in the oracle business rules.
1.I can do the 1st task using XSLT transformation. But there is one challenge. Assume that there are new tags are added in the target schema compared to the source schema of the XML document.
If there are optional tags to be added, I want to know if oracle rules can be used for that. Because I want to make these things done without changing the code (java) or the application internals.
2. I have few questions on the 2nd issue. They are:
a) can I create rules in oracle BRMS based on target schemas. (or to all of them. If so, what needs to be done if I add a new schema in future. How to update the rules?)
b) is it possible to group the rules created above in oracle BRMS.
Lets say
R1, R2 rules are created against schema1 (version 1)
R3, R4, R5 rules are created against schema2 (version 2)
R6, R7 rules are created against schema3(version 3)
Can I create group R1, R2 and R6 rules in to a one group (G1) and R1, R2 and R7 rules in to another group (G2).
What are the APIs available in oracle BRMS to retrieve above defined groups at run time? (because business user can define any rules, ad group them at run time)
Once I have the groups, How can I validate a XML document against a group created above? What are the APIs available for this.
c) is it possible to add/update/delete tags to a XML document based on rules in oracle BRMS? if so, how?
appreciate your valuable feedback on this..Hi Hareendra,
I think you should post your question in this other forum:
Forum Home » SOA & Process Management » SOA Suite
Oracle Business Rules is a component used in SOA Suite
Regards!
Jorge -
Receiving XML document and getting attachment via URL
What is the best method to retrieve a file from a provided URL. Here is the scenario. A system will send us an XML document via an HTTP post but the source system is unable to send us the associated attachment as a MIME attachment instead in the XML they will include a extra node with the URL to a file we need to get. What is the ideal method of retrieving this file once we receive the XML message. If the provided link was an ftp site we would hold the message in BPM and use the file adapter but since this is a full url such as http://someserver.com/myfile/file.doc we are looking for the best approach. On thought was a Java Proxy.
RegardsHi,
there are just two approaches:
easy one - java proxy
more diffcult - creating sync adapter for http xmls
I'd go for java proxy (if possible from secutiry point of view)
as you will have the link (so no "adapter configuration" necessary in your case)
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a> -
How to create and instance of Java Object from an XML Document.
Hi,
How can we use a XML Document to create an instance of Java Object and do vice versa ie from the Java Object creating the XML Document.
XML Document is available in the form of a String Object.
Are there helper class available to achieve this.
I need to do this in a Servlet.
Regards
Pramod.JAXB is part of JavaSE while Xmlbeans claims full schema support and full infoset fidelity.
If the standard APIs do all that you need well then use them. -
Receive XML document as Webservice Response
Hi
I have implemented webservices using axis.This works fine.
But I need an receive the response as an XML document.because for multiple entries of same tag name, i can parse through the document and do what ever i want.
Also how can i attach an external xsd for a wsdl.
I am stuck up at these two places,Your help would be appriciated
Thanks in advanceWeb service is platform independent hence most programming languages should return basic datatypes. In your case easiest thing would be to read that XSD file and convert entire file as String and return it as String. A document object will always throw an error.
Google to find out datatypes supported.
Hi Everyone,
Please let me know if this can be a quick resolution to his problem. -
Date insertion from large XML document (clob) into relation table very slow
Hi Everybody!
I'm working with Oracle 9.2.0.5 on Microsoft Windows Server 2003 Enterprise Edition.
The server (a test server) is a Pentium 4 2.8 GHz, 1GB of RAM.
I use a procedure called PARITOP_TRAITERXMLRESULTMASSE to insert the data contained in the pXMLDOC clob parameter in the table pTABLENAME. (You can see the format of the XML document below). The first step on this procedure is to verify that the XML document is not empty. If not, the procedure needs to add a node in the document, in every <ROW> tag. This added node is named âRST_IDâ. Itâs the foreign key of each record. I can retrieve the value of each <RST_ID> node in an other table in which the data has been previously added (by the calling procedure). When each of the <ROW> elements has been treated, the PARITOP_INSERTXML procedure is called. This procedure uses DBMS_XMLSAVE.INSERTXML to insert the data contained in the XML document in the specified table.
(Below, you can see the code of my procedures.)
With this information, can you tell me why this treatment is very very very slow with a large XML document and how I can improve it?
Thank you for your help!
Anne-Marie
CREATE OR REPLACE PROCEDURE "PARITOP_TRAITERXMLRESULTMASSE" (
pPRC_ID IN PARITOP_PARC.PRC_ID%TYPE,
pRST_MONDE IN PARITOP_RESULTAT.RST_MONDE%TYPE,
pXMLDOC IN CLOB,
pTABLENAME IN VARCHAR2)
AS
Objectif :Insérer le contenu du XML passé en paramètre (pXMLDOC) à la table passée en paramètre (pTABLENAME)
La table passée en paramètre doit être une table ayant comme clé étrangère le champs "RST_ID" .
(Le noeud RST_ID est donc ajouté à tous les document XML. Ce rst_id est
déterminé à partir de la table PARITOP_RESULTAT grâce à pPRC_ID et
pRstMonde fournis en paramètre)
result_doc CLOB;
XMLDOMDOC XDB.DBMS_XMLDOM.DOMDOCUMENT;
NODE_ROWSET DBMS_XMLDOM.DOMNODE;
NODE_ROW DBMS_XMLDOM.DOMNODE;
vUE_ID PARITOP_RESULTAT.UE_ID%TYPE;
vRST_ID PARITOP_RESULTAT.RST_ID%TYPE;
nodeList DBMS_XMLDOM.DOMNODELIST;
BEGIN
BEGIN
vUE_ID := 0;
vRST_ID := 0;
XMLDOMDOC := DBMS_XMLDOM.NEWDOMDOCUMENT(pXMLDOC);
IF NOT GESTXML_PKG.FN_PARITOP_DOCUMENT_IS_NULL(XMLDOMDOC) THEN
NODE_ROWSET := DBMS_XMLDOM.item(DBMS_XMLDOM.GETCHILDNODES (DBMS_XMLDOM.MAKENODE(XMLDOMDOC)),0);
for i in 0..dbms_xmldom.getLength(DBMS_XMLDOM.getchildnodes(NODE_ROWSET))-1 loop
NODE_ROW := DBMS_XMLDOM.ITEM(DBMS_XMLDOM.GETCHILDNODES(NODE_ROWSET), i) ;
nodeList := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(DBMS_XMLDOM.makeelement(NODE_ROW) , 'UE_ID');
IF vUE_ID <> DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0))) THEN
vUE_ID := DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0)));
--on ramasse le rst_id
SELECT RST_ID INTO vRST_ID
FROM PARITOP_RESULTAT RST
WHERE RST.PRC_ID = pPRC_ID
AND RST.UE_ID = vUE_ID
AND RST.RST_MONDE = pRST_MONDE
AND RST_A_SUPPRIMER = 0;
END IF;
GESTXML_PKG.PARITOP_ADDNODETOROW(XMLDOMDOC, NODE_ROW, 'RST_ID', vRST_ID);
end loop;
RESULT_DOC := ' '; --Ã garder, pour ne pas que ca fasse d'erreur lors du WriteToClob.
dbms_xmldom.writeToClob(DBMS_XMLDOM.MAKENODE(XMLDOMDOC), RESULT_DOC);
--Insertion du document XML dans la table "tableName"
GESTXML_PKG.PARITOP_INSERTXML(RESULT_DOC, pTABLENAME);
DBMS_XMLDOM.FREEDOCUMENT( XMLDOMDOC);
end if;
EXCEPTION
[â¦exception treatementâ¦]
END;
END;
The format of a XML clob is :
<ROWSET>
<ROW>
<PRC_ID>193</PRC_ID>
<UE_ID>8781</UE_ID>
<VEN_ID>6223</VEN_ID>
<RST_MONDE>0</RST_MONDE>
<CMP_SELMAN>0</CMP_SELMAN>
<CMP_INDICESELECTION>92.307692307692307</CMP_INDICESELECTION>
<CMP_PVRES>94900</CMP_PVRES>
<CMP_PVAJUSTE>72678.017699115066</CMP_PVAJUSTE>
<CMP_PVAJUSTEMIN>72678.017699115095</CMP_PVAJUSTEMIN>
<CMP_PVAJUSTEMAX>72678.017699115037</CMP_PVAJUSTEMAX>
<CMP_PV>148000</CMP_PV>
<CMP_VALROLE>129400</CMP_VALROLE>
<CMP_PVRESECART>4790</CMP_PVRESECART>
<CMP_PVRHAB>101778.01769911509</CMP_PVRHAB>
<CMP_UTILISE>1</CMP_UTILISE>
<CMP_TVM>1</CMP_TVM>
<CMP_PVA>148000</CMP_PVA>
</ROW>
<ROW>
<PRC_ID>193</PRC_ID>
<UE_ID>8781</UE_ID>
<VEN_ID>6235</VEN_ID>
<RST_MONDE>0</RST_MONDE>
<CMP_SELMAN>0</CMP_SELMAN>
<CMP_INDICESELECTION>76.92307692307692</CMP_INDICESELECTION>
<CMP_PVRES>117800</CMP_PVRES>
<CMP_PVAJUSTE>118080</CMP_PVAJUSTE>
<CMP_PVAJUSTEMIN>118080</CMP_PVAJUSTEMIN>
<CMP_PVAJUSTEMAX>118080</CMP_PVAJUSTEMAX>
<CMP_PV>172000</CMP_PV>
<CMP_VALROLE>134800</CMP_VALROLE>
<CMP_PVRESECART>0</CMP_PVRESECART>
<CMP_PVRHAB>147180</CMP_PVRHAB>
<CMP_UTILISE>1</CMP_UTILISE>
<CMP_TVM>1</CMP_TVM>
<CMP_PVA>172000</CMP_PVA>
</ROW>
</ROWSET>
PARITOP_COMPARABLE TABLE :
RST_ID NUMBER(10) NOT NULL,
VEN_ID NUMBER(10) NOT NULL,
CMP_SELMAN NUMBER(1) NOT NULL,
CMP_UTILISE NUMBER(1) NOT NULL,
CMP_INDICESELECTION FLOAT(53) NOT NULL,
CMP_PVRES FLOAT(53) NULL,
CMP_PVAJUSTE FLOAT(53) NULL,
CMP_PVRHAB FLOAT(53) NULL,
CMP_TVM FLOAT(53) NULL
ROCEDURE PARITOP_INSERTXML (xmlDoc IN clob, tableName IN VARCHAR2)
AS
insCtx DBMS_XMLSave.ctxType;
rowss number;
BEGIN
--permet d'insérer les champs du XML dans la table passée en paramètre.
--il suffit que les champs XML aient le même nom que les champs de la table
BEGIN
insCtx := DBMS_XMLSave.newContext(tableName); -- get context handle
DBMS_XMLSAVE.SETDATEFORMAT( insCtx, 'yyyy-MM-dd HH:mm:ss');--attention, case sensitive
DBMS_XMLSAVE.setIgnoreCase(insCtx, 1);
rowss := DBMS_XMLSAVE.INSERTXML(insCtx , xmlDoc);
DBMS_XMLSave.closeContext(insCtx);
EXCEPTION
[â¦]
END;
END;
PROCEDURE PARITOP_ADDNODETOROW (
XMLDOMDOC DBMS_XMLDOM.DOMDOCUMENT,
NODE_ROW dbms_xmldom.DOMNode,
NOM_NOEUD VARCHAR2,
VALEUR_NOEUD VARCHAR2)
AS
--PERMET D'AJOUTER UN NOEUD AVEC 1 SEULE VALEUR DANS une ROW D'UN XML.
--UTILE SURTOUT POUR LES CLÃS ÃTRANGÃRES
domElemAInserer DBMS_XMLDOM.DOMELEMENT;
NODE dbms_xmldom.DOMNode;
NODE_TMP dbms_xmldom.DOMNode;
BEGIN
domElemAInserer := DBMS_XMLDOM.createElement(XMLDOMDOC, NOM_NOEUD) ;
NODE := DBMS_XMLDOM.MAKENODE(domElemAInserer); --cast
NODE := DBMS_XMLDOM.APPENDCHILD(NODE_ROW,NODE);
NODE_TMP := DBMS_XMLDOM.MAKENODE(DBMS_XMLDOM.CREATETEXTNODE(XMLDOMDOC, VALEUR_NOEUD ) );
NODE := DBMS_XMLDOM.APPENDCHILD(NODE,NODE_TMP );
END;Hi Everybody!
I'm working with Oracle 9.2.0.5 on Microsoft Windows Server 2003 Enterprise Edition.
The server (a test server) is a Pentium 4 2.8 GHz, 1GB of RAM.
I use a procedure called PARITOP_TRAITERXMLRESULTMASSE to insert the data contained in the pXMLDOC clob parameter in the table pTABLENAME. (You can see the format of the XML document below). The first step on this procedure is to verify that the XML document is not empty. If not, the procedure needs to add a node in the document, in every <ROW> tag. This added node is named âRST_IDâ. Itâs the foreign key of each record. I can retrieve the value of each <RST_ID> node in an other table in which the data has been previously added (by the calling procedure). When each of the <ROW> elements has been treated, the PARITOP_INSERTXML procedure is called. This procedure uses DBMS_XMLSAVE.INSERTXML to insert the data contained in the XML document in the specified table.
(Below, you can see the code of my procedures.)
With this information, can you tell me why this treatment is very very very slow with a large XML document and how I can improve it?
Thank you for your help!
Anne-Marie
CREATE OR REPLACE PROCEDURE "PARITOP_TRAITERXMLRESULTMASSE" (
pPRC_ID IN PARITOP_PARC.PRC_ID%TYPE,
pRST_MONDE IN PARITOP_RESULTAT.RST_MONDE%TYPE,
pXMLDOC IN CLOB,
pTABLENAME IN VARCHAR2)
AS
Objectif :Insérer le contenu du XML passé en paramètre (pXMLDOC) à la table passée en paramètre (pTABLENAME)
La table passée en paramètre doit être une table ayant comme clé étrangère le champs "RST_ID" .
(Le noeud RST_ID est donc ajouté à tous les document XML. Ce rst_id est
déterminé à partir de la table PARITOP_RESULTAT grâce à pPRC_ID et
pRstMonde fournis en paramètre)
result_doc CLOB;
XMLDOMDOC XDB.DBMS_XMLDOM.DOMDOCUMENT;
NODE_ROWSET DBMS_XMLDOM.DOMNODE;
NODE_ROW DBMS_XMLDOM.DOMNODE;
vUE_ID PARITOP_RESULTAT.UE_ID%TYPE;
vRST_ID PARITOP_RESULTAT.RST_ID%TYPE;
nodeList DBMS_XMLDOM.DOMNODELIST;
BEGIN
BEGIN
vUE_ID := 0;
vRST_ID := 0;
XMLDOMDOC := DBMS_XMLDOM.NEWDOMDOCUMENT(pXMLDOC);
IF NOT GESTXML_PKG.FN_PARITOP_DOCUMENT_IS_NULL(XMLDOMDOC) THEN
NODE_ROWSET := DBMS_XMLDOM.item(DBMS_XMLDOM.GETCHILDNODES (DBMS_XMLDOM.MAKENODE(XMLDOMDOC)),0);
for i in 0..dbms_xmldom.getLength(DBMS_XMLDOM.getchildnodes(NODE_ROWSET))-1 loop
NODE_ROW := DBMS_XMLDOM.ITEM(DBMS_XMLDOM.GETCHILDNODES(NODE_ROWSET), i) ;
nodeList := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(DBMS_XMLDOM.makeelement(NODE_ROW) , 'UE_ID');
IF vUE_ID <> DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0))) THEN
vUE_ID := DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0)));
--on ramasse le rst_id
SELECT RST_ID INTO vRST_ID
FROM PARITOP_RESULTAT RST
WHERE RST.PRC_ID = pPRC_ID
AND RST.UE_ID = vUE_ID
AND RST.RST_MONDE = pRST_MONDE
AND RST_A_SUPPRIMER = 0;
END IF;
GESTXML_PKG.PARITOP_ADDNODETOROW(XMLDOMDOC, NODE_ROW, 'RST_ID', vRST_ID);
end loop;
RESULT_DOC := ' '; --Ã garder, pour ne pas que ca fasse d'erreur lors du WriteToClob.
dbms_xmldom.writeToClob(DBMS_XMLDOM.MAKENODE(XMLDOMDOC), RESULT_DOC);
--Insertion du document XML dans la table "tableName"
GESTXML_PKG.PARITOP_INSERTXML(RESULT_DOC, pTABLENAME);
DBMS_XMLDOM.FREEDOCUMENT( XMLDOMDOC);
end if;
EXCEPTION
[â¦exception treatementâ¦]
END;
END;
The format of a XML clob is :
<ROWSET>
<ROW>
<PRC_ID>193</PRC_ID>
<UE_ID>8781</UE_ID>
<VEN_ID>6223</VEN_ID>
<RST_MONDE>0</RST_MONDE>
<CMP_SELMAN>0</CMP_SELMAN>
<CMP_INDICESELECTION>92.307692307692307</CMP_INDICESELECTION>
<CMP_PVRES>94900</CMP_PVRES>
<CMP_PVAJUSTE>72678.017699115066</CMP_PVAJUSTE>
<CMP_PVAJUSTEMIN>72678.017699115095</CMP_PVAJUSTEMIN>
<CMP_PVAJUSTEMAX>72678.017699115037</CMP_PVAJUSTEMAX>
<CMP_PV>148000</CMP_PV>
<CMP_VALROLE>129400</CMP_VALROLE>
<CMP_PVRESECART>4790</CMP_PVRESECART>
<CMP_PVRHAB>101778.01769911509</CMP_PVRHAB>
<CMP_UTILISE>1</CMP_UTILISE>
<CMP_TVM>1</CMP_TVM>
<CMP_PVA>148000</CMP_PVA>
</ROW>
<ROW>
<PRC_ID>193</PRC_ID>
<UE_ID>8781</UE_ID>
<VEN_ID>6235</VEN_ID>
<RST_MONDE>0</RST_MONDE>
<CMP_SELMAN>0</CMP_SELMAN>
<CMP_INDICESELECTION>76.92307692307692</CMP_INDICESELECTION>
<CMP_PVRES>117800</CMP_PVRES>
<CMP_PVAJUSTE>118080</CMP_PVAJUSTE>
<CMP_PVAJUSTEMIN>118080</CMP_PVAJUSTEMIN>
<CMP_PVAJUSTEMAX>118080</CMP_PVAJUSTEMAX>
<CMP_PV>172000</CMP_PV>
<CMP_VALROLE>134800</CMP_VALROLE>
<CMP_PVRESECART>0</CMP_PVRESECART>
<CMP_PVRHAB>147180</CMP_PVRHAB>
<CMP_UTILISE>1</CMP_UTILISE>
<CMP_TVM>1</CMP_TVM>
<CMP_PVA>172000</CMP_PVA>
</ROW>
</ROWSET>
PARITOP_COMPARABLE TABLE :
RST_ID NUMBER(10) NOT NULL,
VEN_ID NUMBER(10) NOT NULL,
CMP_SELMAN NUMBER(1) NOT NULL,
CMP_UTILISE NUMBER(1) NOT NULL,
CMP_INDICESELECTION FLOAT(53) NOT NULL,
CMP_PVRES FLOAT(53) NULL,
CMP_PVAJUSTE FLOAT(53) NULL,
CMP_PVRHAB FLOAT(53) NULL,
CMP_TVM FLOAT(53) NULL
ROCEDURE PARITOP_INSERTXML (xmlDoc IN clob, tableName IN VARCHAR2)
AS
insCtx DBMS_XMLSave.ctxType;
rowss number;
BEGIN
--permet d'insérer les champs du XML dans la table passée en paramètre.
--il suffit que les champs XML aient le même nom que les champs de la table
BEGIN
insCtx := DBMS_XMLSave.newContext(tableName); -- get context handle
DBMS_XMLSAVE.SETDATEFORMAT( insCtx, 'yyyy-MM-dd HH:mm:ss');--attention, case sensitive
DBMS_XMLSAVE.setIgnoreCase(insCtx, 1);
rowss := DBMS_XMLSAVE.INSERTXML(insCtx , xmlDoc);
DBMS_XMLSave.closeContext(insCtx);
EXCEPTION
[â¦]
END;
END;
PROCEDURE PARITOP_ADDNODETOROW (
XMLDOMDOC DBMS_XMLDOM.DOMDOCUMENT,
NODE_ROW dbms_xmldom.DOMNode,
NOM_NOEUD VARCHAR2,
VALEUR_NOEUD VARCHAR2)
AS
--PERMET D'AJOUTER UN NOEUD AVEC 1 SEULE VALEUR DANS une ROW D'UN XML.
--UTILE SURTOUT POUR LES CLÃS ÃTRANGÃRES
domElemAInserer DBMS_XMLDOM.DOMELEMENT;
NODE dbms_xmldom.DOMNode;
NODE_TMP dbms_xmldom.DOMNode;
BEGIN
domElemAInserer := DBMS_XMLDOM.createElement(XMLDOMDOC, NOM_NOEUD) ;
NODE := DBMS_XMLDOM.MAKENODE(domElemAInserer); --cast
NODE := DBMS_XMLDOM.APPENDCHILD(NODE_ROW,NODE);
NODE_TMP := DBMS_XMLDOM.MAKENODE(DBMS_XMLDOM.CREATETEXTNODE(XMLDOMDOC, VALEUR_NOEUD ) );
NODE := DBMS_XMLDOM.APPENDCHILD(NODE,NODE_TMP );
END; -
Read xml-structure from a xml-document stored in a xmltype-column?
Hello,
I have several xml-documents stored in a table with a xmltype-column.
Is it possible to read the structure of one xml-document? I need to know what data are exists in the xml-documents.
I had read some hours here, but I dont find a suitable solution for that.
To make a example, what I need:
I have stored the following xml-document in the table:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="6">
<EMPLOYEE_ID>105</EMPLOYEE_ID>
<FIRST_NAME>David</FIRST_NAME>
<LAST_NAME>Austin</LAST_NAME>
<EMAIL>DAUSTIN</EMAIL>
<PHONE_NUMBER>590.423.4569</PHONE_NUMBER>
<HIRE_DATE>6/25/1997 0:0:0</HIRE_DATE>
<JOB_ID>IT_PROG</JOB_ID>
<SALARY>4800</SALARY>
<MANAGER_ID>103</MANAGER_ID>
<DEPARTMENT_ID>60</DEPARTMENT_ID>
</ROW>
</ROWSET>
I need to return the following:
ROWSET
...ROW
......EMPLOYEE NUMBER
......FIRST_NAME VARCHAR2
......DEPARTMENT_ID NUMBER
Regards,
MarkHi,
I was on a wrong way. The datatype is not stored in xml, this was a mistake from me.
I needed something to printout some values from a xml-file. This xml-file was generated bei MS Excel. The data are in /Workbook/Worksheet/Table/Cell and I didnt know how to access it.
I write for that the following:
DECLARE
v_xml XMLType;
v_doc dbms_xmldom.DOMDocument;
v_node dbms_xmldom.DOMNode;
type t_values is table of varchar2(2000) index by binary_integer;
v_values t_values;
type t_table is table of t_values index by binary_integer;
v_table t_table;
procedure node_output (v_node in out dbms_xmldom.DOMNode)
is
v_nodelist1 DBMS_XMLDOM.DOMNodeList;
v_nodelist2 DBMS_XMLDOM.DOMNodeList;
v_anzahlnodes number;
v_anzahlrows number;
v_node_c dbms_xmldom.DOMNode;
v_xmlmitarbeiterid number;
begin
v_nodelist1 := dbms_xmldom.GETCHILDNODES(v_node);
v_anzahlrows := DBMS_XMLDOM.GETLENGTH(v_nodelist1);
if v_anzahlrows = 0 or DBMS_XMLDOM.GETNODENAME(v_node) = 'Table'
then
if v_anzahlrows > 0
then
for i1 in 0..v_anzahlrows - 1
loop
v_node := dbms_xmldom.Item(v_nodelist1,i1);
v_nodelist2 := dbms_xmldom.GETCHILDNODES(v_node);
v_anzahlnodes := DBMS_XMLDOM.GETLENGTH(v_nodelist2);
for i2 in 0..v_anzahlnodes - 1
loop
v_node := dbms_xmldom.Item(v_nodelist2,i2);
v_node_c := dbms_xmldom.GETFIRSTCHILD(v_node);
v_node_c := dbms_xmldom.GETFIRSTCHILD(v_node_c);
v_values(i2) := DBMS_XMLDOM.GETNODEVALUE(v_node_c);
end loop;
v_table(i1) := v_values;
end loop;
for i1 in 1..v_anzahlrows - 1
loop
select SEQ_XMLMITARBEITER.nextval into v_xmlmitarbeiterid from dual;
for i2 in 1..v_table(i1).count - 1
loop
dbms_output.put_line(v_table(i1)(i2));
end loop;
end loop;
end if;
else
v_node := dbms_xmldom.GETFIRSTCHILD(v_node);
for i in 0..v_anzahlrows - 1
loop
v_node := dbms_xmldom.Item(v_nodelist1,i);
node_output(v_node);
end loop;
end if;
end;
BEGIN
select inhalt into v_xml FROM xmlimport WHERE name = 'F23973/mitarbeiter.xml';
v_doc := dbms_xmldom.newDOMDocument(v_xml);
v_node:= dbms_xmldom.makeNode(dbms_xmldom.getDocumentElement(v_doc));
node_output(v_node);
END;
This gives me all data from a xml-Excel-file. Is there a better way to do that? I have Oracle 10.2.
Regards,
Mark -
Build the delta from two xml documents
Hi,
i look for a solution to solve the following problem:
i want to build a xml-based interface to pass my data to a client(Web etc.) and i dont know in which way the client manipulates the data and what in the xml-document was changed, inserted or deleted.
What i have is the original-document and the changed-document (both based on the same DTD). How can i determine the delta from the two documents, cause i must know what actions to be taken (for example put <?bc4j remove?> or an appropriate tag for the XDK in the xml)
any suggestion ???
TIA
OliverThe Oracle XDK for Java comes with a utility called XMLDiffer that, given XML Documents A and B, produces an XSLT stylesheet S that transforms A to B.
Might be of use to you. That's the only inhouse XML diffing technology that I'm aware of. We use it internally in JDeveloper for merging machine-generate web.xml file edits with the user's hand-written web.xml file edits. -
How to get multiple html output file from an xml document via xslt?
Hi,
the purpose is to generate multiple html output file from one xml file
depending on special tag.
exp: i have an xml file which contains sevreral articles so how to get each article section in an independant html file
Thanks for helpNot a standard feature of XSLT. But Michael Kay's XSLT implementation, SAXON, provides that as an extension. Get it here:
http://saxon.sourceforge.net/ -
How to check empty return from Get XML Document Data?
If Get XML Document Data doesn't return a result, how do you test it? String.isEmpty() doesn't do the trick, it still throws the exception "java.lang.NullPointerException". I can't seem to be able to match that up to a cisco exception with a "On Exception Goto" step (which I put right before the XML Document Data step). Any clues anyone?
Hi,
Try this:
variable=Get XML Document Data ()
if(variable == null) then
true
false
Gabriel. -
Send and receiving XML documents out/into APO
Hi all,
We are on APO 5.0 and want to send our forecast from a planning book to a partner and also receive their data.
Has anybody ever done this via XML?
We are not planning to use ICH. But we have XI or could use Business Connector?
Any response is appreciated! Thanks
GMHi,
I would suggest you for XI with Proxy. Or either you can go for RFC but better is using proxy for communicating.
Thanks,
Prakash -
How to select specific element from a XML document using JDBC?
Hi all,
I have a problem with selecting specific XML element in Oracle 11g release 1 from my java application. Data are stored in object-relational storage.
My file looks like:
<students>
<student id="1">
</student>
<student id="2">
</student>
<student id="3">
</student>
</students>
I need to select a specific <student> element. I've already tried few ways to achieve my goal but I failed.
SELECT extract(OBJECT_VALUE,'/students/student') FROM students - works fine, but this selects all <student> elements
SELECT extract(OBJECT_VALUE,'/students/student[1]') FROM students - which should select first <student> element works too but it causes exception when using JDBC driver returns:
java.sql.SQLException: Only LOB or String Storage is supported in Thin XMLType
at oracle.xdb.XMLType.processThin(XMLType.java:2817)
at oracle.xdb.XMLType.<init>(XMLType.java:1238)
at oracle.xdb.XMLType.createXML(XMLType.java:698)
at oracle.xdb.XMLType.createXML(XMLType.java:676)
at cz.zcu.hruby.data.Select.getStudent(Select.java:45)
SELECT to_clob(extract(OBJECT_VALUE,'/students/student[1]')) FROM students - in this case I hoped that DB would convert result to CLOB but the element is quite large (definitely more than 4000 Bytes long which I find out from forum is limit). But this exception occurs:
java.sql.SQLException: ORA-19011: Character string buffer too small
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:953)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:897)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at cz.zcu.hruby.data.Select.getStudent(Select.java:40)
SELECT to_lob(extract(OBJECT_VALUE,'/students/student[1]')) FROM students - I hoped I can convert return value to a LOB value but that doesn't work for me either:
java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected -, got -
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at cz.zcu.hruby.data.Select.getStudent(Select.java:40)
This behaviour raises two questions:
1) Why SELECT extract(OBJECT_VALUE,'/students/student') FROM students works but SELECT extract(OBJECT_VALUE,'/students/student[1]') FROM students does't ?
2) Is there any way how I can select specific element (element XPath /students/student[@id="some value"]) and convert it to String?
Thanks for your responses I would appreciate any suggestion
HonzaTo be exact my <student> element is a bit complicated and looks like the one at the end of this post (sorry but it's in czech). And I need to select whole xml fragment (all opening and closing tags included) as it is shown. Maybe I used wrong solution and I should use CLOB storage. I discuss this issue here: Which solution for better perfomance?
Thanks anyway for your response. I would be very grateful if you have any further idea
<Student RodneCislo="8051015555">
<Jmeno>Petra</Jmeno>
<Prijmeni>Nováková</Prijmeni>
<RodnePrijmeni>Novotná</RodnePrijmeni>
<TitulPred>Bc.</TitulPred>
<TitulZa>MBA.</TitulZa>
<Adresa>
<Okres>3702</Okres>
<Obec>582786</Obec>
<CastObce>11908</CastObce>
<Ulice>Nova</Ulice>
<UliceCislo>4</UliceCislo>
<PSC>60000</PSC>
<Stat>203</Stat>
</Adresa>
<RodinnyStav>1</RodinnyStav>
<StredniSkola>000559024</StredniSkola>
<RokMatZkousky>2001</RokMatZkousky>
<PPStudent DatumVerifikace="2006-08-04">
<SoubeznaStudia>1</SoubeznaStudia>
<SoubeznaStudiaMaxDelka>2.0</SoubeznaStudiaMaxDelka>
<CelkovaDobaStudia>1817</CelkovaDobaStudia>
</PPStudent>
<Studia>
<Studium VSFakulta="14330" StudijniProgram="B1801" ZapisDoStudia="2001-07-10">
<DelkaStudia>5.0</DelkaStudia>
<NovePrijaty>N</NovePrijaty>
<NavazujiciStudProgram>N</NavazujiciStudProgram>
<PredchoziVzdelani>K</PredchoziVzdelani>
<PocetRocniku>5</PocetRocniku>
<AktualniRocnik>5</AktualniRocnik>
<UbytovaniVKoleji>3</UbytovaniVKoleji>
<UkonceniStudia Datum="2004-06-28" Zpusob="1" UdelenyTitul="Bc."/>
<StudiumEtapy>
<StudiumEtapa PlatnostOd="2001-07-10">
<ObcanstviKvalifikator>1</ObcanstviKvalifikator>
<ObcanstviStat>203</ObcanstviStat>
<PobytVCR>A</PobytVCR>
<JazykVyuky>cze</JazykVyuky>
<StudijniObory>
<Obor>1801R001</Obor>
<Obor>1801R005</Obor>
</StudijniObory>
<AprobaceOboru>
<Aprobace>01</Aprobace>
</AprobaceOboru>
<MistoVyuky>582786</MistoVyuky>
<FormaStudia>P</FormaStudia>
<Financovani>1</Financovani>
<PreruseniStudia>S</PreruseniStudia>
<PlatnostDo>2002-04-24</PlatnostDo>
</StudiumEtapa>
<StudiumEtapa PlatnostOd="2002-04-24">
<ObcanstviKvalifikator>1</ObcanstviKvalifikator>
<ObcanstviStat>203</ObcanstviStat>
<PobytVCR>A</PobytVCR>
<StudijniPobyt Forma="V" Program="51" Stat="056"/>
<JazykVyuky>cze</JazykVyuky>
<StudijniObory>
<Obor>1801R001</Obor>
<Obor>1801R005</Obor>
</StudijniObory>
<AprobaceOboru>
<Aprobace>01</Aprobace>
</AprobaceOboru>
<MistoVyuky>582786</MistoVyuky>
<FormaStudia>P</FormaStudia>
<Financovani>1</Financovani>
<PreruseniStudia>S</PreruseniStudia>
<PlatnostDo>2002-09-01</PlatnostDo>
</StudiumEtapa>
<StudiumEtapa PlatnostOd="2002-09-01">
<ObcanstviKvalifikator>1</ObcanstviKvalifikator>
<ObcanstviStat>203</ObcanstviStat>
<PobytVCR>A</PobytVCR>
<JazykVyuky>cze</JazykVyuky>
<StudijniObory>
<Obor>1801R001</Obor>
<Obor>1801R005</Obor>
</StudijniObory>
<AprobaceOboru>
<Aprobace>01</Aprobace>
</AprobaceOboru>
<MistoVyuky>582786</MistoVyuky>
<FormaStudia>P</FormaStudia>
<Financovani>1</Financovani>
<PreruseniStudia>S</PreruseniStudia>
<PlatnostDo>2004-06-28</PlatnostDo>
</StudiumEtapa>
</StudiumEtapy>
</Studium>
<Studium VSFakulta="14330" StudijniProgram="N1802" ZapisDoStudia="2004-06-29">
<DelkaStudia>2.0</DelkaStudia>
<NovePrijaty>N</NovePrijaty>
<NavazujiciStudProgram>A</NavazujiciStudProgram>
<PredchoziVzdelani>R</PredchoziVzdelani>
<PocetRocniku>2</PocetRocniku>
<AktualniRocnik>1</AktualniRocnik>
<UbytovaniVKoleji>3</UbytovaniVKoleji>
<SocialniStipendia>
<SocialniStipendium NarokOd="2006-01-01">
<NarokDo>2006-10-30</NarokDo>
</SocialniStipendium>
</SocialniStipendia>
<UkonceniStudia Datum="" Zpusob="" UdelenyTitul=""/>
<PPStudium DatumVerifikace="2006-07-01">
<NovePrijatyVerif>N</NovePrijatyVerif>
<NovePrijatyKvalif>N</NovePrijatyKvalif>
<NavazujiciStudProgramVerif>A</NavazujiciStudProgramVerif>
<UkonceniStudiaVerif/>
<FinancovanoCR>A</FinancovanoCR>
<SberId>38</SberId>
<DobaStudia>
<Cista>733</Cista>
<VcetneNeuspechuDanehoTypu>733</VcetneNeuspechuDanehoTypu>
<VcetneVsechNeuspechu>733</VcetneVsechNeuspechu>
</DobaStudia>
<PrestoupenoKamPosledni VSFakulta="14330" StudijniProgram="N1802" ZapisDoStudia="2004-06-29"/>
<UbytovaciStipendiumKod/>
</PPStudium>
<StudiumEtapy>
<StudiumEtapa PlatnostOd="2004-06-29">
<ObcanstviKvalifikator>1</ObcanstviKvalifikator>
<ObcanstviStat>203</ObcanstviStat>
<PobytVCR>A</PobytVCR>
<JazykVyuky>eng</JazykVyuky>
<StudijniObory>
<Obor>1801T001</Obor>
<Obor>1801T025</Obor>
</StudijniObory>
<AprobaceOboru>
<Aprobace>01</Aprobace>
</AprobaceOboru>
<MistoVyuky>582786</MistoVyuky>
<FormaStudia>P</FormaStudia>
<Financovani>1</Financovani>
<PreruseniStudia>S</PreruseniStudia>
<PlatnostDo/>
<PPStudiumEtapa DatumVerifikace="2006-07-01">
<FinancovaniVerif>1</FinancovaniVerif>
<StudentRozpoctovy>O</StudentRozpoctovy>
<SberId>38</SberId>
</PPStudiumEtapa>
</StudiumEtapa>
</StudiumEtapy>
</Studium>
</Studia>
</Student> -
Display an Image from a XML document
I am trying to read an xml element, that contains a name of an gif file. I use this name and set it the src value for the image. Except the image will not display in my HTML table.
The following line of code is in my javascript and is apart of my XML DOM reading function. I have test this code and temp.firstChild.nodeValue does contain the name of my image - one.gif.
document.myform.IMAGE.src = temp.firstChild.nodeValue;
The following is apart of the HTML body.
<form name = "myform">
<table>
<tr>
<td><input type="image" name="IMAGE"></td>
</tr>
</table>
</form>
How can I set the IMAGE file to equal my XML element and display in my table ?
Thanks
Brendontry this:
try {
JLabel label = new JLabel(new ImageIcon(new URL("http://developers.sun.com/forums/img/gold.gif")));
JScrollPane sp = new JScrollPane(label);
catch (MalformedURLException x) {
x.printStackTrace();
} -
Extracting data from an XML document that uses namespaces
Hello all,
Firstly, please let me wish you all a very happy and prosperous 2013!
I have a piece of XML containing namespaces (retrieved from a web service) and I am having difficulty extracting values
(If you're interested this is the webservice: http://api.worldbank.org/countries/FRA/indicators/NY.GDP.MKTP.CD?date=2009)
Here is some test code with two cases -
1) where I leave in the namespace and
2) where I strip out all references to the namespace
Case 1 doesn't work, whereas Case 2 works well.
I would prefer a more elegant solution than simply stripping out the namespace.
I have probably just misunderstood something about how to work with namespaces in PL/SQL.
Do any of you have suggestions about how best to approach this?
Many thanks in advance.
Niall.
set serveroutput on
set define off
DECLARE
v_xml XMLTYPE;
v_clob CLOB;
v_country VARCHAR2(255);
BEGIN
v_clob := '<?xml version="1.0" encoding="utf-8"?>
<wb:data page="1" pages="1" per_page="50" total="1" xmlns:wb="http://www.worldbank.org">
<wb:data>
<wb:indicator id="NY.GDP.MKTP.CD">GDP (current US$)</wb:indicator>
<wb:country id="FR">France</wb:country>
<wb:date>2009</wb:date>
<wb:value>2619685000757.11</wb:value>
<wb:decimal>0</wb:decimal>
</wb:data>
</wb:data>';
v_xml := XMLTYPE(v_clob);
SELECT extractvalue(v_xml,'/data/data[1]/country', 'xmlns:"http://www.worldbank.org/"')
INTO v_country
FROM dual;
dbms_output.put_line(' ');
dbms_output.put_line('*** Case 1');
dbms_output.put_line('*** '||nvl(v_country,'nothing'));
dbms_output.put_line(v_xml.getStringVal());
v_xml := XMLTYPE(replace(v_clob,'wb:')); -- strip out wb:
SELECT extractvalue(v_xml,'/data/data[1]/country', 'xmlns:"http://www.worldbank.org/"')
INTO v_country
FROM dual;
dbms_output.put_line(' ');
dbms_output.put_line('*** Case 2');
dbms_output.put_line('*** '||nvl(v_country,'nothing'));
dbms_output.put_line(v_xml.getStringVal());
END;
/Your case 1 query should be
(not tested)
SELECT extractvalue(v_xml,'/wb:data/wb:data[1]/wb:country', 'xmlns:wb="http://www.worldbank.org/"')If the XML is going to be small, you could also do it this way purely in PL/SQL
[url http://anononxml.blogspot.com/2010/06/xml-parsing-with-namespaces-via-plsql.html]XML Parsing with Namespaces via PL/SQL. Ignore the DOMDocument examples (first two) in there.
If the XML will be large and you are on 11.1 or greater, then it would be faster to insert the XML into a column in a DB table (could be a global temporary table) where the column is XMLType and the storage is SECUREFILE BINARY (default on 11.2.0.2+). Then you could use XMLTable, like
[url http://anononxml.blogspot.com/2010/08/xml-parsing-with-namespaces-via.html]XML Parsing with Namespaces via XMLTable
Maybe you are looking for
-
Multiple developers working on the same application/project
Hi All, We have multiple developers working differnt components of the same application/project. As most of them are working on their local systems within their local projects which later has to be integrated as one application project I am afraid th
-
I have used the assessment template to build my writable form and it looks great. But when I save it as a PDF, I lose the header. Also, the text areas fill in blue. How can I fix this.
-
Would like new window to open in new tab as to opening in an exsisting tab and replacing open window
Would like new window to open in new tab as to opening in an exsisting tab and replacing open window
-
Wich function (class) could I use to create one pixel high object (frame)?
Hi guys, I need a pointer on a certatin line on the graphic screen. And I want it to be written in Java. I know how to make it to be "always on top" now, but AFAIK every applet or application is to be shown in a bordered window saying it is a Java ob
-
When I updated to OS 5.0 my old apple id which was not an e-mail address won't work anymore, how can I fix this?