Oracle8i Application Developer's Guide - XML
Release 3 (8.1.7)

Part Number A86030-01

Library

Service

Contents

Index

Go to previous page Go to beginning of chapter Go to next page

Using XML Parser for PL/SQL, 7 of 7


Frequently Asked Questions (FAQs): XML Parser for PL/SQL

Exception in Thread Parser Error

Question

When I try to use the oraxsl I get the following: Exeception in thread "main":

java.lang.NoClassDefFoundError" oracle/xml/parser/v2/oraxsl. 

How do I fix this?

Answer

Can you provide more details as to your configuration and usage? If you are running outside the database you need to make sure the xmlparserv2.jar is explicitly in your CLASS_PATH not simply its directory. If from the database you need to make sure it has been properly loaded and that JServer initialized.

Encoding '8859_1' is not currently supported by the JavaVM

Question

I parsed my XML document using the XML Parser for PL/SQL and modified some of the node values of the DOMDocument by using "setNodeValue". When I tried to write the modified DOMDocument to buffer or file using "writeToBuffer" or "writeToFile, both commands gave me the following error:

ORA-20101: Error occurred while accessing a file or URL: Encoding '8859_1' is 
not currentlysupported by the JavaVM

Comment

I just reinstalled initjvm.sql and also installed the latest version of the XML Parser for PL/SQL. Everything is working fine.

xmldom.GetNodeValue in PL/SQL

Question

I cannot get the element value using the PL/SQL XMLDOM. Here is the code fragment:

...nl := xmldom.getElementsByTagName(doc, '*');
len := xmldom.getLength(nl)
;-- loop through elements
   for i in 0..len-1 loop      n := xmldom.item(nl, i); 
     elename := xmldom.getNodeName(n);      
eleval := xmldom.getNodeValue(n);
...elename is Ok, but eleval is NULL. 

Associating with a text node does not seem to work, or I am not doing it correctly? I receive a compile error, for example:

...t xmldom.DOMText;
...t := xmldom.makeText(n);
eleval := xmldom.getNodeValue(t);

What am I doing wrong?

Comment

I found the answer to my own question. To get the text node value associated with the element node, you must perform additional node navigation via xmldom.getFirstChild(n).

To illustrate, change printElements() in DOMSample.sql as follows:

begin   
-- get all elements   
nl := xmldom.getElementsByTagName(doc, '*');  
 len := xmldom.getLength(nl); 
  -- loop through elements   
for i in 0..len-1 loop      n := xmldom.item(nl, i);
      dbms_output.put(xmldom.getNodeName(n));
      -- get the text node associated with the element node
      n := xmldom.getFirstChild(n); 
     if xmldom.getNodeType(n) = xmldom.TEXT_NODE then         dbms_
output.put('=' | | xmldom.getNodeValue(n));
      end if; 
     dbms_output.put(' ');
   end loop;
   dbms_output.put_line('');
end printElements;

This produces the following output:

The elements are:

family member=Sarah member=Bob member=Joanne member=Jim

The attributes of each element are:

family:familylastname val=Smithmember:membermemberid val=m1member:membermemberid 
val=m2member:membermemberid val=m3 mom val=m1 dad val=m2member:membermemberid 
val=m4 mom val=m1 dad val=m2

XDK for PL/SQL Toolkit

Question

I downloaded XDK for PL/SQL but it requires OAS. Do you have any idea how to run this in an IIS environment?

Answer

If you're going to use IIS, it would be better to use the XML Parser for Java V2.You'll need Oracle8i.

Parsing DTD contained in a CLOB (PL/SQL) XML

Question

I am having problems parsing a DTD file contained in a CLOB. I used the API, "xmlparser.parseDTDClob", provided by the XML Parser for PL/SQL.

The following error was thrown:

"ORA-29531: no method parseDTD in class oracle/xml/parser/plsql/XMLParserCover". 

The procedure xmlparser.parseDTDClob calls a Java Stored Procedure xmlparsercover.parseDTDClob, which in turn calls another Java Stored Procedure xmlparsercover.parseDTD.

I have confirmed that the class file, "oracle.xml.parser.plsql.XMLParserCover", has been loaded into the database, and that it has been published. So the error message does not make sense. The procedure used to call "xmlparser.parseDTDClob" is:

