Embedding XML in XML for writing to database

I am creating a BPEL process in Oracle BPEL Manager 10.1.2.0.2 which will read an XML file using a file adapter, perform some XPath operations on the document to obtain attribute values from its content, then write those values and the document itself to a database table using a database adapter. The attribute to receive the document is a CLOB of type SQL.XMLType.
Given that use of a database adapter typically involves using a stylesheet to map the contents of a working document to a document reflecting the table schema, how do I go about mapping the XML document (as an unparsed string, with all tags intact) to the element of type string that represents the value to write to the XMLType CLOB? Every technique I've tried thus far strips away the tags.
Thanks for your time,
Paul Camann

Hi Rauno,
that sample was added in 10.1.3.1 but the idea should work in 10.1.2.0.2.
I am copying and pasting the key parts of that README.txt:
<copy>
<from expression="ora:getContentAsString(bpws:getVariableData('Invoke_1_readMovieSelect_title_param_OutputVariable','MoviesCollection'))"/>
<to variable="Invoke_2_merge_InputVariable"
part="MoviesAsClobsCollection"
query="/ns6:MoviesAsClobsCollection/ns6:MoviesAsClobs/ns6:xml"/>
</copy>
Notice the use of the ora:getContentAsString custom function.
The assign looks like this (in .bpel)
<assign name="Assign_4">
<copy>
<from expression="ora:parseEscapedXML(bpws:getVariableData('Invoke_3_readMovieAsClobSelect_title_param_OutputVariable','MoviesAsClobsCollection','/ns5:MoviesAsClobsCollection/ns5:MoviesAsClobs/ns5:xml'))"/>
<to variable="outputVariable" part="payload"
query="/ns4:MoviesCollection"/>
</copy>
</assign>
Those are the two xpaths you need for converting an xml to a CLOB/string and vice versa.
Thanks
Steve

