Specify encoding in PL/SQL XMLDOM

Hi,
I am Using Oracle 8.1.7 and trying to construct XML using xmldom object in a PL/SQL block. The XMl is generated fine but the header is
<?xml version = '1.0' encoding = 'ASCII'?>
Can anyone tell me how to change 'ASCII' to 'utf-8'. Is there any methods available for specifying encoding type??
1. xmldom.setcharset() does not have any impact on the output
2. xmldom.writeToFile(doc,'/tmp/op.xml','UTF-8'); removes the entire header.
Code:
DECLARE
doc xmldom.DOMDocument;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
root_elmt xmldom.DOMElement;
BEGIN
doc := xmldom.newDOMDocument;
main_node := xmldom.makeNode(doc);
root_elmt := xmldom.createElement(doc, 'EMP');
root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
xmldom.setCharset(doc,'UTF-8');
xmldom.writeToFile(doc,'/tmp/op.xml');
xmldom.freeDocument(doc);
END;
Output:
<?xml version = '1.0' encoding = 'ASCII'?>
<EMP/>
Any help/suggestions would be highly appreciated.
Thanks and Regards,
Prakash

hi,
Here in this code instead of xmldom.setCharset(doc,'UTF-8') use xmldom.setversion(doc,'1.0') which actually sets the character set as 'UTF-8'.Try this it might work.
DECLARE
doc xmldom.DOMDocument;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
root_elmt xmldom.DOMElement;
BEGIN
doc := xmldom.newDOMDocument;
main_node := xmldom.makeNode(doc);
root_elmt := xmldom.createElement(doc, 'EMP');
root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
xmldom.setversion(doc,'1.0');
xmldom.writeToFile(doc,'/tmp/op.xml');
xmldom.freeDocument(doc);
END;