create or replace procedure parse_my_dtd as p xmlparser.parser; l_clob clob; 
begin   p := xmlparser.newParser;   select content into l_clob from dca_
documents where doc_id = 1;   xmlparser.parseDTDClob(p,l_clob,'site_template'); 
end; API Documentation for xmlparser.parseDTDClob: 

parseDTDClob PURPOSE   Parses the DTD stored in the given clob SYNTAX   
PROCEDURE parseDTDClob(p Parser, dtd CLOB, root VARCHAR2); PARAMETERS   p        
(IN)-  parser instance  dtd      (IN)-  dtd clob to parse  root     (IN)-  name 
of the root element RETURNS   Nothing COMMENTS

Any changes to the default parser behavior should be effected before calling this procedure. An application error is raised if parsing failed, for some reason. Description of the table dca_documents:

DOC_ID         NOT NULL   NUMBER  DOC_NAME       NOT NULL   VARCHAR2(350)  DOC_
TYPE                  VARCHAR2(30)
 DESCRIPTION               VARCHAR2(4000)  MIME_TYPE                 
VARCHAR2(48)  CONTENT        NOT NULL   CLOB  CREATED_BY     NOT NULL   
VARCHAR2(30)  CREATED_ON     NOT NULL   DATE  UPDATED_BY     NOT NULL   
VARCHAR2(30)  UPDATED_ON     NOT NULL   DATE

The contents of the dtd:

<!ELEMENT site_template (component*)> <!ATTLIST site_template template_id CDATA 
#REQUIRED> <!ATTLIST site_template template_name CDATA #REQUIRED> <!ELEMENT 
component (#PCDATA)> <!ATTLIST component component_id ID #REQUIRED> <!ATTLIST 
component parent_id ID #REQUIRED> <!ATTLIST component component_name ID 
#REQUIRED>

Answer

This is a known issue in the 1.0.1 release of the XML Parser for PL/SQL. Here is the workaround.

  1. Make a backup of ./plsqlxmlparser_1.0.1/lib/sql/xmlparsercover.sql

  2. In line 18 in xmlparsercover.sql, change the string: oracle.xml.parser.plsql.XMLParserCover.parseDTD to oracle.xml.parser.plsql.XMLParserCover.parseDTDClob

  3. Verify that Line 18 now reads: procedure parseDTDClob(id varchar2, dtd CLOB, root varchar2, err in out varchar2) is language java name 'oracle.xml.parser.plsql.XMLParserCover.parseDTDClob(java.lang.String, oracle.sql.CLOB, java.lang.String, java.lang.String[])';

  4. Save the file

  5. Rerun xmlparsercover.sql in SQL*Plus Assuming you've loaded XMLParserV2 release 2.0.2.6 into the database, this should solve your problem.

XML Parser for PL/SQL

Question

I have just started using XML Parser for PL/SQL. I am have trouble getting the text between the begin tag and the end tag into a local variable. Do you have examples?

Answer

You just have to use the following:

selectSingleNode("pattern");
getNodeValue()

Remember, if you are trying to get value from a Element node, you have to move down to the #text child node, for example, getFirstChild.getNodeValue()

Suppose you need to get the text contained between the starting and ending tags of a xmldom.DOMNode n. The following 2 lines will suffice.

n_child:=xmldom.getFirstChild(n); 
text_value:=xmldom.getNodeValue(n_child));

n_child is of type xmldom.DOMNode

text_value is of type varchar2

Security: ORA-29532, Granting JavaSysPriv to User

Question

We are using the XML Parser for PLSQL and are trying to parse an XML document. We are getting a Java security error:

ORA-29532: Java call terminated by uncaught Java exception: 
java.lang.SecurityException ORA-06512: at "NSEC.XMLPARSERCOVER", line 0 
ORA-06512: at "NSEC.XMLPARSER", line 79 ORA-06512: at "NSEC.TEST1_XML line 36 
ORA-06512: at line 5

Do we need to grant to user? The syntax appears correct. We also get the error when we run the demo.

Answer

If the document you are parsing contains a <!DOCTYPE which has a System URI with a protocol like file:/// or http:/// then you to grant an appropriate privilege to your current database user to be able to "reach out of the database", so to speak, and open a stream on the file or URL.CONNECT SYSTEM/MANAGER