Similar Messages

  • Selective XML Index feature is not supported for the current database version , SQL Server Extended Events , Optimizing Reading from XML column datatype

    Team , Thanks for looking into this  ..
    As a last resort on  optimizing my stored procedure ( Below ) i wanted to create a Selective XML index  ( Normal XML indexes doesn't seem to be improving performance as needed ) but i keep getting this error within my stored proc . Selective XML
    Index feature is not supported for the current database version.. How ever
    EXECUTE sys.sp_db_selective_xml_index; return 1 , stating Selective XML Indexes are enabled on my current database .
    Is there ANY alternative way i can optimize below stored proc ?
    Thanks in advance for your response(s) !
    /****** Object: StoredProcedure [dbo].[MN_Process_DDLSchema_Changes] Script Date: 3/11/2015 3:10:42 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- EXEC [dbo].[MN_Process_DDLSchema_Changes]
    ALTER PROCEDURE [dbo].[MN_Process_DDLSchema_Changes]
    AS
    BEGIN
    SET NOCOUNT ON --Does'nt have impact ( May be this wont on SQL Server Extended events session's being created on Server(s) , DB's )
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
    select getdate() as getdate_0
    DECLARE @XML XML , @Prev_Insertion_time DATETIME
    -- Staging Previous Load time for filtering purpose ( Performance optimize while on insert )
    SET @Prev_Insertion_time = (SELECT MAX(EE_Time_Stamp) FROM dbo.MN_DDLSchema_Changes_log ) -- Perf Optimize
    -- PRINT '1'
    CREATE TABLE #Temp
    EventName VARCHAR(100),
    Time_Stamp_EE DATETIME,
    ObjectName VARCHAR(100),
    ObjectType VARCHAR(100),
    DbName VARCHAR(100),
    ddl_Phase VARCHAR(50),
    ClientAppName VARCHAR(2000),
    ClientHostName VARCHAR(100),
    server_instance_name VARCHAR(100),
    ServerPrincipalName VARCHAR(100),
    nt_username varchar(100),
    SqlText NVARCHAR(MAX)
    CREATE TABLE #XML_Hold
    ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY , -- PK necessity for Indexing on XML Col
    BufferXml XML
    select getdate() as getdate_01
    INSERT INTO #XML_Hold (BufferXml)
    SELECT
    CAST(target_data AS XML) AS BufferXml -- Buffer Storage from SQL Extended Event(s) , Looks like there is a limitation with xml size ?? Need to re-search .
    FROM sys.dm_xe_session_targets xet
    INNER JOIN sys.dm_xe_sessions xes
    ON xes.address = xet.event_session_address
    WHERE xes.name = 'Capture DDL Schema Changes' --Ryelugu : 03/05/2015 Session being created withing SQL Server Extended Events
    --RETURN
    --SELECT * FROM #XML_Hold
    select getdate() as getdate_1
    -- 03/10/2015 RYelugu : Error while creating XML Index : Selective XML Index feature is not supported for the current database version
    CREATE SELECTIVE XML INDEX SXI_TimeStamp ON #XML_Hold(BufferXml)
    FOR
    PathTimeStamp ='/RingBufferTarget/event/timestamp' AS XQUERY 'node()'
    --RETURN
    --CREATE PRIMARY XML INDEX [IX_XML_Hold] ON #XML_Hold(BufferXml) -- Ryelugu 03/09/2015 - Primary Index
    --SELECT GETDATE() AS GETDATE_2
    -- RYelugu 03/10/2015 -Creating secondary XML index doesnt make significant improvement at Query Optimizer , Instead creation takes more time , Only primary should be good here
    --CREATE XML INDEX [IX_XML_Hold_values] ON #XML_Hold(BufferXml) -- Ryelugu 03/09/2015 - Primary Index , --There should exists a Primary for a secondary creation
    --USING XML INDEX [IX_XML_Hold]
    ---- FOR VALUE
    -- --FOR PROPERTY
    -- FOR PATH
    --SELECT GETDATE() AS GETDATE_3
    --PRINT '2'
    -- RETURN
    SELECT GETDATE() GETDATE_3
    INSERT INTO #Temp
    EventName ,
    Time_Stamp_EE ,
    ObjectName ,
    ObjectType,
    DbName ,
    ddl_Phase ,
    ClientAppName ,
    ClientHostName,
    server_instance_name,
    nt_username,
    ServerPrincipalName ,
    SqlText
    SELECT
    p.q.value('@name[1]','varchar(100)') AS eventname,
    p.q.value('@timestamp[1]','datetime') AS timestampvalue,
    p.q.value('(./data[@name="object_name"]/value)[1]','varchar(100)') AS objectname,
    p.q.value('(./data[@name="object_type"]/text)[1]','varchar(100)') AS ObjectType,
    p.q.value('(./action[@name="database_name"]/value)[1]','varchar(100)') AS databasename,
    p.q.value('(./data[@name="ddl_phase"]/text)[1]','varchar(100)') AS ddl_phase,
    p.q.value('(./action[@name="client_app_name"]/value)[1]','varchar(100)') AS clientappname,
    p.q.value('(./action[@name="client_hostname"]/value)[1]','varchar(100)') AS clienthostname,
    p.q.value('(./action[@name="server_instance_name"]/value)[1]','varchar(100)') AS server_instance_name,
    p.q.value('(./action[@name="nt_username"]/value)[1]','varchar(100)') AS nt_username,
    p.q.value('(./action[@name="server_principal_name"]/value)[1]','varchar(100)') AS serverprincipalname,
    p.q.value('(./action[@name="sql_text"]/value)[1]','Nvarchar(max)') AS sqltext
    FROM #XML_Hold
    CROSS APPLY BufferXml.nodes('/RingBufferTarget/event')p(q)
    WHERE -- Ryelugu 03/05/2015 - Perf Optimize - Filtering the Buffered XML so as not to lookup at previoulsy loaded records into stage table
    p.q.value('@timestamp[1]','datetime') >= ISNULL(@Prev_Insertion_time ,p.q.value('@timestamp[1]','datetime'))
    AND p.q.value('(./data[@name="ddl_phase"]/text)[1]','varchar(100)') ='Commit' --Ryelugu 03/06/2015 - Every Event records a begin version and a commit version into Buffer ( XML ) we need the committed version
    AND p.q.value('(./data[@name="object_type"]/text)[1]','varchar(100)') <> 'STATISTICS' --Ryelugu 03/06/2015 - May be SQL Server Internally Creates Statistics for #Temp tables , we do not want Creation of STATISTICS Statement to be logged
    AND p.q.value('(./data[@name="object_name"]/value)[1]','varchar(100)') NOT LIKE '%#%' -- Any stored proc which creates a temp table within it Extended Event does capture this creation statement SQL as well , we dont need it though
    AND p.q.value('(./action[@name="client_app_name"]/value)[1]','varchar(100)') <> 'Replication Monitor' --Ryelugu : 03/09/2015 We do not want any records being caprutred by Replication Monitor ??
    SELECT GETDATE() GETDATE_4
    -- SELECT * FROM #TEMP
    -- SELECT COUNT(*) FROM #TEMP
    -- SELECT GETDATE()
    -- RETURN
    -- PRINT '3'
    --RETURN
    INSERT INTO [dbo].[MN_DDLSchema_Changes_log]
    [UserName]
    ,[DbName]
    ,[ObjectName]
    ,[client_app_name]
    ,[ClientHostName]
    ,[ServerName]
    ,[SQL_TEXT]
    ,[EE_Time_Stamp]
    ,[Event_Name]
    SELECT
    CASE WHEN T.nt_username IS NULL OR LEN(T.nt_username) = 0 THEN t.ServerPrincipalName
    ELSE T.nt_username
    END
    ,T.DbName
    ,T.objectname
    ,T.clientappname
    ,t.ClientHostName
    ,T.server_instance_name
    ,T.sqltext
    ,T.Time_Stamp_EE
    ,T.eventname
    FROM
    #TEMP T
    /** -- RYelugu 03/06/2015 - Filters are now being applied directly while retrieving records from BUFFER or on XML
    -- Ryelugu 03/15/2015 - More filters are likely to be added on further testing
    WHERE ddl_Phase ='Commit'
    AND ObjectType <> 'STATISTICS' --Ryelugu 03/06/2015 - May be SQL Server Internally Creates Statistics for #Temp tables , we do not want Creation of STATISTICS Statement to be logged
    AND ObjectName NOT LIKE '%#%' -- Any stored proc which creates a temp table within it Extended Event does capture this creation statement SQL as well , we dont need it though
    AND T.Time_Stamp_EE >= @Prev_Insertion_time --Ryelugu 03/05/2015 - Performance Optimize
    AND NOT EXISTS ( SELECT 1 FROM [dbo].[MN_DDLSchema_Changes_log] MN
    WHERE MN.[ServerName] = T.server_instance_name -- Ryelugu Server Name needes to be added on to to xml ( Events in session )
    AND MN.[DbName] = T.DbName
    AND MN.[Event_Name] = T.EventName
    AND MN.[ObjectName]= T.ObjectName
    AND MN.[EE_Time_Stamp] = T.Time_Stamp_EE
    AND MN.[SQL_TEXT] =T.SqlText -- Ryelugu 03/05/2015 This is a comparision Metric as well , But needs to decide on
    -- Peformance Factor here , Will take advise from Lance if comparision on varchar(max) is a vital idea
    --SELECT GETDATE()
    --PRINT '4'
    --RETURN
    SELECT
    top 100
    [EE_Time_Stamp]
    ,[ServerName]
    ,[DbName]
    ,[Event_Name]
    ,[ObjectName]
    ,[UserName]
    ,[SQL_TEXT]
    ,[client_app_name]
    ,[Created_Date]
    ,[ClientHostName]
    FROM
    [dbo].[MN_DDLSchema_Changes_log]
    ORDER BY [EE_Time_Stamp] desc
    -- select getdate()
    -- ** DELETE EVENTS after logging into Physical table
    -- NEED TO Identify if this @XML can be updated into physical system table such that previously loaded events are left untoched
    -- SET @XML.modify('delete /event/class/.[@timestamp="2015-03-06T13:01:19.020Z"]')
    -- SELECT @XML
    SELECT GETDATE() GETDATE_5
    END
    GO
    Rajkumar Yelugu

    @@Version : ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
        May 14 2014 18:34:29
        Copyright (c) Microsoft Corporation
        Developer Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
    (1 row(s) affected)
    Compatibility level is set to 110 .
    One of the limitation states - XML columns with a depth of more than 128 nested nodes
    How do i verify this ? Thanks .
    Rajkumar Yelugu

  • Confusion for writing Crawling Data to Which XML Methods?

    Hi,
    I am stucked over here as i m going to use XML.
    Problem Having :-
    I have implemented the Crawling code .
    In which I have written the upcoming Main urls and and its sublinks in the Different Text File with the Incremented numbers.
    But in the Text files i can't see each and every URl's Grand Parent ,Parent and Child Relations.
    So, it generates the confusion and more time to see which URl having which Sublinks and its Text Files.
    Thinkable Approxiamte Solution from my side
    To use XML for Writing the Crawling processed all links Grant Parent, Parent and Child Relation Ships.
    Which can be useful for Traversing all the links Parent and Child relation Ship into only 1 XML file.
    XML files after that will used to read line by line and fetch the uRLs and that will used for other process ahead.
    Question Having:
    There are so many XML Methods available on the internet.(i.e. XMLwriting,XML Beans,Dom4j,XML Parser,SAX Parser,Dom Parser)
    So which method should i used for reading and writing the Crawling Parent and Child Relation ship using Good Schema.?
    Pls provide some code or useful links or any Suggetion which makes me to reach at solution.

    Use the Write Waveforms to File VI to write to a tab delimited text file.  Excel can open those up just fine.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Choosing between SAX & DOM & StringBuffer class for writing XML

    Hii Javaties
    I need to create a XML document from a swing application.
    I need to store this xml in a file.
    For writing XML which parser should i use SAX or DOM or should i go for StringBuffer class.

    I'm not aware of a way to use SAX to create an XML document. It is used to view the contents of an existing XML document or data that is well-structured.
    That leaves you with a choice of DOM or StringBuffer. We cannot tell enought about what you are doing to know which is better. Each has some advantages and disadvantages.
    StringBuffer:
    + less overhead
    - no assistance in ensuring the validity of the result
    + greater control over layout of resulting document (how and when to indent)
    - any control over layout must be done by you.
    DOM (although this task is easier in JDOM)
    - more overhead
    - some learning curve
    + result is guaranteed to be valid XML.
    + there are pretty formatters to generate good looking results
    - there may be layout choices that the standard pretty formatters cannot do
    As an example, consider this part of the Document being created.
    You want <name>John Doe</name>
    With a StringBuffer, you can just add these pieces. With DOM, you need to:
    1) create an Element named "name".
    2) create a Text object with a value of "John Doe".
    3) add the Text object as a child of the Element
    4) add the Element to the parent
    Having done the DOM version (also a JDOM version) several times, I have developed an XMLHelper class that has several static methods to make simple, common constructs.
    It lets me do things like:
    parent.addChild( XmlHelper.makeElement( "name", customerName ) );
    So, the answer to your question is the same as many other questions: It depends.
    Dave Patterson

  • Wrong XML OraDbType code for database column type CHAR

    Hi there!
    I have a strange issue with the XML retrieved from an Oracle DB. I'm using OraDB11g and my problem is described next:
    When I create a table with a CHAR type columns and get the XML from a query the returns a cursor with the table rows, I get the supposed right OraDbType code 104:
    Table creation:
    create table AA_Table1
    ID number(2,0) not null,
    ColumnA         char(1)                    null,
    ColumnB         char(1)   default 'S'   not null,
    constraint PK_AA_Table1
    primary key ( ID )
    tablespace "X"
    storage
    compress for all operations
    and the returned XML:
    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema id="o_ListaTable" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
    <xs:element name="o_ListTable" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="o_List" msprop:REFCursorName="REFCursor">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="ID" msprop:OraDbType="111" type="xs:short" minOccurs="0" />
    *<xs:element name="COLUMNA" msprop:OraDbType="104" type="xs:string" minOccurs="0" />*
    *<xs:element name="COLUMNB" msprop:OraDbType="104" type="xs:string" minOccurs="0" />*
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    BUT...when I insert another column on the table, changing it, after that, I get a wrong OraDBType code on the returned XML for the new added column...
    Added new column:
    alter table AA_Table1 add ColumnC char(1) default 'S' not null;
    The returned XML is:
    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema id="o_ListaTable" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
    <xs:element name="o_ListTable" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="o_List" msprop:REFCursorName="REFCursor">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="ID" msprop:OraDbType="111" type="xs:short" minOccurs="0" />
    <xs:element name="COLUMNA" msprop:OraDbType="104" type="xs:string" minOccurs="0" />
    <xs:element name="COLUMNB" msprop:OraDbType="104" type="xs:string" minOccurs="0" />
    *<xs:element name="COLUMNC" msprop:OraDbType="126" type="xs:string" minOccurs="0" />*
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    My question is: why is this OraDbType code different? Check that the same column type CHAR(1) NOT NULL DEFAULT 'S' is created on table create and the OraDbType is ok, so I think this can be a bug...Because of this, I cannot do a right XML parser to convert CHAR(1) columns in other type I want, in this case, to convert it to .Net bool type. My parser now is ignoring the OraDbType code 126, because this is also the code used for nvarchar2, and I won't convert nvarchar2 to bool.
    How can I solve this problem?
    Some additional tests I've done:
    Have also inserted new columns nullable/not nullable and with default value:
    alter table AA_Table1 add ColumnD char(1);
    alter table AA_Table1 add ColumnE char(1) not null;
    alter table AA_Table1 add ColumnF char(1) default 'S';
    And the returned XML was:
    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema id="o_ListTable" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
    <xs:element name="o_ListTable" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="o_Lista" msprop:REFCursorName="REFCursor">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="COLUMNA" msprop:OraDbType="104" type="xs:string" minOccurs="0" />
    <xs:element name="COLUMNB" msprop:OraDbType="104" type="xs:string" minOccurs="0" />
    <xs:element name="COLUMNC" msprop:OraDbType="126" type="xs:string" minOccurs="0" />
    *<xs:element name="COLUMND" msprop:OraDbType="104" type="xs:string" minOccurs="0" />*
    *<xs:element name="COLUMNE" msprop:OraDbType="104" type="xs:string" minOccurs="0" />*
    *<xs:element name="COLUMNF" msprop:OraDbType="104" type="xs:string" minOccurs="0" />*
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    All OraDbTypes are right, except that one for the column not null and with default value. Any solution for this issue?
    If I change the type of the column that returns the wrong code (ColumnC) to CHAR(1) null default 'S' and then change it again to the original type CHAR(1) not null default 'S', I get the right ORaDbType code 104 as expcted and not the 126. This behaviour is strange - can this be an Oracle bug?
    I am using the following Oracle DLL and respective version:
    oci.dll (version 11.2.0.1)
    Oracle.DataAccess.dll (version 4.112.3.0)
    orannzsbb11.dll (version 11.0.0.1)
    oraocci11.dll (version 11.2.0.3)
    OraOps11w.dll (version 2.112.3.0)
    Edited by: 929091 on 23/Abr/2012 2:44

    Have you tried using minOccurs="1" ? Since the column is not null, it is guaranteed 1 value, correct?

  • Embedding data from xml file into metadata of a pdf

    Hi All
    I'm wanting to do the following, but struggling to figure the right way to go about it.
    I want to embedded data from my MIS into a pdf's metadata (as scrnshot). I can create a standalone xml file with all the data I require, but I'm unsure how to automate that being embedded into a pdf's advanced metadata. I know this can be done, as it worked at a previous employer, but I didn't get chance to find out how they did it.
    I'm wanting to do this so I can carry out a more advanced search of the metadata in Bridge.
    Any advice would be appreciated!

    Hi Northern,
        I have modified the modifyingXMP sample for you. After this change, put your xmp file as sample.xml and also put pdf file in the same folder where ModifyXMP executable is. After merging my changes, ModifyXMP file will read the sample.xml and will embed it into pdf file.
       Please follow the following steps
    1. Download XMPToolkit SDK and follow the steps to compile Sample
    2. Open ModifyingXMP file, replace all the content of that file with the below content
    3. Compile the ModifyingXMP file.
    4. The ModifyXMP.exe will be generated in folder (samples\target\windows\Debug), if you have changed the output folder it will be generated there.
    5. In parallel to ModifyingXMP.exe put the sample.xml (the xml file you have) and also the pdf file (say pdf file name is mypdf.pdf)
    6. Go to console and change directory to the directory where ModifyingXMP is and pass the following command
    ModifyingXMP mypdf.pdf
    7. Open the pdf file and check that value/properties
    For your reference, I am putting the content of the sample.xml file too, put this content in sample.xmp and any pdf and you will find subject field is getting added.
    ************** content of the sample.xml file. Create a file name sample.xml and put that content. Put sample.xml in parallel to ModifyingXMP.exe*******
    <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
        <rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/elements/1.1/'>
            <dc:subject>
                <rdf:Bag>
                    <rdf:li>XMP</rdf:li>
                    <rdf:li>SDK</rdf:li>
                    <rdf:li>Sample</rdf:li>
                </rdf:Bag>
            </dc:subject>
            <dc:format>image/tiff</dc:format>
        </rdf:Description>
    </rdf:RDF>
    ******************* MODIFIED CONTENT OF MODIFYING.CPP FILE. ***************************************************************************************** ************
    // ========================================================================================= ========
    // Copyright 2008 Adobe Systems Incorporated
    // All Rights Reserved.
    // NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the terms
    // of the Adobe license agreement accompanying it.
    // ========================================================================================= ========
    * Tutorial solution for Walkthrough 2 in the XMP Programmers Guide, Modifying XMP
    * Demonstrates how to open a file for update, and modifying the contained XMP before writing it back to the file.
    #include <cstdio>
    #include <vector>
    #include <string>
    #include <cstring>
    // Must be defined to instantiate template classes
    #define TXMP_STRING_TYPE std::string
    // Must be defined to give access to XMPFiles
    #define XMP_INCLUDE_XMPFILES 1
    // Ensure XMP templates are instantiated
    #include "public/include/XMP.incl_cpp"
    // Provide access to the API
    #include "public/include/XMP.hpp"
    #include <iostream>
    #include <fstream>
    using namespace std;
    * Creates an XMP object from an RDF string.  The string is used to
    * to simulate creating and XMP object from multiple input buffers.
    * The last call to ParseFromBuffer has no kXMP_ParseMoreBuffers options,
    * thereby indicating this is the last input buffer.
    #include <sstream>     
    SXMPMeta createXMPFromRDF()
        string rdf;
        //open the RDF file and put it's content into rdf buffer
        ifstream inFile;
        inFile.open("sample.xml");//open the input file
        if (!inFile.is_open()) {
            cout <<"Couldn't open xml file" <<endl;
            exit(1);
        stringstream strStream;
        strStream << inFile.rdbuf();//read the file
        rdf = strStream.str();//str holds the content of the file
        SXMPMeta meta;
        // Loop over the rdf string and create the XMP object
        // 10 characters at a time
        int i;
        for (i = 0; i < (long)rdf.size() - 10; i += 10 )
            meta.ParseFromBuffer ( &rdf[i], 10, kXMP_ParseMoreBuffers );
        meta.ParseFromBuffer ( &rdf[i], (XMP_StringLen) rdf.size() - i );
        return meta;
    int main ( int argc, const char * argv[] )
        if ( argc != 2 ) // 2 := command and 1 parameter
            cout << "usage: ModifyingXMP (filename)" << endl;
            return 0;
        string filename = string( argv[1] );
        if(!SXMPMeta::Initialize())
            cout << "Could not initialize toolkit!";
            return -1;
        XMP_OptionBits options = 0;
        #if UNIX_ENV
            options |= kXMPFiles_ServerMode;
        #endif
        // Must initialize SXMPFiles before we use it
        if(SXMPFiles::Initialize(options))
            try
                // Options to open the file with - open for editing and use a smart handler
                XMP_OptionBits opts = kXMPFiles_OpenForUpdate | kXMPFiles_OpenUseSmartHandler;
                bool ok;
                SXMPFiles myFile;
                std::string status = "";
                // First we try and open the file
                ok = myFile.OpenFile(filename, kXMP_UnknownFile, opts);
                if( ! ok )
                    status += "No smart handler available for " + filename + "\n";
                    status += "Trying packet scanning.\n";
                    // Now try using packet scanning
                    opts = kXMPFiles_OpenForUpdate | kXMPFiles_OpenUsePacketScanning;
                    ok = myFile.OpenFile(filename, kXMP_UnknownFile, opts);
                // If the file is open then read get the XMP data
                if(ok)
                    cout << status << endl;
                    cout << filename << " is opened successfully" << endl;
                    // Create the XMP object and get the XMP data
                    SXMPMeta meta;
                    myFile.GetXMP(&meta);
                    // Create a new XMP object from an RDF string
                    SXMPMeta rdfMeta = createXMPFromRDF();
                    // Append the newly created properties onto the original XMP object
                    // This will:
                    // a) Add ANY new TOP LEVEL properties in the source (rdfMeta) to the destination (meta)
                    // b) Replace any top level properties in the source with the matching properties from the destination
                    SXMPUtils::ApplyTemplate(&meta, rdfMeta, kXMPTemplate_AddNewProperties | kXMPTemplate_ReplaceExistingProperties | kXMPTemplate_IncludeInternalProperties);
                    // Check we can put the XMP packet back into the file
                    if(myFile.CanPutXMP(meta))
                        // If so then update the file with the modified XMP
                        myFile.PutXMP(meta);
                    // Close the SXMPFile.  This *must* be called.  The XMP is not
                    // actually written and the disk file is not closed until this call is made.
                    myFile.CloseFile();
                else
                    cout << "Unable to open " << filename << endl;
            catch(XMP_Error & e)
                cout << "ERROR: " << e.GetErrMsg() << endl;
            // Terminate the toolkit
            SXMPFiles::Terminate();
            SXMPMeta::Terminate();
        else
            cout << "Could not initialize SXMPFiles.";
            return -1;
        return 0;
    Please let me know if you find any issue/assistance.
    -Sunil

  • Extract Embedded XML within XML using XSLT

    Hi,
    We have a unique scenario where our incoming payload is coming from Oracle Database table which has one column of CLOB type storing complete raw XML.
    We need to extract this embedded raw XML and process it further, each XML has a unique XSD associated and we have that details in a separate column.
    So our DBAdapter incoming payload looks like below
    <rows>
    <row>
    <xml_xsd>xyz.xsd</xml_xsd>
    <xml>RAW XML DATA</xml>
    </row>
    <row>
    <xml_xsd>xyzv2.xsd</xml_xsd>
    <xml>RAW XML DATA</xml>
    </row>
    <row>
    <xml_xsd>xyzv2.xsd</xml_xsd>
    <xml>RAW XML DATA</xml>
    </row>
    <row>
    <xml_xsd>xyzv3.xsd</xml_xsd>
    <xml>RAW XML DATA</xml>
    </row>
    </rows>
    How can we leverage XSL Transformation to extract this embedded XML in each row? I need the each individual XML available for further mapping. I can split the payload using XPATH filtering per XSD, but not able to find a solution to parse the embedded XML and assign to a target schema?
    Research done so far points to do two transformations to get resulting XML or using Saxon Parser if available and use the parse() extension.
    Any other ideas/suggestions will be helpful. Challenge here is performance as i need to do this in bulk, will have many rows to process
    Thanks in advance.

    Hi,
    You dont have finite set of XSD's and probably you wont be creating a variable for each type of xsd from that finite set.
    Secondly, xslt doesnt support dynamic xpath as per my knowledge.
    Question:
    Do you really need XSD to do the validation?
    A possible solution to your question would be using java approach as below: Pass the xml and the xpath query
        public String evalXpath(String xml, String xpathQuery) {
              String xpathResult ;
            DocumentBuilderFactory domFactory =
                DocumentBuilderFactory.newInstance();
            try {
                DocumentBuilder builder = domFactory.newDocumentBuilder();
                InputSource is = new InputSource(new StringReader(xml));
                Document dDoc = builder.parse(is);
                XPath xPath = XPathFactory.newInstance().newXPath();
                Object result =
                    (NodeList)xPath.evaluate(xpathQuery, dDoc, XPathConstants.NODESET);
                NodeList nodes = (NodeList)result;
                for (int i = 0; i < nodes.getLength(); i++) {
                    xpathResult = nodes.item(i).getNodeValue();
                    System.out.println(xpathResult);
            } catch (Exception e) {
                e.printStackTrace();
            return xpathResult;
    Thanks,
    Rosh

  • How to insert into table from a xml with XDE for java?

    want to insert into the oracle tables from the xml with XDE for java, some sample better. thank you.

    XML Document may be stored in a SQL database with XML SQL Utility.
    http://download-west.oracle.com/docs/cd/B13789_01/appdev.101/b10794/adx08xsu.htm#i1008168
    XML Document may be stored in a SQL database with Oracle XML DB.
    http://download-west.oracle.com/docs/cd/B13789_01/appdev.101/b10790/xdb03usg.htm#CEGFECFH

  • Problem with running sample code from XML Schema Processor for Java

    Hi there,
    I downloaded the XML Schema Processor for Java and tried it out. Unfortunately, it failed at the first step. FYI, I included all xmlparserv2.jar and xmlschema.jar in my classpath.
    I compiled XSDSample.java with a warning: XSDSample.java uses a deprecated API. Recompile with "-deprecation" for details. There was no problem with compiling XSDSetSchema.java.
    When I tried to run report.xml by typing java XSDSample report.xml, I got Parsing report.xml
    NonParserException: null.
    I guess that report.xml from the sample is not valid.
    Could any one give me a hint? Any suggestion would be greatly appreciated.
    ---Denali
    null

    Please post this message at:
    Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB

  • Is XML-SQL Utility for Java run on Client Side?

    A question about the XML-SQL Utility for Java
    When a client program connect to a Oracle database (the clinet program and Oracle DB is run on two different machine. Oracle 8i is used) and use the oracle.xml.sql.query.OracleXMLQuery Class (form the XSU) to generate XML by given a SQL query. I want to know the transforation process is execute in the Clinet side or the database?
    Is there any method that i can retrieve the XML directly from the database rather then doing the transformation form the Client side?

    Set JDK_HOME to the directory where you install your JDK (Java Development Kit).
    So instance, I've install JDK1.1.8 on my
    C drive so
    set JDK_HOME=c:\jdk1.1.8;c:\jdk1.1.8\bin

  • Inserting XML(Master Detail like PO)into Database

    hi,
    Can any one suggest me which tools or what methodolgy I should use to insert master detail data like one header and multiple rows into database.
    I am unable to insert into database through object view with the help of XML SQL utility for Java.
    Please help in this....
    null

    Here's an example that ships with
    the XSQL Servlet release 0.9.8.6
    (due out any day now on OTN!!)
    With this set of types and object view
    you can insert documents like the
    example at the end that is REM'd out.
    drop view department;
    drop type dept_t;
    drop type emp_list;
    drop type emp_t;
    create or replace type emp_t as object (
    empno number,
    ename varchar2(80),
    sal number
    create or replace type emp_list as table of emp_t;
    create or replace type dept_t as object (
    deptno number,
    dname varchar2(80),
    loc varchar2(80),
    employees emp_list
    create or replace view department of dept_t
    with object OID (deptno)
    as select deptno, dname, loc,
    cast(multiset(select empno, ename, sal
    from emp
    where emp.deptno = dept.deptno
    ) as emp_list ) employees
    from dept;
    create trigger department_ins
    instead of insert on department
    for each row
    declare
    emps emp_list;
    emp emp_t;
    begin
    -- Insert the master
    insert into dept( deptno, dname, loc )
    values (:new.deptno, :new.dname, :new.loc);
    -- Insert the details
    emps := :new.employees;
    for i in 1..emps.count loop
    emp := emps(i);
    insert into emp(deptno, empno, ename, sal)
    values (:new.deptno, emp.empno, emp.ename, emp.sal);
    end loop;
    end;
    REM
    REM
    REM <ROWSET>
    REM <ROW>
    REM <DEPTNO>99</DEPTNO>
    REM <DNAME>ACCOUNTING</DNAME>
    REM <LOC>NEW YORK</LOC>
    REM <EMPLOYEES>
    REM <EMPLOYEES_ITEM>
    REM <EMPNO>1111</EMPNO>
    REM <ENAME>CLARK</ENAME>
    REM <SAL>2450</SAL>
    REM </EMPLOYEES_ITEM>
    REM <EMPLOYEES_ITEM>
    REM <EMPNO>2222</EMPNO>
    REM <ENAME>KING</ENAME>
    REM <SAL>5000</SAL>
    REM </EMPLOYEES_ITEM>
    REM <EMPLOYEES_ITEM>
    REM <EMPNO>3333</EMPNO>
    REM <ENAME>MILLER</ENAME>
    REM <SAL>1300</SAL>
    REM </EMPLOYEES_ITEM>
    REM </EMPLOYEES>
    REM </ROW>
    REM </ROWSET>
    null

  • Compile build.xml with Ant for web service with annotations

    Hi Friends,
    I have a web service with annotations, using javax.annotation.PostConstruct, and javax.annotation.PreDestroy.
    I have a build.xml to create a EAR for this web service.
    When I run the ant task, the build complete successfully but the .war file cannot be deployed on the WLS server. Taking a closer look, I see that the required files such as, webservices.xml, weblogic.xml, weblogic-webservices.xml, Provision.wsdl files are not generated.
    Following is the build.xml file:
    <?xml version="1.0" encoding="windows-1252" ?>
    <project default="jwsc">
    <property file="build.properties"/>
    <property name="weblogic.jar.classpath"
    value="C:/bea_jDev/wlserver_10.3/server/lib"/>
    <property name="oimclient.jar.classpath"
              value="C:/_data/Project_Dc/OIM_jars" />
         <property name="com.jar.classpath" value="C:/JDeveloper/mywork/Service_Test/lib" />
    <taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask">
    <classpath>
    <path id="weblogic.classpath">
    <pathelement path="WEBLOGIC_HOME"/>
    <fileset dir="${weblogic.jar.classpath}">
    <include name="**/*.jar"/>
    </fileset>
    </path>
    </classpath>
    </taskdef>
    <target name="all" depends="clean,build-service,deploy"></target>
    <target name="build-service">
         <jwsc srcdir="${src.home}" destdir="ear_directory" >
    <classpath>
    <path id="oim.classpath">
    <pathelement path="OIM_HOME"/>
    <fileset dir="${oimclient.jar.classpath}">
    <include name="**/*.jar"/>
    </fileset>
    <fileset dir="${com.jar.classpath}">
    <include name="**/*.jar"/>
    </fileset>
    </path>
    </classpath>
    <jws file="${jws.home}" type="JAXWS" />
    </jwsc>
    </target>
    <target name="deploy">
    <!--add wldeploy task here -->
    </target>
    <target name="clean">
    <delete dir="output" />
    </target>
    </project>
    Can you please point out what else is to be done and where exactly am I going wrong in writing the build.xml file.
    Let me know if some else information is required.

    This is what I get when I run the ant task:
    Buildfile: C:\JDeveloper\mywork\ProvisioningService_Test2\Provision\resource\build.xml
    build-service:
    [jwsc] JWS: processing module /com/fox/provision/webservice/endpoint/impl/ProvisionEndPointImpl
    [jwsc] Parsing source files
    [jwsc] Parsing source files
    [jwsc] 1 JWS files being processed for module /com/.../provision/webservice/endpoint/impl/ProvisionEndPointImpl
    [jwsc] [JAM] Warning: failed to resolve class org.apache.xmlbeans.XmlObject
    [jwsc] [JAM] Warning: failed to resolve class com.bea.xml.XmlObject
    [jwsc] [JAM] Warning: failed to resolve class javax.xml.rpc.holders.Holder
    [jwsc] JWS: C:\..\...\..\...\code\ProvisioningService\src\com\...\provision\webservice\endpoint\impl\..EndPointImpl.java Validated.
    [jwsc] Processing 1 JAX-WS web services...
    [jwsc] warning: Specified AnnotationProcessorFactory, 'com.sun.istack.ws.AnnotationProcessorFactoryImpl', not found on search path.
    warning: No annotation processors found but annotations present.
    2 warnings
    [jwsc] Compiling 2 source files to C:\DOCUME~1\....\LOCALS~1\Temp\_lsgijm
    [jwsc] Building jar: C:\..\...\..\...\code\ProvisioningService\src\com\...\provision\webservice\deploy\ear_directory\com\fox\provision\webservice\endpoint\impl\...EndPointImpl.war
    [jwsc] Created JWS deployment outputFile: C:\..\...\..\...\code\ProvisioningService\src\com\...\provision\webservice\deploy\ear_directory\....\...\provision\webservice\endpoint\impl\..EndPointImpl.war
    [jwsc] [EarFile] Application File : C:\..\...\..\...\code\ProvisioningService\src\com\.....\provision\webservice\deploy\ear_directory\META-INF\application.xml
    [AntUtil.deleteDir] Deleting directory C:\DOCUME~1\....\LOCALS~1\Temp\_lsgijm
    BUILD SUCCESSFUL
    Total time: 7 seconds
    Due to some limitations, I edited the path in the build.xml files.
    Please let me know what can be done. Thanks.
    Edited by: user9112073 on Nov 22, 2011 9:52 PM

  • XML-25004: Could not acquire a database connection named: gksconnection

    HI Gentlemen,
    I am trying to build up an XSQL page with a query against an XMLTYPE table, to display the contents using a stylesheet. I have set up an IDE connection, the test was successful. Now I would like to start the page just to see if it works altogether. Now without a stylesheet, only that the page executes. And I am constantly running into
    XML-25004: Could not acquire a database connection named: gksconnection
    I entered the connection in the XSQLConfig file by manual editing--it did not help. Well, there is some stuff in the forum about setting some preferences for OC4J, but in my version of JDeveloper only Weblogic Server is available. So I am prevented from clearing the cause of the problem.
    My JDeveloper is a Studio Edition Version 11.1.1.3.0, Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660.
    Please help me if you can.
    Many thanks in advance,
    kind regards from
    Miklos HERBOLY

    Sorry, I found a solution in My Oracle Support which will suffice.
    Thank you very much
    Miklos

  • When / why use XML to store data instead of database table ?

    Hi All,
    I still not use XML much in applications and don't know much about its utilization.
    I read here and there about storing data as XML instead of into database tables.
    - could any body please tell me when / why use XML to store data instead of database table ?
    e.g : store inventory per warehouse in XML format. ?
    - What is the other cases or reasons of extracting database records into XML or vice versa ?
    - is there any good pdf on this ?
    Thank you for your help,
    xtanto

    It depends entirely what you want to accomplish with the 'XML in the database'. There are basically 3 independent methods: As CLOB, as XMLType views or as native XMLType 'columns'
    Each method has advantages and disadvantages, especially in the performance vs purpose tradeoff.
    The Oracled Press book "Oracle Database 10g XML & SQL Design, Build, & Manage XML Applications in Java, C, C++, & PL/SQL" is highly recommended for anyone interested in Oracle and XML. http://books.mcgraw-hill.com/getbook.php?isbn=0072229527&template=oraclepress

  • Generate xml source file for Oracle Order Capture Print Quote

    Hi,
    I am new to xml and need to work on creating templates for Print Quote.
    I am trying to generate the xml source file for which I enabled the report in system administrator and set the output to XML and assigned to Quoting Reports responsiblity. I then assigned XML Report Publisher to the same responsiblity.
    I ran the report (Print Quote) and then I am trying to run the XML Report Publisher but I cannot get the request id in the list of values.
    I am able to generate xml source file for other reports like Printed Purchase Order etc.,
    The view output for the (Print Quote) report is as follows:
    <?xml version="1.0" ?>
    - <!-- Generated by Oracle Reports version 6.0.8.26.0
    -->
    <ASOPQTER />
    How do I get the xml source file? Or are there seeded templates that I can use to create more templates? Any help would be appreciated. Thanks Ravi

    Hi, I am in the same position - did this issue ever ger resolved by anyone. I have done a few XMLP reports successfully now using the Word add-in, but customising the Quote output differs from other standard reports.
    If you look at the data definition for Quote it is a 'dummy' definition and has no XML file attached. Does anyone know how I can get the XML format for the report output?
    Also the template uses XSL-FO ?!?!?! rather than RTF - not sure how to work with this, the Oracle docs are not very helpful in this regard either.
    Has anyone successfully managed to customise the Quote print report? Many thanks,
    Roger

Maybe you are looking for