Extracting XML

I am having a problem of extracting the XML file from a table that is storing the file in the binary format. The problem I am having is that I am not able to extact the whole file through sqlplus.
Am I having problems with my settings in sqlplus?

What have you set 'long' to
By default SQL*PLUS only returns the first (4000?) characters. You can control this by using set long nnnnnn before executing your qurey.

Similar Messages

  • Re-Using XML file from decode barcode + extract xml process

    I was hoping someone could put me in the right direction here. I am decodeing the information stored in a 2D Bar code and sending this information to an XML file, then I am trying to combine that xml file with a blank PDF template but the process is failing beacuse there are some additional tag fields the XML data from the  Decode->Extract XML process.
    The XML file from the decode process gives the structure below..notice therer some extra tags (lines 2- 4)
    <?xml version="1.0" encoding="UTF-8"?>
    <xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
    <xfa:datasets>
    <xfa:data>
    <form1>
    The XML structure that is expected by the PDF template is as follows
    <?xml version="1.0" encoding="UTF-8"?>
    <form1>
    So the xml output of the Decode barcode + Extract XML process has three extra lines of tag. Is there a way I could use a process within liveCycle to clean out those three lines in real-time before sending the xml to be recombined with the PDF template.
    Thanks

    Hi,
    What you may do is to use the SetValue and its xpath builder functions to "serialize" the xml into string, "substring" to remove the extra tags, and "concat" to add the extra tags and then "deserialize" it again to an xml to be merged with your form.
    Greetings,
    Yasser

  • Extract XML from an XML File

    Hi All,
    I have an xml file from which data has to be extracted and inserted into table. XML file looks like this..
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE labels SYSTEM "label.dtd">
    <labels FORMAT="Harvest Label for Lot Project" QUANTITY="1" PRINTERNAME="PFP3400E006" JOBNAME="JA272017">
    <label>
    <variable name= "ITEM">PM191_JTEST</variable>
    <variable name= "ITEM_DESC">6 Pack Blue Assembled 2004 JTEST</variable>
    <variable name= " LOT ">ja28-10</variable>
    <variable name= "QUANTITY">1</variable>
    </label>
    </labels>
    In the above xml, if i remove <!DOCTYPE labels SYSTEM "label.dtd"> and use the below query, I am able to get the details.
    SELECT EXTRACTVALUE(VALUE(x), 'labels/@_FORMAT') format
    ,EXTRACTVALUE(VALUE(x), 'labels/@_QUANTITY') QUANTITY
    ,EXTRACTVALUE(VALUE(x), 'labels/@_PRINTERNAME') PRINTERNAME
    ,EXTRACTVALUE(VALUE(x), 'labels/@_JOBNAME') JOBNAME
    FROM (SELECT XMLTYPE
    ('<?xml version="1.0" encoding="UTF-8" standalone="no"?> <labels FORMAT="Harvest Label for Lot Project" QUANTITY="1" PRINTERNAME="PFP3400E006" JOBNAME="JA272017"> <label> <variable name= "ITEM">PM191_JTEST</variable> <variable name= "ITEM_DESC">6 Pack Blue Assembled 2004 JTEST</variable> <variable name= " LOT ">ja28-10</variable> <variable name= "QUANTITY">1</variable> </label> </labels>' ) xml
    FROM DUAL),
    TABLE(XMLSEQUENCE(EXTRACT(xml, 'labels'))) x
    But <!DOCTYPE labels SYSTEM "label.dtd"> tag is there means then i am getting error as
    Invalid resource handle or path name "/label.dtd"
    Please let me know how we can parse the xml and insert into table. OR how can i remove <!DOCTYPE labels SYSTEM "label.dtd"> tag and process it further.
    Thanks and Regards,
    Mahesh
    Edited by: magu on Sep 2, 2009 3:15 PM
    Edited by: magu on Sep 2, 2009 3:16 PM

    I don't understand why the DOCTYPE is in the XML, but it appears that Oracle is trying to resolve label.dtd to a registered resource. As you discovered, it may be easier to remove the DOCTYPE from the XML then try to register the label.dtd resource within Oracle. To do this, some options are
    - Use the REPLACE command
    - treat the data as a CLOB and instr/substr to build a new clob without the DOCTYPE tag in it.
    - Use the REGEXP_REPLACE command
    Also, if your DB version supports XMLTable, here is the way to do it with that.
    SELECT *
      FROM XMLTABLE('/labels'
                    PASSING XMLTYPE('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <labels _FORMAT="Harvest Label for Lot Project" _QUANTITY="1" _PRINTERNAME="PFP3400E006" _JOBNAME="JA272017">
         <label>
              <variable name="ITEM">PM191_JTEST</variable>
              <variable name="ITEM_DESC">6 Pack Blue Assembled 2004 JTEST</variable>
              <variable name=" LOT ">ja28-10</variable>
              <variable name="QUANTITY">1</variable>
         </label>
    </labels>
                    COLUMNS
                    format    VARCHAR2(15) PATH '@_FORMAT',
                    quantity  VARCHAR2(15) PATH '@_QUANTITY',
                    printername  VARCHAR2(15) PATH '@_PRINTERNAME',
                    jobname  VARCHAR2(15) PATH '@_JOBNAME');

  • Need help for extract XML fron PDF

    I am a newbee for javascript developer and i don know about Acrobat my requirement is Extract XML from PDF document there is any possiblities to do this from acrobat professional if is it possible please guide me to do this thank you

    i have a separate DTD for my own XML i want to extract my PDF files to that
    XML is it possible may i know how the acrobat export as xml feature works

  • Extracting XML Data to a flat file

    I have an application which is puting an XML string into a field in the database... now my problem is that I have to extract that information and put it in either 1. a flat file, or 2. a seperate table containing a column for each XML attribute... Does anyone know of the best way to approach either solution?
    cheers.

    And your Oracle version is?
    There are many different ways to put something into a file. How about UTL_FILE?http://www.psoug.org/reference/utl_file.html
    How to get it out of the table in the first place?
    I usually try a SELECT statement. They seem to work.
    PS: Databases don't have fields ... table's don't either. Check your verbiage.
    Try looking of the word "FIELD" in the Oracle docs. Then try "COLUMN."

  • Error while extracting XML file from the application server

    Hi ,
    I am writing a XML file into the application server, after which when i try to extract the file to the local server using the report - RFASLDPC ,
    the file is extracted, but with a '#' symbol at the first position.
    Because of which the XML File does not open. But after i open the file in notepad and manually delete the '#' symbol and then reopen the file, it works fine.
    Is there any way to remove the '#' symbol while extracting itself ??
    Thanks in advance,
    Vikas.

    Select the option "No Character Set Conversion" in stead of Code page 1100.
    However, I still have troubles -> the downloaded xml file misses a space on several places. This causes errors too.

  • Failing to extract xml value using Jdom & Xpath

    I have a method (getSingleNodeValue()) which when passed an xpatch expression will extract the value of the specified element in the xml document refered to in 'doc'. Assume doc at this point has been initialised as shown below and xmlInput is the buffer containing the xml content.
        SAXBuilder     builder          =     null;
        Document     doc          =     null;
        XPath          xpathInstance     =      null;
        doc     = builder.build(new StringReader(xmlInput));When i call the method, i pass the following xpath xpression
        /TOP4A/PERLODSUMDEC/TINPLD1/text()Here is the method. It basically just takes an xml buffer and uses xpath to extract the value:
        public static String getSingleNodeValue(String xpathExpr) throws Exception{
             Text list = null;
             try {
                  xpathInstance = XPath.newInstance(xpathExpr);
                  list = (Text) xpathInstance.selectSingleNode(doc);
             } catch (JDOMException e) {
                  throw new Exception(e);
             }catch (Exception e){
                  throw new Exception(e);
             return list==null ? "?" : list.getText();
        }The above method always returns "?" i.e. nothing is found so 'list' is null.
    The xml document it looks at is
        <TOP4A xmlns="http://www.testurl.co.uk/enment/gqr/3232/1">   
          <HEAD>
            <Doc>ABCDUK1234</Doc> 
          </HEAD>   
          <PERLODSUMDEC>
            <TINPLD1>10109000000000000</TINPLD1>
          </PERLODSUMDEC>
        </TOP4A>The same method works with other xml documents so i am not sure what is special about this one. There is no exception so the xml is valid xml. Its just that the method always sets 'list' to null. Any ideas?
    Edit
    Here is a running program testing the above:
        import org.jdom.*;
        import org.jdom.input.*;
        import org.jdom.xpath.*;
        import java.io.IOException;
        import java.io.StringReader;
        public class XpathTest {
             public static String getSingleNodeValue(String xpathExpr, String xmlInput) throws Exception{
                 Text list = null;
                  SAXBuilder  builder           =   null;
                  Document    doc                    =   null;
                  XPath       xpathInstance   =   null;
                 try {
                      builder     = new SAXBuilder();     
                      doc          = builder.build(new StringReader(xmlInput));
                     xpathInstance = XPath.newInstance(xpathExpr);
                     list = (Text) xpathInstance.selectSingleNode(doc);
                 } catch (JDOMException e) {
                     throw new Exception(e);
                 }catch (Exception e){
                     throw new Exception(e);
                 return list==null ? "Nothing Found" : list.getText();
             public static void main(String[] args){
                  String xmlInput1 = "<TOP4A xmlns=\"http://www.testurl.co.uk/enment/gqr/3232/1\"><HEAD><Doc>ABCDUK1234</Doc></HEAD><PERLODSUMDEC><TINPLD1>10109000000000000</TINPLD1></PERLODSUMDEC></TOP4A>";
                  String xpathExpr = "/TOP4A/PERLODSUMDEC/TINPLD1/text()";
                  XpathTest xp = new XpathTest();
                  try {
                       System.out.println(xp.getSingleNodeValue(xpathExpr, xmlInput1));
                  } catch (Exception e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
        }When i run the above, the output is
        Nothing foundEdit
    I have run some further testing and it appears that if i remove the namespace url it does work. Not sure why yet. Is there any way i can tell it to ignore the namespace?
    Edited by: ziggy on Sep 3, 2011 4:57 PM

    ziggy wrote:
    <TOP4A xmlns="http://www.testurl.co.uk/enment/gqr/3232/1">   
    <HEAD>
    <Doc>ABCDUK1234</Doc> 
    </HEAD>   
    <PERLODSUMDEC>
    <TINPLD1>10109000000000000</TINPLD1>
    </PERLODSUMDEC>
    </TOP4A>
    It works fine, the problem is not with namespace, it is with url have given.
    Editing:
    Found a way to say the program to ignore namespace.
    You have to use Xpath.addNamespace(prefix,uri), and pass the prefix to your pattern string.
    If not clear refer the below code:
    import org.jdom.*;
        import org.jdom.input.*;
        import org.jdom.xpath.*;
        import java.io.IOException;
        import java.io.StringReader;
        public class XpathTest {
             public static String getSingleNodeValue(String xpathExpr, String xmlInput) throws Exception{
                 Text list = null;
                  SAXBuilder  builder           =   null;
                  Document    doc                    =   null;
                  XPath       xpathInstance   =   null;
                 try {
                      builder     = new SAXBuilder();     
                      doc          = builder.build(new StringReader(xmlInput));
                     xpathInstance = XPath.newInstance(xpathExpr);
                        xpathInstance.addNamespace("ns","http://www.testurl.co.uk/enment/gqr/3232/1");
                     list = (Text) xpathInstance.selectSingleNode(doc);
                 } catch (JDOMException e) {
                     throw new Exception(e);
                 }catch (Exception e){
                     throw new Exception(e);
                 return list==null ? "Nothing Found" : list.getText();
             public static void main(String[] args){
                  String xmlInput1 = "<TOP4A xmlns=\"http://www.testurl.co.uk/enment/gqr/3232/1\"><HEAD><Doc>ABCDUK1234</Doc></HEAD><PERLODSUMDEC><TINPLD1>10109000000000000</TINPLD1></PERLODSUMDEC></TOP4A>";
                  String xpathExpr = "/ns:TOP4A/ns:PERLODSUMDEC/ns:TINPLD1/text()";
                  XpathTest xp = new XpathTest();
                  try {
                       System.out.println(xp.getSingleNodeValue(xpathExpr, xmlInput1));
                  } catch (Exception e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
        }Edited by: 833545 on Sep 8, 2011 11:35 PM

  • How can I extract XML from a text document?

    I have tons of text documents containing useless text and a section of XML. I would like to use either Mac Automator or Apple Script to pull the XML section out and place it in a new document with a .xml extension. How can I do that?
    Here is a sample of the XML section that I need to pull:
    - ---Start ACNS XML
    <?xml version="1.0" encoding="UTF-8"?>
    <Infringement xsi:schemaLocation="http://www.movielabs.com/ACNS/ACNS2v1.xsd" xmlns="http://www.movielabs.com/ACNS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">           <Case>
    <ID>22242387629</ID>
    <Status>OPEN</Status>
    <Severity>Normal</Severity>
    </Case>
    <Complainant>
    <Entity>MPAA Search and Notify</Entity>
    <Contact></Contact>
    <Address></Address>
    <Phone>5555555555</Phone>
    <Email>[email protected]</Email>
    </Complainant>
    <Service_Provider>
    <Entity>Some Place, Somewhere</Entity>
    <Contact></Contact>
    <Address>Some Place, Somewhere  </Address>
    <Phone></Phone>
    <Email>[email protected]</Email>
    </Service_Provider>
    <Source>
    <TimeStamp>2011-12-02T23:41:59.94Z</TimeStamp>
    <IP_Address>127.0.0.1</IP_Address>
    <Port>64153</Port>
    <Type>P2P</Type>
    <SubType BaseType="P2P" Protocol="BitTorrent" />
    <UserName></UserName>
    <Number_Files>1</Number_Files>
    </Source>
    <Content>
    <Item>
    <TimeStamp>2011-12-02T23:41:59.94Z</TimeStamp>
    <AlsoSeen Start="2011-12-02T23:40:00.11Z" End="2011-12-02T23:41:59.94Z"></AlsoSeen>
    <Title>asdfasdf (2011)</Title>
    <Artist></Artist>
    <FileName>asdfasdf (2011) DVDRip XviD-MAXSPEED</FileName>
    <FileSize>1580908467</FileSize>
    <Type>Video</Type>
    <Hash Type="SHA1">8FB7B1F4984AB6E0746B43D2B82D4ED8102984D5</Hash>
    </Item>
    </Content>
    <History></History>
    <Notes></Notes><Type Retraction="false">DMCA</Type>
    <Detection>
    <Asset>
    <OriginalAssetName>asdfasdf (2011)</OriginalAssetName>
    </Asset>
    <ContentMatched Audio="false" Video="true" Text="false" />
    <HashMatched>true</HashMatched>
    <VerificationID>Manual and automated watermark verification</VerificationID>
    </Detection>
    <Verification>
    <VerificationLevel Type="DT">2</VerificationLevel>
    </Verification>
    <TextNotice><![CDATA[12-03-2011

    XML portion always starts with <Infringement and ends with </Infringement>.
    Actually, it doesn't... the XML starts with the <?xml> tag, but that's just me being pedantic
    Given what you've said, though, it's easy to extract the XML data from a given block of text.
    First, read the source data:
    set theText to read file "path:to:the:file"
    Then you can extract the XML via something like:
    set start_tag to "<?xml"
    set end_tag to "</Infringement>"
    set start_of_data to offset of start_tag in theText
    set end_of_data to (offset of end_tag in theText) + (-1 + (length of end_tag))
    set theXML to text start_of_data through end_of_data of theText
    Now you can write that data to a file:
    set theFile to open for access file ((path to desktop as text) & "output.xml" as text) with write permission
    set eof theFile to 0
    write theXML to theFile starting at 0
    close access theFile
    If you have multiple files you can either run this in a loop that iterates over the files, or save the script as a droplet, then drop the files onto the script icon. Let me know if you need help with that, too.

  • Extracting XML from Pdf form

    There is an industry standard pdf form with an underlying XML schema which can be opened in Adobe reader.
    The form has a custom button on Page 2  called "export" which can be manually clicked to export the XML file.
    We will have hundreds of these forms. How would I automate the extraction of this XML document?
    I would prefer to just write a simple script and extract out the xml to a file folder
    Thanks for your help.

    Thanks Patrick.
    We are thinking about using a third party native Java library to do this (http://www.qoppa.com/pdffields/jpfindex.html). I was hoping we could use acrobat reader, since everyone has it!
    Here are a few more things.
    1. We are an Software Vendor that sells our solutions - our software solutions need to extract the xml from pdf. We have a java based program that parses this xml and does stuff with it.
    2. Obviously, we would need to be able to redistribute whatever solution we use to extract the xml from pdf.
    3. Can Acrobat Professional batch mode be executed from Java?
    4.. If so, Instead of distributing a full blown Acrobat Professional or requiring customers to buy it,  is there a library that Adobe provides that we could repackage and ewdistribute? If so, can you send me some pointers on where I could find what those libraries would be and how much would they cost for each distribution we do.
    5. If no, are you familiar with qoppa or do you have recommendations on any other third party libary for Java?
    Thanks a bunch!

  • Extracting xml from BLOB and display on the Browser on the fly using xslt

    HI All,
    I am storing my xml file in BLOB in oracle database.
    Now in my java-jsp application, I want to display this xml file, by extracting from BLOB in a formatted/html way...( XSLT/CSS Style) on the fly.. means without storing it as a .xml file.
    Pl. guide me...
    Thanks in advance.
    Sandeep Oza

    First, can you get an InputStream that allows you to read the XML from the BLOB?
    If you can, then simply get a Transformer object for your XSLT, then calltransform(new StreamSource(yourInputStream), new StreamResult(resp.getOutputStream()));Since you won't be writing any HTML for this, there's no point in putting it in a JSP, either. A servlet would be more suitable.

  • Problem In Extracting xml file from Zip File

    Hi,
    In my application I am creating a zip file which contains some xml files. I am using Weblogic 8.1 for my application.
    When I try to extract the xml file from the zip file it displays error and those xml files are not extracted from the zip file.
    Otherwise on tomcat it works absolutely fine.
    Is there any support issues of using the zip files with weblogic?
    Please respond.
    Thanks in Advance.

    Friends
    I resolved the problem
    just to add the jars of
    mail.jar and activation.jar in the client side.
    regards
    ashok

  • Extracting xml content in a XMLTYPE VIEW

    Experts:
    I need to create an xmltype view based on the following xml content.
    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <EMPLOYEES CREATED="2013-02-06T12:33:00" xsi:noNamespaceSchemaLocation="http://supporthtml.oracle.com/TEST_SCHEMA.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <EMPLOYEE_TRANS MODE="A" emp_id="1">
      <emp_nm>SCOTT</emp_nm>
      <emp_dept>FN</emp_dept>
      <mgr>DON</mgr>
      <sal>4000</sal>
      <updt_ts>2013-02-06T12:28:00</updt_ts>
      </EMPLOYEE_TRANS>
    <EMPLOYEE_TRANS MODE="A" emp_id="2">
      <emp_nm>KEVIN</emp_nm>
      <emp_dept>HR</emp_dept>
      <mgr>MIKE</mgr>
      <sal>3000</sal>
      <updt_ts>2013-02-06T12:29:00</updt_ts>
      </EMPLOYEE_TRANS>
    </EMPLOYEES>I want to run a select statement againt this view which can give me column data in this format.
    This xml is already stored in an Oracle XMLTYPE Object Relation table which conforms to a registered xsd schema document.
    select CREATED, MODE, EMP_ID, emp_nm, emp_dept, mgr, sal, updt_ts from employees_view.
    Result:
    2013-02-06T12:33:00 A 1 SCOTT FN DON  4000 2013-02-06T12:28:00
    2013-02-06T12:33:00 A 2 KEVIN HR MIKE 3000 2013-02-06T12:29:00How can I achieve this? I tried by getting various errors. I would appreciate if someone can send me a sample
    11.2.0.3
    Linux
    XMLDBThanks
    Kevin
    Edited by: Kevin_K on Feb 6, 2013 9:54 AM
    Edited by: Kevin_K on Feb 6, 2013 9:55 AM

    I guess the above makes a regular relational view? correct?Yes.
    How can I extract the of CREATED attribute from the top most employees element and attributes "MODE" and "emp_id" from EMPLOYEE_TRANS element ? You have to use a two-level approach :
    SQL> select x1.created, x2.*
      2  from EMPLOYEES_OR_TABLE t
      3     , xmltable('/EMPLOYEES'
      4         passing t.object_value
      5         columns created timestamp path '@CREATED'
      6               , emps    xmltype   path 'EMPLOYEE_TRANS'
      7       ) x1
      8     , xmltable('/EMPLOYEE_TRANS'
      9         passing x1.emps
    10         columns emp_mode varchar2(1)  path '@MODE'
    11               , emp_id   number       path '@emp_id'
    12               , emp_nm   varchar2(30) path 'emp_nm'
    13               , updt_ts  timestamp    path 'updt_ts'
    14       ) x2 ;
    CREATED                     EMP_MODE     EMP_ID EMP_NM                         UPDT_TS
    06/02/13 12:33:00,000000    A                 1 SCOTT                          06/02/13 12:28:00,000000
    06/02/13 12:33:00,000000    A                 2 KEVIN                          06/02/13 12:29:00,000000
    The first XMLTable x1 extracts top-level information, then passes the collection of EMPLOYEE_TRANS elements to a second XMLTable that breaks each item in separate rows and columns.
    It's also possible to use a single XMLTable, but with a little more complex XQuery expression.

  • Using XPath with SQL to extract XML data

    Given data such as this one:
    <?xml version="1.0"?>
    <ExtendedData>
       <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
      <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
      <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
      <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
    </ExtendedData>I normally use extractValue function as shown below for example to extract the value for the last parameter in the data above, e.g:
    select extractValue(extended_data,'/ExtendedData/Parameter[@name="RealProv"]/BooleanValue') "my_column_alias" from tableAny ideas on how I may return the value of the parameter xsi:nil from this node:
    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>I'd like to extract the true in xsi:nil="true"...
    Thanks,
    Edited by: HouseofHunger on May 15, 2012 2:13 PM
    Edited by: HouseofHunger on May 15, 2012 2:13 PM

    Extractvalue() has a third parameter we can use to declare namespace mappings :
    SQL> with sample_data as (
      2    select xmltype('<?xml version="1.0"?>
      3  <ExtendedData>
      4    <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
      5    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
      6    <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
      7    <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
      8  </ExtendedData>') doc
      9    from dual
    10  )
    11  select extractvalue(
    12           doc
    13         , '/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
    14         , 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
    15         )
    16  from sample_data
    17  ;
    EXTRACTVALUE(DOC,'/EXTENDEDDAT
    true
    If you're on 11.2.0.2 and up, extractvalue() is deprecated.
    One should use XMLCast/XMLQuery instead :
    SQL> with sample_data as (
      2    select xmltype('<?xml version="1.0"?>
      3  <ExtendedData>
      4    <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
      5    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
      6    <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
      7    <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
      8  </ExtendedData>') doc
      9    from dual
    10  )
    11  select xmlcast(
    12           xmlquery('/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
    13            passing doc
    14            returning content
    15           ) as varchar2(5)
    16         )
    17  from sample_data
    18  ;
    XMLCAST(XMLQUERY('/EXTENDEDDAT
    true
    Note : the xsi prefix is predefined when using Oracle XQuery, so in this case we don't have to declare it explicitly.
    Edited by: odie_63 on 15 mai 2012 15:23

  • Extract XML output to a file from a Query

    Hi Gurus,
    I want to know how can I achieve this. Please post some sample code.
    i want to extract output of following query into xml
    select customer_name,address,phone,email
    from tn_customers
    where rownum <1001
    here i wil get 1000 records.
    Is there any way to generate mxl into a file from the above query?
    Please help

    First you must have defined a output directory:
    create directory OUTPUT_DIRECTORY as 'c:\work'
    Then you need a function which creates the xml for you, for example:
    function create_xmltype
    return xmltype
    is
    queryctx dbms_xmlquery.ctxtype;
    result clob;
    begin
    -- set up the query context...!
    queryctx := dbms_xmlquery.newcontext ('select customer_name,address,phone,email from tn_customers where rownum <1001');
    -- get the result..!
    result := dbms_xmlquery.getxml (queryctx);
    -- Now you can use the result to put it in tables/send as messages..
    dbms_xmlquery.closecontext (queryctx); -- you must close the query handle..
    return xmltype(result);
    end;
    And last but not least you must create the file. This is shown in next code:
    procedure write_file
    is
    cursor c_cur
    is
    select primary_id, clob_stuff
    from table;
    l_output_directory varchar2 (200) := 'OUTPUT_DIRECTORY';
    output_file utl_file.file_type;
    l_xml xmltype;
    l_blob blob;
    l_data_length number;
    l_offset number default 1;
    l_chunk constant number default 4000;
    l_csid number;
    l_csid_value varchar2 (100);
    begin
    -- make sure we are using correct character set id
    select value
    into l_csid_value
    from nls_database_parameters
    where parameter = 'NLS_CHARACTERSET';
    select nls_charset_id (l_csid_value)
    into l_csid
    from dual;
    for r_cur in c_cur
    loop
    l_xml := xmltype (r_cur.clob_stuff);
    l_blob := l_xml.getblobval (l_csid);
    l_data_length := dbms_lob.getlength (l_blob);
    -- Open the file
    output_file := utl_file.fopen (l_output_directory, r_cur.primary_id || '.xml', 'wb', l_chunk);
    loop
    -- Exit when our file offset is bigger than our file
    exit when l_offset > l_data_length;
    -- Write the output chunk by chunk
    utl_file.put_raw (output_file, dbms_lob.substr (l_blob, l_chunk, l_offset), true);
    -- Increment the offset by the amount written
    l_offset := l_offset + l_chunk;
    end loop;
    -- Close the file and reset offset
    utl_file.fclose (output_file);
    l_offset := 1;
    end loop;
    end write_file;

  • Extracting XML attributes

    Hi!
    I'm working on a big XML document that I will import into inDesign. Many tags have the following structure:
    <verse value="1" chapter="1">...some text...</verse>
    I need to extract the numbers of the 'value' and 'chapter' attributes to add them in the text and style them with character styles. Can this be done with inDesign or with some simple script? Or do I have to use XSLT? I have absolutely no experience of XSLT but I'll be looking into it. I'm assuming this should be quite easy for someone who knows these things though so if someone could give me a hand I'd be grateful.

    Ok, I've made some progress. I managed to put together the following XSL code, which creates tags based on the attribute types and puts the values as tag content:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="verse">
        <xsl:if test="@value = 1">
                  <chapter-number><xsl:value-of select="@chapter"/></chapter-number>
        </xsl:if>
        <verse-number><xsl:value-of select="@value"/></verse-number>
        <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>
    The problem is that it removes all other tags. How can I keep this effect and still keep all the other tags?
    My other problem is that inDesign won't allow me to use this XSLT before import. It just says "could not write data to output". It works when I open the XML in a browser though so the code seems valid.

Maybe you are looking for

  • How can I do a batch rename of the version info?

    I've looked online and then on this forum for a while now and have not found anything that addresses this question, although, it may have been touched upon already somewhere on here. Basically what I want to do is be able to rename numerous versions

  • Problem in importing two different classes with same name...

    I have to import two different classes in my program with the same name.... import org.apache.lucene.document.Document; import org.w3c.dom.Document; //    I AM USING THE DOCUMENT FROM W3C PACKAGE HERE.... DocumentBuilderFactory factory = DocumentBuil

  • Can anyone help with my i pod touch

    i need help with my i pod it freezes on the apple loading screen and it wont start up nor will it turn off. i tryed draining the battery and recharging it, i tried reseting it, and i tried dfu mode; and it still doesnt wor. i really would appreciate

  • I have been charged twice for zineo magazine

    iTunes has charged twice for a magazine download from zineo who do I get money back off and how

  • [POL-5171] CONNECT BY depth exceeded 32 levels

    create table a2 ( barcode varchar2(50), parent_barcode varchar2(50) insert into a2 values('ZJB02451', 'ZJB01268'); insert into a2 values('ZJB02452', 'ZJB01268'); insert into a2 values('ZJB02453', 'ZJB01268'); insert into a2 values('ZJB02454', 'ZJB012