GRANT JAVAUSERPRIV, JAVASYSPRIV TO  youruser;

should do it.

Installing XML Parser for PL/SQL: JServer(JVM) Option

Question

I have downloaded and installed the plxmlparser_V1_0_1.tar.gz. The readme said to use loadjava to upload xmlparserv2.jar and plsql.jar in order. I tried to load xmlparserv2.jar using the following command:

loadjava -user test/test -r -v xmlparserv2.jar

to upload the jar file into Oracle8i. After much of the uploading, I got the following error messages:

identical: oracle/xml/parser/v2/XMLConstants is unchanged from previously loaded 
fileidentical: org/xml/sax/Locator is unchanged from previously loaded 
fileloading  : META-INF/MANIFEST.MFcreating : META-INF/MANIFEST.MFError while 
creating resource META-INF/MANIFEST.MF    ORA-29547: Java system class not 
available: oracle/aurora/rdbms/Compilerloading  : 
oracle/xml/parser/v2/mesg/XMLErrorMesg_en_US.propertiescreating : 
oracle/xml/parser/v2/mesg/XMLErrorMesg_en_US.propertiesError while creating 
...

Then I removed -r from the previous command:

loadjava -user test/test -v xmlparserv2.jar

I still got errors but it's down to four:

.identical: org/xml/sax/Locator is unchanged from previously loaded fileloading  
: META-INF/MANIFEST.MFcreating : META-INF/MANIFEST.MFError while creating 
...

I think I have installed the JServer on the database, correctly.

Answer

The JServer option is not properly installed if you're getting errors like this during loadjava.You need to run INITJVM.SQL and INITDBJ.SQL to get the JavaVM properly installed. Usually these are in the ./javavm subdirectory of your Oracle Home.

XML Parser for PL/SQL: domsample

Question

I am trying to execute domsample on dom1151. This is an example that is provided with installation. XML file family.xml is present in the directory /hrwork/log/pqpd115CM/out.

Still I am getting the following error.

Usage of domsample is domsample(dir, inpfile, errfile)

     SQL>
     begin
     domsample('/hrwork/log/pqpd115CM/out','family.xml','errors.txt');
       end;
       /
     Error generated :
     begin
     *
     ERROR at line 1:
     ORA-20100: Error occurred while parsing: No such file or directory
     ORA-06512: at "APPS.XMLPARSER", line 22
     ORA-06512: at "APPS.XMLPARSER", line 69
     ORA-06512: at "APPS.DOMSAMPLE", line 80
     ORA-06512: at line 2

Answer

From your description it sounds like you have not completed all of the steps in the sample/Readme without errors. After confirming the xmlparserv2.jar is loaded, carefully complete the steps again.

XML in CLOBs

Question

In Oracle8i database, we have CLOBs which contain well formed XML documents up to 1 MB in size.

We want the ability to extract only part of the CLOB (XML document), modify it, and replace it back in the database rather than processing the entire document.

Second, we want this process to run entirely on the database tier.

Which products or tools are needed for this? This may be possible with the JVM which comes with Oracle8i There also may be some PL/SQL tools available to achieve this by means of stored procedures.

Answer

You can do this by using either of the following:

XML Parser for PLSQL has methods like:

As well as methods like:

If you wanted to do surgical updates on the text of the CLOB, you would have to use DBMS_LOB.* routines, but this would be tricky unless the changes being made to the content don't involve any growth or shrinkage of the number of characters.

Out of memory errors in oracle.xml.parser

Question

Out of memory errors in oracle.xml.parser

 last entry at 2000-04-26 10:59:27.042:
 VisiBroker for Java runtime caught exception:
 java.lang.OutOfMemoryError
    at oracle.xml.parser.v2.XMLAttrList.put(XMLAttrList.java:251)
    at oracle.xml.parser.v2.XMLElement.setAttribute(XMLElement.java:260)
    at oracle.xml.parser.v2.XMLElement.setAttribute(XMLElement.java:228)
    at cars.XMLServer.processEXL(XMLServer.java:122)

It's trying to create a new XML attribute and crashes with OutOfMemoryError.

We are parsing a 50Mb XML file. We have upped the java_pool_size to 150Mb with a shared_pool_size of 200Mb.

Answer

