Printing ?xml version="1.0"..? tag in xmltype variable
I created the xmltype "result" by using xmlelement and xmlforest functions in a select query.
Now I need to add the "<?xml version="1.0" encoding="utf-8"?>" to the xmltype.
I tried manipulating the clob (result.getclobval()) using dbms_lob.append() ,dbms_lob.write() and dbms_lob.writeappend() functions in various combinations,but nothing seems to work.
Can anyone help me with this?
Thanks,
Aditi
Hi,
I want to strip it off because I am apppending the same in a Java Program.
Please let me know how can it be done.
Appreciate your inputs.
Thanks,
Dibya
Similar Messages
-
How to avoid priniting xml version... tag in output
hi,
I'm transforming an xml using xsl using output method="text". Not it is giving the something like the following tag in the top of output file.
<?xml version='1' encoding='UTF 8'?>
How can i remove this tag from not being printed.
A solutionasap will help us to proceed without hitches in our project.
thanx
Arun
nullHi !
I've got the same problem, I'm using Jdeveloper build 915. My xml is like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<SERVICE DISPLAYNAME="Aktiekurser" LONG_DESCRIPTION="Aktiekurser med slutkurser">
<PARAMETERS>
<STOCK NAME="STOCKTICKER" DISPLAYNAME="Aktie kod" DISPLAYTYPE="TEXT">
<UPPERLIMIT NAME="MAX" DISPLAYNAME="Max " DISPLAYTYPE="TEXT"/>
<LOWERLIMIT NAME="MIN" DISPLAYNAME="Min" DISPLAYTYPE="TEXT"/>
<CLOSE NAME="CLOSE" DISPLAYNAME="Stangningskurs" DISPLAYTYPE="CHECKBOX"/>
</STOCK>
</PARAMETERS>
</SERVICE>
and my xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:template match="SERVICE">
<xsl:value-of select="@LONG_DESCRIPTION"/>
<xsl:element name="TABLE">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="PARAMETERS/*">
<xsl:element name="TR">
<xsl:element name="TD">
<xsl:value-of select="@DISPLAYNAME"/>
<INPUT TYPE="{@DISPLAYTYPE}" NAME="{@NAME}" />
</xsl:element>
</xsl:element>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/SERVICE/PARAMETERS/*/*">
<xsl:element name="TD">
<xsl:value-of select="@DISPLAYNAME"/>
<INPUT TYPE="{@DISPLAYTYPE}" NAME="{@NAME}" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
I get
<?xml version = '1.0' encoding = 'UTF-8'?>
as the first row from the xsl-transform.
null -
?xml version="1.0"? tag not appearing as first characters in document
Hi,
JSP below successfully creates a XML document but it includes a blank line before the <?xml version="1.0"?> tag.
This causes my PL/SQL to return a "ORA-20100: Error occurred while parsing: PI names starting with 'xml' are
reserved." error when using the XMLPARSER package.
I am outputting the XML to IE5.0 but even if I do a SYSTEM out I get the same blank line before the initial tag.
There are posts on here that confirm the PI error is caused by the tag not being the first characters in the document, but no solution/fix is provided.
Any ideas much appreciated.
JSP Code
<%@ page import="java.sql.*, oracle.jbo.*, oracle.jdeveloper.cm.*, oracle.jdbc.*,oracle.xml.sql.query.*" %>
<%String driver="oracle.jdbc.driver.OracleDriver";
Driver d = new oracle.jdbc.driver.OracleDriver();
String dbURL="jdbc:oracle:thin:@localhost:1521:mydb";
String login="i2k";
String password="fred";
Connection cn = null;
cn = DriverManager.getConnection(dbURL,login,password);
// SQL Statement from URL Parameters
String sql = request.getParameter("sql");
if(sql == null){
sql = "select * from vfi_trans";
// Create SQL-to-XML Handler
OracleXMLQuery q = new OracleXMLQuery(cn, sql);
// Use <TransactionList> as document element for Rowset
q.setRowsetTag("TransactionList");
// Use <Transaction> for each row in the result
q.setRowTag("Transaction");
// set encoding
q.setEncoding("iso-8859-1");
// ensure lower case element names
q.useLowerCaseTagNames();
// Generate XML results and write to output
String xmldoc = q.getXMLString();
out.println(xmldoc.trim());
//System.out.println(xmldoc.indexOf("\n"));
cn.close();%>
PL/SQL
PROCEDURE XML_HANDLER2 IS
-- MODIFICATION HISTORY
-- Person Date Comments
vfiURL VARCHAR2(100);
parser xmlparser.Parser;
vfiXML xmldom.DOMDocument;
transactions xmldom.DOMNodeList;
transactions_found NUMBER;
curNode xmldom.DOMNode;
textChild xmldom.DOMNode;
v_itrans_site vfi_trans.itrans_site%TYPE;
BEGIN
dbms_output.put_line('Integrator 2000 Transactions');
-- This is the URL to browse for an XML-based vfi feed of stories on XML
vfiURL := 'http://10.1.1.111:7070/i2k25_html/ShowQuery.jsp?sql=select%20*%20from%20vfi_trans';
-- Set the machine to use as the HTTP proxy server for URL requests
http_util.setProxy('MYPROXY');
-- Parse the live XML vfi feed from Moreover.com by URL
parser := xmlparser.newParser;
vfiXML := xml.parseURL( vfiURL );
xmlparser.freeParser(parser);
-- Search for all <headline_text> elements in the document we recieve
transactions := xpath.selectNodes(vfiXML,'/TransactionList/ITRANS_ID');
-- Loop over the "hits" and print out the text of the title
FOR j IN 1..xmldom.getLength(transactions) LOOP
-- Get the current <headline_text> node (Note the list is zero-based!)
curNode := xmldom.item(transactions,j-1);
-- The text of the title is the first child (text) node of
-- the <headline_text> element in the list of "hits"
-- textChild := xmldom.getFirstChild(curNode);
v_itrans_site := xpath.valueof(curNode, '.');
dbms_output.put_line('('| |LPAD(j,2)| |') '| | v_itrans_site);
END LOOP;
-- Free the XML document full of vfi stories since we're done with it.
xml.freeDocument(vfiXML);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END; -- Procedure
nullCharles,
I believe that the blank line is caused by the JSP engine when it strips out the '<%@ page import...>' (replace bracket with brace) statement. God (or at least Larry E) forgive me for posting a link at IBM, but this article speaks to your issue:
http://www-106.ibm.com/developerworks/library/j-dynxml.html?dwzone=ibm
Maybe you need to put the <?xml?> tag in the jsp itself and strip it out of your xmldoc before outputting it.
Good luck. -
Leading ? xml version="1.0"? tag when creating / invoking web services
Hello friends. I'm wondering if anyone has any insight as to why I cannot create
a fully formed XML document when developing a web service which includes the standard
<? xml version="1.0" ?> leading tag.
If I include the leading tag in my XML mapping for a jws method, I am unable to
compile the service into an ear, getting the following error: "An unexpected
exception occurred while attempting to process the classes and annotations for
this Web Service." If I do not include the leading tag, I can compile into an
EAR file and invoke the web service from a HTTP POST, but I cannot include the
leading <?xml...> tag in my request. Considering that I'll be asking other vendors
to submit to my web services and creation of xml documents using DOM or other
methods automatically generates the <?xml ...>, I'm hoping I'm not going to have
to tell them to parse out this piece of the files they want to send me. Can anyone
help?
Thanks so much!
CMCM,
I suppose you have set 'http-xml=true' for this to work. For http-xml
protocol, there is no way to specify the leading <?xml> tag, and hence
unfortunately the desired functionality cannot be achieved.
In case, this is very important for you, could you please log a support
case, and then we can file a bug and ask the Engineering to look into it.
Thanks,
Anurag
"Crackhead Millionaire" <[email protected]> wrote in message
news:[email protected]...
>
Hi Anurag -
Thanks for the response. My problem is that I would like to be able tosubmit
straight XML (i.e., not SOAP) to a webservice from an application outsideof Weblogic.
For example, the following code block fails on submission to BEA:
* Example Simple Integration.
import java.io.*;
import java.net.*;
public class testBEAPost {
* Null constructor.
public testBEAPost () {
super();
* This method handles creation of a PeopleSoft XML Envelope, wrapping of
* user input into the envelope, submission of the message to theintegration
broker
* and display of the response message to the screen.
* @created 3.12.2003
* @param argv java.lang.String[] Standard user entry input
public static void main(String[] argv) {
try{
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;
// Create the internal XML document which will be to send to BEA.(hardcoded)
>
String internalXMLDoc = "<? xml version=\"1.0\"?><newlocationxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><setid>WMS</setid><l
ocationid>1118UG0000</locationid><description>Electric
UndergroundLocation</description><exceptionemailaddress>[email protected]<
/exceptionemailaddress></newlocation>";
>
// Define the target URL.
url = newURL("http://167.75.117.20:7001/WebServices/PeopleSoftWebServices/NewLocation
Service.jws/createLocation");
>
// Open the Conection
urlConn = url.openConnection();
// Set necessary connection variables.
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
// Specify the content type.
urlConn.setRequestProperty("Content-Type", "text/xml");
// Send POST output.
printout = new DataOutputStream (urlConn.getOutputStream ());
printout.writeBytes (internalXMLDoc);
printout.flush ();
printout.close ();
// Get response data.
input = new DataInputStream (urlConn.getInputStream ());
String str;
while (null != ((str = input.readLine())))
System.out.println (str);
input.close ();
} catch (Exception e)
System.out.println(e);
If I run this program, I get a java.io.IOException with the serverreturning a
500 error code. However, if I strip out the leading <? xml version="1.0"?> tag
and submit to the web service, it works fine. My program set I createdthis example
for uses DOM to create the document, so I'm actually creating thedocument, getting
the String value of it, then parsing out the leading tag beforesubmission. My
problem is that soon I'll be dealing with third parties who may havetrouble generating
SOAP requests (don't ask), so I'd like to be able to tell them to generatesimple
XML documents to send to BEA if at all possible.
Can you assist? Thanks so much.
"Anurag Pareek" <[email protected]> wrote:
CM,
A SOAP message generated by a Workshop web service, when it acts as a
client
to another service, always contains the leading <?xml> tag. Here is a
sample
of a SOAP message generated by Workshop:
POST /TestImport/TestAny/TestAny.jws HTTP/1.0
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client
Protocol 1.0.3705.0; BEA WLW 7.0)
SOAPAction: "http://www.openuri.org/hello2"
Host: localhost
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: Keep-Alive
Content-Length: 398
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<hello2 xmlns="http://www.openuri.org/">
<o></o>
</hello2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It seems to me that what you are asking for is already there. Could you
please elaborate your issue further, probably with a sample of a XML
message
which you feel is not accepted by Workshop, but should be.
Thanks,
Anurag
"Crackhead Millionaire" <[email protected]> wrote in message
news:[email protected]...
Hello friends. I'm wondering if anyone has any insight as to why Icannot
create
a fully formed XML document when developing a web service which
includes
the standard
<? xml version="1.0" ?> leading tag.
If I include the leading tag in my XML mapping for a jws method, Iam
unable to
compile the service into an ear, getting the following error: "Anunexpected
exception occurred while attempting to process the classes and
annotations
for
this Web Service." If I do not include the leading tag, I can compileinto an
EAR file and invoke the web service from a HTTP POST, but I cannotinclude
the
leading <?xml...> tag in my request. Considering that I'll be askingother vendors
to submit to my web services and creation of xml documents using DOMor
other
methods automatically generates the <?xml ...>, I'm hoping I'm notgoing
to have
to tell them to parse out this piece of the files they want to sendme.
Can anyone
help?
Thanks so much!
CM -
Stripping Off ?xml version="1.0" ? tag in the final output XML
Hi All,
Is there anyway that we can strip off the tag <?xml version="1.0" ?> from the Final XML generated by BPEL.
I have commented out<?xml version="1.0" ?> in the XSL mapper file but still it is coming in the output file that is generated.
Any help or pointer is really appreciated.
Thanks,
DibyaHi,
I want to strip it off because I am apppending the same in a Java Program.
Please let me know how can it be done.
Appreciate your inputs.
Thanks,
Dibya -
Delete xml messagetype tag and xml versioning tag in target xml file
Hi experts.
i want to delete the xml version, starting (<MT_ZMPSSERRMSGMST_SEND>*and ending </MT_ZMPSSERRMSGMST_SEND> tags in below message.
here i am bold the tags which i want to delete. please help me how to delete this.
<?xml version="1.0"; encoding="UTF-8"?>
<MT_ZMPSSERRMSGMST_SEND>
<MESSAGE>
<TABLENAME/>
<ACTION/>
<RECORD>
<ERRORID/>
<ERRCLASSID/>
<SHORTDESC/>
<DESCRIPTION/>
<RESOLVE/>
</RECORD>
</MESSAGE>
</MT_ZMPSSERRMSGMST_SEND>Hi Srinivas,
You can delete the required content of the XML by editing the XML.
Develop a custom adapter module and use the below code to edit the xml and deleting the highlighted content
// to read the input XML
strData = xmlData.getText();
// get the length of <?xml version="1.0"; encoding="UTF-8"?> <MT_ZMPSSERRMSGMST_SEND>
int strheaderlength = (strData.substring(0,strData.indexOf("<Message>")).length());
// read the data from <MESSAGE> to </MESSAGE>
String payload=strData.substring(strheaderlength,strData.startIndexOf("</MT_ZMPSSERRMSGMST_SEND>"))
// set the new payload to xmlData
xmlData.setText(payload);
appreciate if useful -
XMLType without "xml version=1.0"
Hi,SELECT XMLType(CURSOR(SELECT *
FROM dual))
FROM dual;How may I get the result as<ROWSET>
<ROW>
<DUMMY>X</DUMMY>
</ROW>
</ROWSET>and not the<?xml version="1.0"?>
<ROWSET>
<ROW>
<DUMMY>X</DUMMY>
</ROW>
</ROWSET>JackKWhy do you need it without the prolog?
Is it related to your previous question? {thread:id=2512929}
One way is to use EXTRACT() :
SQL> SELECT extract(
2 XMLType(
3 CURSOR(SELECT * FROM dual)
4 )
5 , '/*'
6 )
7 FROM dual;
EXTRACT(XMLTYPE(CURSOR(SELECT*
<ROWSET><ROW><DUMMY>X</DUMMY></ROW></ROWSET> -
Append XML version tag to PAYLOAD
Hi,
I wanted add XML tag <? xml version="1" conversion="UTF-8"?> to my payload.
please suggest me the way to achieve it.
I tried ora:toCDATA but could not achieve it.
Thanks,
Arun Jadhav.may b try getting your payload as string using ora:getContentAsString as use a concat operation and add your content and the parse it to XML using parasedEscapedXML
Edited by: Oraacler on May 9, 2010 12:01 PM -
Can anyone spot where I'm going wrong?
I'm creating a DOMDocument like this:
Document document = null;
DocumentBuilder doc_builder = null;
try
doc_builder = factory.newDocumentBuilder();
catch(ParserConfigurationException e){/* deal with exception*/}
document = doc_builder.newDocument();Adding various stuff to it, then saving it like this
Source source = new DOMSource(document);
Result result = new StreamResult(idx);
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.setOutputProperty(OutputKeys.METHOD, "xml");
xformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //??????
xformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
xformer.transform(source, result);All the usual stuff.
But how do I get it to write:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
at the top of the page?
One further thing...
If I have nothing to write in my xml file, it just spits out a blank file.
Instead, I want it to write:
<?xml version="1.0" encoding="UTF-8"?>
<upIdx/>
a simple:
document.createElement("upIdx");doesn't appear to do anything if the block "upIdx" is subsequently empty.
Many thanksduugggh....
(well it is friday evening.. ... long week.. all that kind of stuff)
how stupid of me....
to answer my own question, it was here:
xformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); //??????
xformer.setOutputProperty(OutputKeys.VERSION, "1.0");
xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); -
Hi all,
I am doing file to file scenario.When I use APPEND in the File adapter it is also adding <?xml version="1.0" encoding="UTF-8" ?>
I need to send a file for every 10 minutes consolidate all files and send at the end of the day.
<?xml version="1.0" encoding="UTF-8" ?>
<ID>31154</ID>
The next time when i send the file with different< ID>31155</ID>
it should append ignoring <?xml version="1.0" encoding="UTF-8" ?>
The consolidated file must look like this...
<?xml version="1.0" encoding="UTF-8" ?>
<ID>31154</ID>
< ID>31155</ID>
Thanks ,
SrinivasHey
as pointed out by everyone else,there is no straight way for this,one thing u can do is that create two separate scenarios.
in first scenario use content conversion on receiver side and keep on appending the text for 10 mins (guess this is ur pooling interval),now since ur using FCC u wont get <?xml version="1.0" encoding="UTF-8" ?>,you will get a flat file on receiver side.
after 10 mins u can have one more scenario which picks up this flat file and this time use FCC on sender side so that it will convert this flat file to XML,in this way you will get <?xml version="1.0" encoding="UTF-8" ?> only once.
hope this solves ur problem.
just make sure that you specify correct polling intervals for both the scenarios.
thanx
ahmad -
Client Java Proxy - ?xml version="1.0" encoding="UTF-8" tag missing
Hi All,
I have a Java Proxy to File scenario. I am getting the output in the SAP XI but when i check the XML payload <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> is missing from it. Rest of the document is coming fine.
Any idea how to fix it up?
Thanks and Regards,
Anurag Mahendru.Here it is:
Re: ABAP Proxy -> XI - > File on a Website
As I know, this is still on discussion, if the Java Proxy generation will be replaced by web service proxy generation.
But existing Java Proxy applications definitivley will run in PI 7.1 as well.
Regards
Stefan -
Insert Encoding tag into xml file. ?xml version="1.0"?
I am using oracle 10g.
I am using dbms_xmlgen.getxml function to generate xml data for oracle tables. I use utl_file to write data back into xml file.
Oracle is generating the file in the following manner...
<?xml version="1.0"?>
<ROWSET>
<ROW>
<RSLT_ID>1</RSLT_ID>
</ROW>
</ROWSET>
I want to change the following xml header to have encoding information in it as follows...
<?xml version="1.0" encoding = "AL32UTF8"?>
How do I achieve that?
Any suggestions?I want to change the following xml header to have encoding informationIn 10g I think you could use a xmlroot hack:
SQL> select xmlroot(xmlelement(e, dummy), version '1.0" encoding="AL32UTF8') xml from dual
XML
<?xml version="1.0" encoding="AL32UTF8"?>
<E>X</E>
1 row selected. -
DB XML version 2.5.13, php 5.2.10
Not sure what the problem is, but I'm not getting the XML content with this piece of code:
function getXmlDocumentByNameAsStringV1($documentName, $containerName){
$container = $this->mgr->openContainer($containerName);
$xmlDocument = $container->getDocument($documentName);
$xmlDocument->fetchAllData();
$content = $xmlDocument->getContent();
$documentName = $xmlDocument->getName();
echo "doc name= [$documentName]";
print $xmlDocument->getContent();
unset ($container);
return $content;
I basically created a wrapper class around the DB XML api.
I was trying to get the full XML content as a string with this function, but all I seem to get is just a reference.
I ended up doing a query on it instead to get me the getContent() call to get what I needed (which was full XML document with the document version and DOCTYPE refernces), but was wondering what I was doing wrong with this approach.
Also when I was inserting XML documents into the Oracle Berkely DB XML database that referenced a DTD the database seemed
to switch to a validate mode even though I did not turn on validation when either creating the container or opening the container.
Is there a way to overide what appears to be a valdiation mode when the document refernces a DTD?
I am running PHP 5.2.10 under Apache 2.2.14 with the binary release of DB XML version 2.5.13
I figured out that I had to put my DTD in the [Apache Root] directory for it to validate properly. Stuff I read
through the forums suggested that I needed to put the DTD at the root of where the databases are when
referencing a DTD with just a file name without any reference to file:/// etc.. or http://
I changed my home directory to a certain location:when I instantiated the
$env = new Db4Env();
$env->open($this->homeDirectory, $this->flagsDbEnvOpen)
In any case the work around for now is to just put the DTD in the location that it expects which is the Apache Root install directory.
It is a minor inconvenience, but thought I would mention it for others that may have run into this problem.
(I used the Process Monitor searching on my DTD name to discover the solution to where Oracle DB XML or rather Apache Web server, I suppose through the dlls
was expecting to find it)
Also it appears that the binary versino works with PHP 5.2.10 of apache. I did not need to recompile the code with the new apache version.
Is there any thing I should be worried about?
Also I was getting the following error:
// the code commented out below was an attempt to try and do a sub query from a valid XmlValue object.
// was unsuccesful. starting receiving errors such as
////[25-Nov-2009 15:24:26] PHP Fatal error: Uncaught exception 'xmlexception' with message 'Error: Sequence does not match type document-node() - found item of type element(APP_Test_Script, {http://www.w3.org/2001/XMLSchema}untyped) [err:XPTY0004], <query>:1:12' in C:\htdocs\app1\BackEnd.php:82
// Will attempt to reprocess xml into a php DOm node and extract out value that way, just to get something working.
// $subQuery = "//*";
// $categoryQContext = $this->mgr->createQueryContext();
// $categoryQuery = $this->mgr->prepare($subQuery, $categoryQContext);
// $testScriptValue = $AppScriptAsXmlValue->asString();
// echo $testScriptValue;
// echo "hello world";
// $categoryResults = $categoryQuery->execute($testScriptAsXmlValue, $categoryQContext);
// $categoryValue = null;
// while($categoryResults->hasNext()){
// $node = $categoryResults->next();
// $categoryValue = $node->asString();
Basically, I was trying to do a sub xquery from an initial xquery that returned a sequence of XML documents. According to the example in book The Definiitive Guide to Bekrely DB XML
it should have worked, but wasn't.
I also ran into an issue where I seemed to have locked up a container when I was editing an XML document in Oxygen and saving it back to the DB XML container from within Oxygen.
after that action it wouldn't return from the save function and I coudln't ever load up that container. Even trying to access the contain from the command line dbxml it wasn't able to access
that container again. I ended up having to blow it away from lack of knowledge on how to recover from that. If anyone has run into this and/or has some suggestions on this it would be nice.
I'm guessing could it be because I had some meta data values defined in some of these documents that I was updating. From Oxygen, can you create metadata? I dont think you can, at least it wasn't obvious to me except perhaps fro the name of the document (which is implicitly a meta data tag).Hi,
You'll have to compile yourself for different PHP API versions.
Regards,
George -
How to loop through XML data in a table of XMLType?
Hi,
I am failry new to xml document processing in Oracle using PL/SQL.
My DB version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
I have successfully loaded an xml document into a table using the following two statements:
1) CREATE TABLE mytable2 OF XMLType;
2) INSERT INTO mytable2 VALUES (XMLType(bfilename('IMAGE_FILE_LOC', 'IFTDISB20100330172157C002.xml'), nls_charset_id('AL32UTF8')));
Now I need to traverse through the various nodes within the xml document and extract values of elements of each node. The question I have is:
How do I loop through a node? A VALID record is enclosed within the <checkItem> </checkItem> tags.
Here is a snippet of the data in that xml document:
++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<bdiData>
<documentControlInfo>
<documentInfo>
<docDescription>Check images and data for Test Company, account number 1234567890</docDescription>
<docID>
<ID>20100330172157</ID>
</docID>
<docModifier>Test Company</docModifier>
<docCreateDate>2010-03-30</docCreateDate>
<docCreateTime>17:21:57-0700</docCreateTime>
<standardVersion>1.0</standardVersion>
<testIndicator>0</testIndicator>
<resendIndicator>0</resendIndicator>
</documentInfo>
<sourceInfo>
<sourceName>The Bank IFT</sourceName>
<sourceID>
<idOther>TheBankIFT</idOther>
</sourceID>
</sourceInfo>
<destinationInfo>
<destinationName>Test Company</destinationName>
<destinationID>
<idOther>FEI3592</idOther>
</destinationID>
</destinationInfo>
</documentControlInfo>
<checkItemCollection>
<collectionInfo>
<description>Items</description>
<ID>1269994919135</ID>
<Classification>
<classification>Items</classification>
</Classification>
</collectionInfo>
<checkItemBatch>
<checkItemBatchInfo>
<description>Paid Checks</description>
<ID>1269994919135</ID>
<Classification>
<classification>Paid Checks</classification>
</Classification>
</checkItemBatchInfo>
<checkItem>
<checkItemType>check</checkItemType>
<checkAmount>86468</checkAmount>
<postingInfo>
<date>2010-03-29</date>
<RT>10700543</RT>
<accountNumber>1234567890</accountNumber>
<seqNum>009906631032</seqNum>
<trancode>001051</trancode>
<amount>86468</amount>
<serialNumber>300040647</serialNumber>
</postingInfo>
<totalImageViewsDelivered>2</totalImageViewsDelivered>
<imageView>
<imageIndicator>Actual Item Image Present</imageIndicator>
<imageViewInfo>
<Format>
<Baseline>TIF</Baseline>
</Format>
<Compression>
<Baseline>CCITT</Baseline>
</Compression>
<ViewSide>Front</ViewSide>
<imageViewLocator>
<imageRefKey>201003260000738400851844567205_Front.TIF</imageRefKey>
<imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
</imageViewLocator>
</imageViewInfo>
<imageViewInfo>
<Format>
<Baseline>TIF</Baseline>
</Format>
<Compression>
<Baseline>CCITT</Baseline>
</Compression>
<ViewSide>Rear</ViewSide>
<imageViewLocator>
<imageRefKey>201003260000738400851844567205_Rear.TIF</imageRefKey>
<imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
</imageViewLocator>
</imageViewInfo>
</imageView>
</checkItem>
<checkItem>
<checkItemType>check</checkItemType>
<checkAmount>045</checkAmount>
<postingInfo>
<date>2010-03-29</date>
<RT>10700543</RT>
<accountNumber>1234567890</accountNumber>
<seqNum>008518967429</seqNum>
<trancode>001051</trancode>
<amount>045</amount>
<serialNumber>200244935</serialNumber>
</postingInfo>
<totalImageViewsDelivered>2</totalImageViewsDelivered>
<imageView>
<imageIndicator>Actual Item Image Present</imageIndicator>
<imageViewInfo>
<Format>
<Baseline>TIF</Baseline>
</Format>
<Compression>
<Baseline>CCITT</Baseline>
</Compression>
<ViewSide>Front</ViewSide>
<imageViewLocator>
<imageRefKey>201003290000713900851896742901_Front.TIF</imageRefKey>
<imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
</imageViewLocator>
</imageViewInfo>
<imageViewInfo>
<Format>
<Baseline>TIF</Baseline>
</Format>
<Compression>
<Baseline>CCITT</Baseline>
</Compression>
<ViewSide>Rear</ViewSide>
<imageViewLocator>
<imageRefKey>201003290000713900851896742901_Rear.TIF</imageRefKey>
<imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
</imageViewLocator>
</imageViewInfo>
</imageView>
</checkItem>
<checkItemBatchSummary>
<totalItemCount>1028</totalItemCount>
<totalBatchAmount>61370501</totalBatchAmount>
<totalBatchImageViewsDelivered>2056</totalBatchImageViewsDelivered>
</checkItemBatchSummary>
</checkItemBatch>
<collectionSummary>
<totalBatchCount>1</totalBatchCount>
<totalItemCount>1028</totalItemCount>
<totalCollectionAmount>61370501</totalCollectionAmount>
<totalCollectionImageViewsDelivered>2056</totalCollectionImageViewsDelivered>
</collectionSummary>
</checkItemCollection>
<documentSummaryInfo>
<totalCollectionCount>1</totalCollectionCount>
<totalBatchCount>1</totalBatchCount>
<totalItemCount>1028</totalItemCount>
<totalDocumentAmount>61370501</totalDocumentAmount>
<totalDocumentImageViewsDelivered>2056</totalDocumentImageViewsDelivered>
</documentSummaryInfo>
</bdiData>
++++++++++++++++++++++++++++++++++++++++++++++++
Any ideas and or suggestions will be greatly appreciated.
Cheers!
Edited by: user12021655 on Aug 3, 2010 1:25 PMI really need to update my blog to get the example you are looking for posted. I did a quick search on the forums for XMLTable and found a good example at {message:id=4325701}. You will want to use OBJECT_VALUE in the PASSING clause where you need to reference the column in your table.
Note: See the FAQ in the upper right for how to use the tag to wrap objects to retain formatting. Also your XML is missing closing nodes. -
Parse XML file, read a tag with whitespaces value.
Hi all,
I've got a problem with reading a spaced value record from xml file using sys.xmltype.
My xml file contains the following:
<?xml version = '1.0'?>;
<ROWSET>
<ROW num="1">
<FIRSTNAME>Nik</FIRSTNAME>
<LASTNAME> </LASTNAME>
<AGE>30</AGE>
</ROW>
</ROWSET>
As you see last name contains four spaces!
Now when I'm trying to read value from LASTNAME record I'm getting a NULL value, but I want it to return me those 4 spaces as they are.
Here is a short code description of what I'm doing:
declare
xml sys.xmltype;
str1 varchar2(100);
str2 varchar2(100);
begin
xml := sys.xmltype.createxml(fileContentClob); -- I copy the file content into the fileContentClob variable.
If xml.existsnode('//ROW['1']/LASTNAME') > 0 Then -- This condition evaluates as true
str1 := xml.extract('//ROW['1']/LASTNAME/text()'); -- str1 gets NULL value :(, I want spaces as they are in the file.
str2 := xml.extract('//ROW[' || 1 || ']/LASTNAME').getstringval; -- str2 gets <LASTNAME/> null tag :(.
End If;
end;
Seems like when it createxml from the fileContentClob it ignores the spaces and find LASTNAME as a null field.
Do you have any suggestions on how can I fix that, so I can read whitespaces as they are in the file?
I generate the file also using a xml toolpackage from oracle:
declare
strSqlStmt Varchar2(300);
varCtxHdl dbms_xmlquery.ctxhandle;
varClob Clob;
begin
strSqlStmt := 'SELECT FIRSTNAME,LASTNAME,AGE FROM USERS WHERE ROWNUM =1';
varCtxHdl := dbms_xmlquery.newcontext(strSqlStmt);
varClob := dbms_xmlquery.getxml(varCtxHdl);
dbms_xmlquery.closecontext(varCtxHdl);
End;Even if the STORE AS CLOB clause is used to store the data and preserve whitespace for the XML, the actual extraction of data seems to be removing whitespace...
SQL> ed
Wrote file afiedt.buf
1* create table t (xml xmltype) xmltype xml store as clob
SQL> /
Table created.
SQL> ed
Wrote file afiedt.buf
1 insert into t (xml)
2 values (q'[<?xml version = '1.0'?>
3 <ROWSET>
4 <ROW num="1">
5 <FIRSTNAME>Nik</FIRSTNAME>
6 <LASTNAME> </LASTNAME>
7 <AGE>30</AGE>
8 </ROW>
9* </ROWSET>]')
SQL> /
1 row created.
SQL> select * from t;
XML
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<FIRSTNAME>Nik</FIRSTNAME>
<LASTNAME> </LASTNAME>
<AGE>30</AGE>
</ROW>
</ROWSET>
SQL> set null NULL
SQL> select x.rnum, x.firstname, x.lastname, x.age
2 from t
3 ,xmltable('/ROWSET/ROW'
4 PASSING t.xml
5 COLUMNS rnum NUMBER PATH '/ROW/@num'
6 ,firstname VARCHAR2(10) PATH '/ROW/FIRSTNAME'
7 ,lastname VARCHAR2(10) PATH '/ROW/LASTNAME'
8 ,age NUMBER PATH '/ROW/AGE'
9 ) x
10 /
RNUM FIRSTNAME LASTNAME AGE
1 Nik NULL 30
SQL>
Maybe you are looking for
-
THE SHORT PROBLEM: 1) DVR records only a few moments of pre-scheduled events then the recording stops with only 10 to 30 seconds stored content and this is reported in the on screen detail. 2) DVR records a full 1 hour show however, after 20 or so mi
-
How to retrieve 2 values from a table in a LOV
Hi I'm pretty new to APEX. I try to retrieve two values from a table using a LOV. I have a table named DEBIT with then columns SITE, NAME and KEY I want to display NAME to the user in a list. When the user select an item from the list, I want to retr
-
Junk Mail folder refusing to show messages from a particular account
So, I have a weird problem with Leopard Mail (3.2) - when I click on the junk mail folder, 99% of the time it won't show messages from my Yahoo POP account. The only way I can get messages from this account to show is by expanding the junk mail folde
-
Does the Serial Number work for Mac and Windows?
I Purchased Photoshop Elements 12 it came with a Windows and a Mac Disc. My Son just got a Mac. I was wondering if I can install Elements on his Computer using the serial number I received from the Redemption code that I used for my Windows Laptop
-
How to make downtime shorter in BI upgrade project
hi expert, I am planning upgrade to BI7.0 from BW3.0B. After upgrade to BI700(ABAP), install AS-JAVA(EP,BI-JAVA) as addin installation. In this case downtime is not only for BI upgrade (ABAP) but also have to be considered install and setting bi-java