Similar Messages

  • Convert PL?SQL xmldom.DOMDocument to Java XMLDocument

    My program generates a PL/SQL CLOB containing XML. I can parse this on the server and create a PL/SQL xmldom.DOMDocument. However, I would like to be able to pass this back to a Java class via JDBC. I can do this with the CLOB, but I can't figure out how to define the return-type for the PL/SQL XML document to read it back into a Java XMLDocument.
    Any ideas?
    Thanks,
    Chris

    Did you ever find out how to do this? I am faced with the same
    problem. Any help would be greatly appreciated.
    Cheers,
    Tom

  • Viewing Chinese Characters / Encoding setting in SQL Developer

    Hi all,
    I am new to SQL Developer 1.1. I have just downloaded the tool yesterday.
    I have a table where there "should" be chinese characters in a NVARCHAR2 column. But I see only inverted question marks when displaying that data in SQL Developer.
    I know from a ressource on the web, that SQL Developer is able to display chinese characters ( see http://awads.net/wp/2006/07/06/sql-developer-and-utf8/ ).
    The NLS_NCHAR_CHARACTERSET is set to AL16UTF16; the NLS_CHARACTER_SET is set to WE8ISO8859P1.
    The encoding under Tools->Preferences->Environment is set to "Cp1252".
    What is actually the influence of this Encoding setting and do I have to make changes to that to view the data?
    In addition I have to admit, that we actually do not really know if the data entered the DB correctly, that is as chinese characters. Maybe there have occured conversion errors that were made in a application that writes the data into the database. Actually I want to verify that. So, if I have the right settings configured which should be fine to see chinese characters and then I see only inverted question marks I can conclude that the data actually entered the database corrupted and the error is not an display issue with SQL Developer but rather an error in the application that writes the data to the database.
    Thanks to any answers in advance!
    Regards,
    Philipp Hinnah

    Hi,
    Am able to view chinese characters in VARCHAR2, FUNCTIONS & PROCEDURES.
    My Settings are :
    1. Developer encoding is X-ORACLE-AL32UTF8.
    2. Control Panel :
       Regional& Language Options:
                Standard & Format = English (US)
                Location                 = US
                Under Advanced = China (PRC)
            System :
                Environmental Varaibles
                  Variable Name  = NLS_LANG
                  Variable Value = SIMPLIFIED CHINESE_CHINA.ZHS16GBK 3. Windows Registry for oracle's NLS_LANG all using
    SIMPLIFIED CHINESE_CHINA.ZHS16GBK.
    4. Oracle database when creating using SIMPLIFIED CHINESE_CHINA.ZHS16GBK
    and AL32UTF8.
    HTH
    Zack

  • How to specify encoding=gb2312 when using weblogc.jspc?

    Hi,
              I have tried to compile jsp pages using weblogic.jspc, but found out
              that I can not get the same result as compiling on the fly.
              When compiling on the fly, I can find these in the generated java source:
              out = pageContext.getOut();
              ((weblogic.servlet.jsp.JspWriterImpl)out).setEncoding("gb2312");
              response.setHeader("Content-Type", "text/html; charset=gb2312");
              HttpSession session = request.getSession(true);
              But when compiling with weblogic.jspc, I can only find these:
              out = pageContext.getOut();
              HttpSession session = request.getSession(true);
              In my weblogic.properties file, I have this:
              weblogic.httpd.initArgs.*.jsp=\
              pageCheckSeconds=2,\
              compileCommand=c:/jdk1.3/bin/javac.exe,\
              workingDir=c:/Develop/weblogic/myserver/classfiles,\
              keepgenerated=true,\
              encoding=gb2312,\
              verbose=true
              And the command line to compile manually is:
              java weblogic.jspc -verbose -verboseJavac -compiler
              c:\jdk1.3\bin\javac.exe -d ../classfiles -keepgenerated -encoding "gb2312"
              MY_JSP_NAME.jsp
              That seems to be caused by that weblogic.jspc can not get encoding parameter
              correctly,
              can anybody tell me why?
              

    term is not a http address, but a directory address. So, you have to specify the path on the server:
    term=c:\oracle\forms90\.....

  • Get canvas.toDataURL('image/jpeg') and convert base64 encoding to java.sql.Blob

    Convert canvas.toDataURL('image/jpeg') to java.sql.Blob.
    I am using oracle adf so I am able to action a backing bean from javascript and pass in parameters as a map. I pass in the canvas.toDataURL('image/jpeg') which I then try to decode in my bean. Using BASE64Decoder and the converting the bytearray to a file I can see the image is corrupted as I can't open the file thus converting the bytearray to blob is also a waste.
    Has anyone any ideas on base64 encoding from canvas.toDataURL to file or Blob?

    Use Case:
    A jsf page that enables a user to take photos using the HTML5 canvas feature - interact with webcam -, take photos and upload to profile
    1. I have created the jsf page with the javascript below; this pops up as a dialog and works okay and onclick an upload image, triggers the snapImage javascript function below and sends the imgURL parameter to the serverside managedbean
    <!-- java script-->
    function snapImage(event){
                    var canvas = AdfPage.PAGE.findComponent('canvas');
                    AdfCustomEvent.queue(event.getSource(),"getCamImage",{imgURL:canvas.toDataURL('image/jpeg'),true);
                    event.cancel();
    <!-- bean -->
    public void getCamImage(ClientEvent ce){
    String url=(String)ce.getAttributes().get("imgURL");
    decodeBase64URLToBlob(url);
    private BlobDomain decodeBaseB4URLToBlob(String url64){
                    BASE64Decoder de=new BASE64Decoder();
                    byte[] bytes=de.decode(url64);
                    File file=new File("abc.jpg");
                    InputStream in = new ByteArrayInputStream(bytes);
                    BufferedImage bImageFromConvert = ImageIO.read(in);
                    in.close();
                    ImageIO.write(bImageFromConvert, "jpg", file);
                    return createBlobDomainFromFile(file);
    ----problem---
    Accessing the generated jpeg file shows the image is corrupted, probably missing bytes or encode/decoder issues.and the blob image after uploading to database is saved as a binary stream which ondownload doesnt render as an image or anything i know of.
    Is there anyways of achieving the conversion without errors?

  • Encoding problem in sql developer

    I have problems with encoding when use timesten database with DatabaseCharacterSet=AL32UTF8. If I use DatabaseCharacterSet=US7ASCII all ok.
    I don't have this problem if connect to timesten using ttisql.
    Server - TimesTen Release 11.2.1.4.0 (64 bit Linux/x86_64) (tt1121:53388) 2009-11-19T19:20:36Z
    Client - TimesTen Release 11.2.1.4.0 (64 bit Linux/x86_64) (tt1121:53388) 2009-11-19T19:20:36Z on Windows XP
    SqlDeveloper - Oracle SQL Developer 2.1.0.63 Build MAIN-63.73
    !http://digilo.com/images/work/sqldeveloper_ecncoding.PNG!

    I can't reproduce this going from SQL Developer on XP with TT 11.2.1.4 32bit installed, to TT 11.2.1.4 32bit on Linux x8664. Can you paste in your DSN settings on the server side and also check the ConnectionCharacterSet setting in the Oracle TimesTen Client DSN Setup (accessed via ODBC Data Source Administrator). Mine is blank. AFAIK SQL Developer should just use AL32UTF8 only as its ConnectionCharacterSet for TT.

  • Possible encoding problem in sql queries

    I am using mac os. I've set everything possible (files, eclipse workspace, database collation, mysql charst) to utf-8 encoding. Still when i send a query, smthing like
    SELECT * FROM suppliers WHERE LOWER(name_post)='&#1072;&#1082;&#1094;&#1077;&#1085;&#1090;'
    using java, empty resultset is returned (it should be nonempty). My only guess is that cyrillic part of the query is not correctly encoded. I used to have lots of those queries under windows w/o any problem. Is there any way to figure out what is going wrong? (If I select the whole table and then verify the constraint within a java loop it works fine)

    If you use a Statement, and concatenate your parameters in like:
    String query = "select * from my_table where some_id = " + anId;Oracle will create an execution plan for each id that passes through this bit of code. This execution plan gets stored in the shared pool. The more of these that happens, the fuller the pool gets. Oracle will age out older plans, but this can result in pool fragmentation if there's a lot of "churn" in the pool, which there will be if your queries look like the above.
    Eventually you'll hit an ORA-4031, as it can't find a suitable chunk of pool to allocate to a query. Some people see that as "I've run out of pool" and so try to "fix" it by expanding the shared pool size. All this tends to do is delay the inevitable.
    What a 4031 actually means is "you're not using bind variables", since binding would result in a single plan being held for the above SQL, since it would actually be stored as "select * from my_table where some_id = ?". Thus no flooding of the shared pool.
    So, PreparedStatements aren't just about security, but also about good resource management.
    Hopefully that makes sense?

  • Character encoding issue in sql server

    Hi Team,
    We have a table with more than 20 columns...In that we have some columns which will have data extracted from the Datawareshouse applicances and its one time load.
    The problem is we have two columns which will may have same set of values from some records and for different set of records
    the below values are the example for same set of records but the values are changed while importing into the sql server database..
    2pk Etiquetas Navide‰as 3000-HG                                
     2pk Etiquetas Navideñas 3000-H                           
    Is there anyway to change the first column values into the second column value ? 
    By looking at the data we can say its the code page issue..(Character encoding issue)..but how to convert it?
    Convertting(2pk Etiquetas Navide‰as 3000-HG)  
    to get   2pk Etiquetas Navideñas 3000-H   in the select query?

    Then it seems that you can do the obvious: replace it.
    DECLARE @Sample TABLE ( Payload NVARCHAR(255) );
    INSERT INTO @Sample
    VALUES ( N'2pk Etiquetas Navide‰as 3000-HG' );
    UPDATE @Sample
    SET Payload = REPLACE(Payload, N'‰', N'ñ');
    SELECT S.Payload
    FROM @Sample S;

  • Specify different location of SQL*PLUS EDIT/SPOOL directory

    Where can I specify the location of the SQL*PLUS edit/spool directory such that I can change it from the default? I'm running on Linux (Ubuntu 6.10) if that helps...

    Check this Link :
    Error while Invoking Editor
    Regds.

  • Any way to encode/decode PL/SQL record types ?

    Hello everyone,
    I came to XDK because I was looking for an easy way or working around a JDBC driver limitation. Namely that it does not access PL/SQL record types. I thought the best way was to encode my package's public types into XML streams and wrap up each public routine into a set of routines receiving and exporting data in XML.
    I installed XDK 9i/PL/SQL yesterday and tried it on my 8.1.6 db. So far so good.
    However, I did not see anything that does not access directly the database. The only preocupation of XSU is to access directly the DB for a variety of select, insert...
    Am I wrong ?
    I'm looking for a routine that takes an XML varchar, a DTD varchar and some description of my type (to map tags to fields) and parses the whole thing...
    Is there anything I could use to do that ???
    Thanks in advance...
    Alain

    Marwim wrote:
    You code should be instrumented. Whenever you need to debug/trace you switch it on and get a log fileor log table; it maybe a database parameter or simply a package variable, which you can set at runtime.
    This will allow you to debug a production environment where you should never be allowed to change the code or to use adebugger.And very valuable advice this is...
    Debugging needs to be part and parcel of a code unit (like a PL/SQL package), where you can execute it (in production or anywhere else) and tell it "+go forth, execute, and debug thyself+".

  • Update passed in XML doc with pl/sql xmldom

    Hi,
    I have an xml document that is passed in through a stored procedure as CLOB. I'm trying to use the XMLParser and XMLDOM to add an additional node
    The XML looks something like the following
    <rowset>
    <row>
    <firstname>john</firstname>
    </row>
    <row>
    <firstname>jane</firstname>
    </row>
    </rowset>
    I need to loop through each of <mynames> nodes and then add another node <lastame> so it looks like the following
    <rowset>
    <row>
    <firstname>john</firstname>
    <lastame>smith</lastame>
    </row>
    <row>
    <firstname>jane</firstname>
    <lastame>smith</lastame>
    </row>
    </rowset>
    I have the following code
    parseClob XMLPARSER.Parser;
    newNames XMLDOM.DOMDocument;
    tempNode XMLDOM.DOMNode;
    mye xmldom.domelement;
         item_text xmldom.DOMText;
    numofrows number;
         nodeList xmldom.DOMNodeList;
         newnode xmldom.domnode;
    parseClob := xmlparser.newParser;
    XMLPARSER.parseClob(parseClob,names);
    newNames := XMLPARSER.getDocument(parseClob);
    XMLPARSER.freeParser(parseClob);
    nodeList := xslprocessor.selectNodes(xmldom.makeNode(newNames), '//rowset/row');
    numOfRows := xmldom.getlength(nodeList)-1;
    for i in 0..numOfRows LOOP
    newnode := xmldom.item(nodeList, i);
              --create the new node
    mye := xmldom.createElement(newName, 'lastname');
    --add it to the new node   
    tempNode := xmldom.appendChild(newnode, xmldom.makeNode(mye));
    --update the text in the lastname   
    item_text := xmldom.createTextNode(newNames, 'smith');
    tempNode := xmldom.appendChild(tempNode, xmldom.makeNode(item_text));
    end loop;
    what happens is that when i write out the newnode xml out to a buffer i see the <lastname> tag
    but when i write out the newNames xml out to a buffer after the loop is finished the <lastname> tag is
    missing. like it didn't update the newNames xml
    I've seen lots of example on how to create an XML document with the DOM from scratch but nothing about updating
    an passed in xml document. any help would be appreciated

    Updatexml is reference in Oracle 9i, I'm sorry i should have mentioned that I am using oracle 8i. Is there something you can use in oracle 8i?

  • How to send output from SQL script to the specified log file (not *.sql)

    ## 1 -I write sql command into sql file
    echo "SELECT * FROM DBA_USERS;">results.sql
    echo "quit;">>results.sql
    ##2- RUN sqlplus, run sql file and get output/results into jo.log file
    %ORACLE_HOME/bin/sqlplus / as sysdba<results.sql>>jo.log
    It doesn't work please advise

    $ echo "set pages 9999" >results.sql ### this is only to make the output more readable
    $ echo "SELECT * FROM DBA_USERS;" >>results.sql
    $ echo "quit" >>results.sql
    $ cat results.sql
    set pages 9999
    SELECT * FROM DBA_USERS;
    quit
    $ sqlplus -s "/ as sysdba" @results >jo.log
    $ cat jo.log
    USERNAME                          USER_ID PASSWORD
    ACCOUNT_STATUS                   LOCK_DATE  EXPIRY_DAT
    DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE           CREATED
    PROFILE                        INITIAL_RSRC_CONSUMER_GROUP
    EXTERNAL_NAME
    SYS                                     0 D4C5016086B2DC6A
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        SYS_GROUP
    SYSTEM                                  5 D4DF7931AB130E37
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        SYS_GROUP
    DBSNMP                                 19 E066D214D5421CCC
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUP
    SCOTT                                  60 F894844C34402B67
    OPEN
    USERS                          TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUP
    HR                                     47 4C6D73C3E8B0F0DA
    OPEN
    EXAMPLE                        TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUPThat's only a part of the file, it's too long :-)

  • Java Code  that can find all the specified functions in a sql statement

    If i pass a string like
    SELECT CONCAT(region_name,store_name) , length( region_name) , region_name || store_name, region_name, store_name FROM Geography
    WHERE store_name = 'Boston';
    Then my code should return
    CONCAT(region_name,store_name)
    length( region_name)
    region_name || store_name
    i.e all function related stuff. Is there any parser in java that can parse all the functions a sql or ny code that can d that. Any help is highly appreciated

    I suspect a regular expression may be able to handle this, or 'grep'. Why do you need to do it in Java?

  • How do we specify the username in sql

    Hi^^,
    while writing the conectivity statement we use this statement
    Connection con = DriverManager.getConnection("url","username","password");
    were we specify that:
    username="root";
    password="root"
    url="-----"
    My question is where in the system it is specified that the username ="root" and when do we specify it. we specify it while installing mysql or when...?
    Regards,
    Prashant

    as i understand your question:
    root username is the owner for the database ,root has all privilage to create/grant other accounts
    so whenever you install mysql there is root username and password as you specify it in the installation phase

  • Member acces profile error(A table name, specified in an sql command)

    Hi friends,
    In my bpc application(A) below 3 dims are secure dims.
    1. entiiy  (std)
    2. category (std)
    3. location (custom dim)
    while defining one member access profile,
    Read Only      : CATEGORY 100
    Read & Write      : CATEGORY 200,500
    for whatever combinatio i use, for other secure dims (eg: category,location where base member,or parent members ) i'm getting below error  message
    A table name, specified in an sql command, is unknown.
    We are on bpc75nw sp04.
    Pls suggest us .
    dump(st22):
    Short text
        A table name, specified in an SQL command, is unknown.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "CL_UJE_MEMACCESS_CACHE========CP" had to be
         terminated because it has
        come across a statement that unfortunately cannot be executed.
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
         not caught in
        procedure "REMOVE_MEMACCESS" "(METHOD)", nor was it propagated by a RAISING
         clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        An invalid table name "/1CPMB/RDWCSUMAS" was specified in an Open SQL command:
        Due to one of the following reasons, the error occurs only at runtime:
        - the table name was specified dynamically, or
        - the SELECT clause, WHERE clause, GROUP-BY clause, HAVING clause, or
          ORDER-BY clause was specified dynamically.
    Thanks,
    naresh
    Edited by: Naresh P on Feb 19, 2011 10:40 AM

    Hi Naresh,
    As far as I know You have specify Explicit Access to all the dimensions mentioned as Secured in your Application.
    You can't skip the secured Dimesions.
    In your case if you want to restrict only one dimension for 1 Member Access Profile then give Read & Write access to other 2 Dimensions and select ALL members.
    This might solve your problem.
    Hope it helps.
    Chaithanya

Maybe you are looking for