You should not be using the DOMParser for parsing a 50Mb XML file. You need to look at the SAXParser which parses files of arbitrary size because it does not create an in-memory tree of nodes as it goes.

Which parser are you using, SAX or DOM - if you are using DOM, you should seriously consider moving to SAX which processes the XML file sequentially instead of trying to build an in-memory tree that represents the file.

Using SAX we process XML files in excess of 180Mb without any problems and with very low memory requirements.

Rule of thumb for DOM and SAX:

DOM:

SAX:

Is There a PL/SQL Parser Based on C?

Question

Is there a PL/SQL parser that is based on C?

Answer

There is not one currently but there are plans to provide the PL/SQL parser on top of the C version.

Memory Requirements When Using the Parser for PL/SQL

Question

What are the memory requirements for using the PL/SQL Parser?

Answer

While the memory use is directly dependent on the document size, it should also be realized that the PL/SQL parser uses the Java parser and thus the Oracle JServer is being run. JServer typically requires 40-60MB depending on its configuration.

JServer (JVM) , Is It Needed to Run XML Parser for PL/SQL?

Question

Do I need to install JServer to run the XML Parser for PL/SQL?

Answer

Yes, if you are running the parser in the database, you do need JServer because the PL/SQL Parser currently uses the XML Parser for Java under the covers. JServer exists in both the Standard and Enterprise versions. A forthcoming version of XML Parser for PL/SQL using C underneath is being developed for applications that do not have access to a Java Virtual Machine (JVM).

Using the DOM API

Question - What does the XML Parser for PL/SQL do?

Answer

The XML parser accepts any XML document giving you a tree-based API (DOM) to access or modify the document's elements and attributes. It also supports XSLT which allows transformation from one XML document to another.

Question - Is it possible to dynamically set the encoding in the XML document?

Answer

No, you need to include the proper encoding declaration in your document as per the specification. You cannot use setCharset(DOMDocument) to set the encoding for the input of your document. SetCharset(DOMDocument) is used with oracle.xml.parser.v2.XMLDocument to set the correct encoding for the printing.

Question - How do I get the number of elements in a particular tag using the parser?

Answer

You can use the getElementByTagName (elem DOMElement, name IN VARCHAR2) method that returns a DOMNodeList of all descent elements with a given tag name. You can then find out the number of elements in that DOMNodeList to determine the number of the elements in the particular tag.

Question - How do I parse a string?

A: We do not currently have any method that can directly parse an XML document contained within a String. You can use

Question - How do I display my XML document?

Answer

If you are using IE5 as your browser you can display the XML document directly. Otherwise, you can use our XSLT processor in v2 of the parser to create the HTML document using an XSL Stylesheet. Our Java Transviewer bean also allows you to view your XML document.

Question - How do I write the XML data back using a special character sets?

Answer

You can specified the character sets for writing to a file or a buffer. Writing to a CLOB will be using the default character set for the database that you are writing to. Here are the methods to use:

Question - How do I to get ampersand from characterData?

Answer

You cannot have "raw" ampersands in XML data. You need to use the entity, &amp; instead. This is defined in the XML standard.

Question - How do I generate a document object from a file?

Answer

Check out the following example:

inpPath VARCHAR2;
inpFile VARCHAR2;
p xmlparser.parser;
doc xmldom.DOMDocument;

-- initialize a new  parser object;
p := xmlparser.newParser;
-- parse the file
xmlparser.parse(p, inpPath || inpFile);
-- generate a document object
doc := xmlparser.getDocument(p);

Question - Can the parser run on Linux?

Answer

As long as a 1.1.x or 1.2.x JavaVM for Linux exists in your installation, you can run the Oracle XML Parser for Java there. Otherwise, you can use the C or C++ XML Parser for Linux.

Question - How do I perform a >,<,>=, or <= comparison using the XML Parser v2?

Answer

You need to use the entities &lt; for < and &gt; for >.

Question -Is support for Namespaces and Schema included?

Answer

The current XML parsers support Namespaces. Schema support will be included in a future release.

Question -My parser doesn't find the DTD file.

Answer

The DTD file defined in the <!DOCTYPE> declaration must be relative to the location of the input XML document. Otherwise, you'll need to use the setBaseDir(Parser, VARCHAR2) functions to set the base URL to resolve the relative address of the DTD.

Question - Can I validate an XML file using an external DTD?

Answer

You need to include a reference to the applicable DTD in your XML document. Without it there is no way that the parser knows what to validate against. Including the reference is the XML standard way of specifying an external DTD. Otherwise you need to embed the DTD in your XML Document.

Question - Do you have DTD caching?

Answer

Yes, DTD caching is optional and it is not enabled automatically.

Question - How do I get the DOCTYPE tag into the XMLDocument after its parsed?

Answer

You need to do some preprocessing to the file, and then put it through the DOMParser again, which will produce a valid, well-formed XMLDocument with the DOCTYPE tag contained within.

Question - How does the XML DOM parser work?

Answer

The parser accepts an XML formatted document and constructs in memory a DOM tree based on its structure. It will then check whether the document is well-formed and optionally whether it complies with a DTD. It also provides methods to traverse the tree and return data from it.

Question - How do I create a node whose value I can set later?

Answer

If you check the DOM spec referring to the table discussing the node type, you will find that if you are creating an element node, its nodeValue is to be null and hence cannot be set. However, you can create a text node and append it to the element node. You can store the value in the text node.

Question - How do I extract elements from the XML file?

Answer

If you're using DOM, the you can use the NamedNodeMap methods to get the elements.

Question - How do I append a text node to a DOMElement using PL/SQL parser?

Answer

Use the createTextNode() method to create a new text node. Then convert the DOMElement to a DOMNode using makeNode(). Now, you can use appendChild() to append the text node to the DOMElement.

Question - I am using XML parser with DOM but I cannot get the actual data. What is wrong?

Answer

You need to check at which level your data resides. For example,

The text is the first child node of the first DOM element in the document. According to the DOM Level 1 spec, the "value" of an ELEMENT node is null and the getNodeValue() method will always return null for an ELEMENT type node. You have to get the TEXT children of an element and then use the getNodeValue() method to retrieve the actual text from the nodes.

Question - Can the XML Parser for PL/SQL handle stylesheets that produce non-XML documents such as HTML?

Answer

Yes it can.

Using the Sample

Question - I cannot run the sample file. Did I do something wrong in the installation?

Answer

Here are two frequently missing steps in installing the PL/SQL parser:

XML Parser for PL/SQL: Parsing DTD in a CLOB

Question

I am having problems parsing a DTD file contained in a CLOB. I used the API, "xmlparser.parseDTDClob", provided by the XML Parser for PL/SQL.

The following error was thrown:

"ORA-29531: no method parseDTD in class oracle/xml/parser/plsql/XMLParserCover"

I managed to work out the following:

The procedure xmlparser.parseDTDClob calls a Java Stored Procedure xmlparsercover.parseDTDClob, which in turn calls another Java Stored Procedure xmlparsercover.parseDTD.

I have confirmed that the class file -"oracle.xml.parser.plsql.XMLParserCover" has been loaded into the database, and that it has been published. So the error message does not make sense.

I am not able to figure out whether I am doing it right or whether this is a bug in the parser API.

The procedure use to call "xmlparser.parseDTDClob" :
----------------------------------------------------
create or replace procedure parse_my_dtd as
p xmlparser.parser;
l_clob clob;
begin
  p := xmlparser.newParser;
  select content into l_clob from dca_documents where doc_id = 1;
  xmlparser.parseDTDClob(p,l_clob,'site_template');
end;

API Documentation for xmlparser.parseDTDClob:

parseDTDClob
PURPOSE
  Parses the DTD stored in the given clob
SYNTAX
  PROCEDURE parseDTDClob(p Parser, dtd CLOB, root VARCHAR2);
PARAMETERS
  p        (IN)-  parser instance
 dtd      (IN)-  dtd clob to parse
 root     (IN)-  name of the root element
RETURNS
  Nothing
COMMENTS

Any changes to the default parser behavior should be effected before calling this procedure. An application error is raised if parsing failed, for some reason.

Description of the table dca_documents:

 DOC_ID         NOT NULL   NUMBER
 DOC_NAME       NOT NULL   VARCHAR2(350)
 DOC_TYPE                  VARCHAR2(30)
 DESCRIPTION               VARCHAR2(4000)
 MIME_TYPE                 VARCHAR2(48)
 CONTENT        NOT NULL   CLOB
 CREATED_BY     NOT NULL   VARCHAR2(30)
 CREATED_ON     NOT NULL   DATE
 UPDATED_BY     NOT NULL   VARCHAR2(30)
 UPDATED_ON     NOT NULL   DATE

The contents of the dtd:

<!ELEMENT site_template (component*)>
<!ATTLIST site_template template_id CDATA #REQUIRED>
<!ATTLIST site_template template_name CDATA #REQUIRED>
<!ELEMENT component (#PCDATA)>
<!ATTLIST component component_id ID #REQUIRED>
<!ATTLIST component parent_id ID #REQUIRED>
<!ATTLIST component component_name ID #REQUIRED>

Answer (a)

It appears to be a typo in the "xmlparsercover.sql" script which is defining the Java Stored Procedures that wrap the XMLParser. It mentions the Java method name "parseDTD" in the 'is language java name' part when "parseDTD" should be "parseDTDClob" (case-sensitive).

If you:

  1. Make a backup copy of this script

  2. Edit the line that reads:

    procedure parseDTDClob(id varchar2,
    dtd CLOB, root varchar2, err in out varchar2) is language java name
    'oracle.xml.parser.plsql.XMLParserCover.parseDTD (java.lang.String, 
    oracle.sql.CLOB, java.lang.String, java.lang.String[])';
    

    to say:

    procedure parseDTDClob(id varchar2, 
    dtd CLOB, root varchar2, err in out varchar2) is language java name
    'oracle.xml.parser.plsql.XMLParserCover.parseDTDClob
    (java.lang.String, oracle.sql.CLOB, java.lang.String, 
    java.lang.String[])';
    

    that is, change the string:

    'oracle.xml.parser.plsql.XMLParserCover.parseDTD
    

    to

     'oracle.xml.parser.plsql.XMLParserCover.parseDTDClob
    

    and rerun the xmlparsercover.sql script you should be in business.

I filed a bug 1147031 to get this typo corrected in a future release.

Note: Your DTD had syntactic errors in it, but I was able to run the following without problem after making the change above:

declare
   c clob;
   v varchar2(400) :=
'<!ELEMENT site_template  (component* )>
<!ATTLIST site_template  template_name CDATA  #IMPLIED
                         tempmlate_id  CDATA  #IMPLIED >
<!ELEMENT component  (#PCDATA )>
<!ATTLIST component  component_id   ID     #REQUIRED
                     parent_id      IDREF  #IMPLIED
                     component_name CDATA  #IMPLIED >';
begin
   delete from dca_documents;
   insert into dca_documents values(1,empty_clob())
    returning content into c;
   dbms_lob.writeappend(c,length(v),v);
   commit;
   parse_my_dtd;
end;

Answer (b)

What do u want to do with the LOB. The LOB can either be a temporary LOB or a persistant lob. In case of persistant lobs, u need to insert the value into a table. In case of temp lob u can instantiate it in ur program.

For example:

   persistant lob
   declare
     clob_var CLOB;
   begin
     insert into tab_xxx values(EMPTY_CLOB()) RETURNING clob_col INTO
clob_var;
      dbms_lob.write(,,,,);
    // send to AQ
   end;
   temp lob -----

    declare
      a clob;
    begin
       dbms_lob.createtemporary(a,DBMS_LOB.SESSION);
       dbms_lob.write(...);
      // send to AQ

   end;
   /

Also refer to Oracle8i Application Developer's Guide - Large Objects (LOBs). There are 6 books one for each language access (C(OCI), Java,PL/SQL, Visual Basic, Pro*C/C++, Pro*Cobol)) and it is quite comprehensive. If this is PL/SQL, I believe you can just do the following:

myClob CLOB = clob();

I have tried the DBMS_LOB.createtemporary() which works.

Answer (c)

Here's what you need to do if you are using LOBs with AQ:

  1. Create an ADT with one of the fields of type CLOB.

    create type myAdt (id NUMBER, cdata CLOB);
    
    

    The queue table must be declared to be of type myAdt

  2. Instantiate the object - use empty_clob() to fill the LOB field

    myMessage := myAdt(10, EMPTY_CLOB();
    
  3. Enqueue the message

    clob_loc clob;
    enq_msgid RAW(16);
    DBMS_AQ.enqueue('queue1', enq_opt, msg_prop, myMessage, enq_msgid)
    
    
  4. Get the LOB locator

    select t.user_data.cdata into clob_loc
    from qtable t  where t.msgid
    = enq_msgid;
    
  5. Populate the CLOB using dbms_lob.write

  6. Commit

There is an example of this is in the Oracle8i Application Developer's Guide - Advanced Queuing. If you are using the Java API for AQ, the procedure is slightly more complicated.

Errors When Parsing a Document

I downloaded the javaparser v2 and the xml parser utility and I'm using the PLSQL parser interface. I have an XML file that is a composite of three tags and when parsing it generates the following error:

ORA-20100: Error occurred while parsing: Unterminated string

When I separate the document into individual tags 2 are ok the third generates this error:

ORA-20100: Error occurred while parsing: Invalid UTF8 encoding

  1. Why is the error different when separating the data?

  2. I have not been able to find an "unterminated string" in the document.

  3. I'm fairly anxious since this is the only way the data is coming and I don't have time to figure out another parser.

Answer

If you document is the "composite of three tags" then it is not a well-formed document as it has more than one root element. Try putting a start and end tag around the three.

PLXML: Parsing a Given URL?

Question

I'am working with the XML parser for PL/SQL on NT.According to your Parser API documentation it is possibleto parse a given url, too:> Parses xml stored in the given url/file and returns> the built DOM DocumentNow, parsing from file works fine, but any form of urlraises ORA-29532: ... java.io.FileNotFoundException

Can you help me ? Can you give an example of a call ?Are there prerequisites i have to think of ?

Answer

To access external URLs, you need set up your proxy host and port. For example using this type of syntax:

java -Dhttp.proxyHost=myproxy.mydomain.com -Dhttp.proxyPort=3182DOMSample 
myxml.xml

Using XML Parser to Parse HTML?

Question

We need to parse HTML files as follows:

  1. Find each "a href"

  2. For each a href found, extract the file/pathname being linked to

  3. Substitute a database procedure call for the a href, passing the file/pathname as a parameter.

Does it make sense to use the PL/SQL XML parser to do this? If so, how easy/hard would it be, and how can we find out how to do this?

Answer

Since HTML files aren't necessary well formed XML documents, are you sure you want to use XML parser? Won't PERL be a better choice?I'm not sure whether PL/SQL parser supports the following methods but just for your information:

  1. getElementsByTagName() retrieves all matching nodes.

  2. getNodeValue() will return a string.

  3. setNodeValue() sets node values.

Answer b

It supports those methods, but not over an ill-formed HTML file.

Oracle 7.3.4: Moving Data to a Web Browser (PL/SQL)

Question

I'm trying to get the data to a web browser in the client side while all the processing has to take place on the server (oracle 7.3.4), using:

Are these two components sufficient to get the job done?

Answer

Dependencies for XSQL Page Processor states:

You'll also need XSQL Page Processor itself.

Oracle 7.3.4 and XML

Question

Does the XML Parser for Java,V2, work with Oracle 7.3.4.?

Is XML- SQL Utility part of XML Parser for Java,V2, or does it need to be downloaded separately.

Answer

  1. The XML Parser for Java, V2 works with 7.3.4 as long as you have the proper JDBC driver and run it in a VM on a middle tier or client.

  2. The XML-SQL Utility includes a copy of the v2 parser in its download, as it requires it.

getNodeValue(): Getting the Value of DomNode

Question

I am having problems obtaining the value between XML tags after using xmlparser(). Below is code from the DOMSAMPLE.SQL example:

-- loop through elementsfor i in 0..len-1 loop   n := xmlparser.item(nl, i);
   dbms_output.put(xmlparser.getNodeName(n)

Comment

I encountered the same problem. I found out that getNodeValue() on Element Node returns null. getNodeValue() on the text node returns the value.

Retrieving all Children or Grandchilden of a Node

Question

Is there a way to retrieve all childrenor grandchildren, and so on, of a particular node in a DOM tree using the DOM API? Or is there a work-around? We are using the XML Parser for PL/SQL.

Answer

Try the following:

DECLARE  nodeList   xmldom.DOMNodeList;  
theElement xmldom.DOMElement;
BEGIN    :nodeList := xmldom.getElementsByTagName( theElement,'*');
:END;

This gets all children nodes rootedas the element in "theElement".


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Service

Contents

Index