XMLTYPE schemaValidate() problem...

Hello world!

I have a problem using the XMLTYPE.schemaValidate () procedure.
Can someone help me with this problem?

I always get the error: ORA-30937: no schema definition for 'COMPONENT_ID"("##local"namespace) in parent ' / P_WAFERLIST/PLATE [1].


Here's what I did:
_1) first of all, I created the following schema definition: _
<?xml version="1.0"?>
<xs:schema id="P_WAFERLIST" targetNamespace="http://portal.xxx.com/xsd_schemadefinitions/ecf/prop" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:element name="P_WAFERLIST">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="WAFER">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="PARAMETERS" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="PARAMETER" nillable="true" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="NAME" form="unqualified" type="xs:string" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="COMPONENT_ID" form="unqualified" type="xs:string" />
            <xs:attribute name="SUBQTY" form="unqualified" type="xs:string" />
            <xs:attribute name="STATE" form="unqualified" type="xs:string" />
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>
_2) then I did a DBMS_XMLSCHEMA.registerSchema_
      DBMS_XMLSCHEMA.registerSchema ('http://portal.xxx.com/xsd_schemadefinitions/ecf/prop',
                                     sys.UriFactory.getUri ('http://portal.xxx.com/xsd_schemadefinitions/ecf/prop/ecf_property.xsd'),
                                     TRUE,
                                     TRUE,
                                     FALSE);
_3) this is an example of XML file to reproduce the error: _
<P_WAFERLIST xmlns="http://portal.xxx.com/xsd_schemadefinitions/ecf/prop">
  <WAFER COMPONENT_ID="C11026W01PE6" SUBQTY="22500" STATE="SPLIT">
    <PARAMETERS>
      <PARAMETER NAME="PARAMETER">PARA1_VALUE</PARAMETER>
      <PARAMETER NAME="PARAMETER">PARA2_VALUE</PARAMETER>
      <PARAMETER NAME="PARAMETER">PARA3_VALUE</PARAMETER>
    </PARAMETERS>
  </WAFER>
  <WAFER COMPONENT_ID="C11026W02PH1" SUBQTY="21700" STATE="SPLIT">
    <PARAMETERS>
      <PARAMETER NAME="PARAMETER">PARA1_VALUE</PARAMETER>
      <PARAMETER NAME="PARAMETER">PARA2_VALUE</PARAMETER>
      <PARAMETER NAME="PARAMETER">PARA3_VALUE</PARAMETER>
    </PARAMETERS>
  </WAFER>
  <WAFER COMPONENT_ID="C11026W05PG7" SUBQTY="24300" STATE="PRESENT">
    <PARAMETERS>
      <PARAMETER NAME="PARAMETER">PARA1_VALUE</PARAMETER>
      <PARAMETER NAME="PARAMETER">PARA2_VALUE</PARAMETER>
      <PARAMETER NAME="PARAMETER">PARA3_VALUE</PARAMETER>
    </PARAMETERS>
  </WAFER>
</P_WAFERLIST>
_4) and it is an example of code to reproduce the error: _
         //P_XML is of type XMLTYPE and contains the sample XML 
         l_info := P_XML.isSchemaValid ('http://portal.xxx.com/xsd_schemadefinitions/ecf/prop', 'P_WAFERLIST');
         //l_info = 1 --> as far as good...
         P_XML := P_XML.createSchemaBasedXML ('http://portal.xxx.com/xsd_schemadefinitions/ecf/prop');
         //No error until now
         P_XML.schemaValidate();
         //Performing the schema validation causes the error:
         //ORA-30937: No schema definition for 'COMPONENT_ID' (namespace '##local') in parent '/P_WAFERLIST/WAFER[1]'
I really have no idea what is the problem and why the schemaValidate() procedure causes an error :-( The basic version is 10g

I would be grateful for any help!
Mike BR

Published by: ups_mike on December 3, 2010 05:07

Published by: mdrake on December 3, 2010 08:05
Add formatting tags... Please try and examples of format in the future

If you change the attributeFormDefault setting in the schema, it seems to avoid the bug. I don't know if it's a work of viaable around in your case, but you expliciy showing the qualities of each attribute, then the default value need not matter.

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> set echo on
SQL> spool testcase.log
SQL> --
SQL> connect sys/oracle as sysdba
Connected.
SQL> --
SQL> set define on
SQL> set timing on
SQL> --
SQL> def USERNAME = XDBTEST
SQL> --
SQL> def PASSWORD = &USERNAME
SQL> --
SQL> -- def XMLDIR = &1
SQL> --
SQL> def USER_TABLESPACE = USERS
SQL> --
SQL> def TEMP_TABLESPACE = TEMP
SQL> --
SQL> drop user &USERNAME cascade
  2  /
old   1: drop user &USERNAME cascade
new   1: drop user XDBTEST cascade

User dropped.

Elapsed: 00:00:00.39
SQL> grant create any directory, drop any directory, connect, resource, alter se
ssion, create view to &USERNAME identified by &PASSWORD
  2  /
old   1: grant create any directory, drop any directory, connect, resource, alte
r session, create view to &USERNAME identified by &PASSWORD
new   1: grant create any directory, drop any directory, connect, resource, alte
r session, create view to XDBTEST identified by XDBTEST

Grant succeeded.

Elapsed: 00:00:00.03
SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespa
ce &TEMP_TABLESPACE
  2  /
old   1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tabl
espace &TEMP_TABLESPACE
new   1: alter user XDBTEST default tablespace USERS temporary tablespace TEMP

User altered.

Elapsed: 00:00:00.00
SQL> connect &USERNAME/&PASSWORD
Connected.
SQL> --
SQL> -- create or replace directory XMLDIR as '&XMLDIR'
SQL> -- /
SQL> var SCHEMAURL1    varchar2(256)
SQL> VAR XMLSCHEMA1    CLOB;
SQL> VAR INSTANCE1     CLOB;
SQL> --
SQL> set define off
SQL> --
SQL> alter session set events='31098 trace name context forever'
  2  /

Session altered.

Elapsed: 00:00:00.00
SQL> begin
  2    :SCHEMAURL1:= 'http://portal.xxx.com/xsd_schemadefinitions/ecf/prop';
  3    :XMLSCHEMA1 :=
  4  '
  5  
  6    
  7      
  8        
  9          
 10            
 11              
 12                
 13                  
 14                    
 15                      
 16                        
 17                          
 18                            
 19                              
 20                            
 21                          
 22                        
 23                      
 24                    
 25                  
 26                
 27              
 28              
 29              
 30              
 31            
 32          
 33        
 34      
 35    
 36  ';
 37    :INSTANCE1 :=
 38  '

 39    
 40      
 41        PARA1_VALUE
 42        PARA2_VALUE
 43        PARA3_VALUE
 44      
 45    
 46    
 47      
 48        PARA1_VALUE
 49        PARA2_VALUE
 50        PARA3_VALUE
 51      
 52    
 53    
 54      
 55        PARA1_VALUE
 56        PARA2_VALUE
 57        PARA3_VALUE
 58      
 59    
 60  ';
 61  end;
 62  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.00
SQL> set define on
SQL> --
SQL> declare
  2    V_XML_SCHEMA xmlType := XMLType(:XMLSCHEMA1);
  3  begin
  4    DBMS_XMLSCHEMA.registerSchema
  5    (
  6      SCHEMAURL        => :SCHEMAURL1,
  7      SCHEMADOC        => V_XML_SCHEMA,
  8      LOCAL            => TRUE,
  9      GENBEAN          => FALSE,
 10      GENTYPES         => TRUE,
 11      GENTABLES        => FALSE,
 12      ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
 13    );
 14  end;
 15  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.64
SQL> declare
  2    V_XML XMLTYPE := XMLType(:INSTANCE1).createSchemaBasedXML (:SCHEMAURL1);
  3  begin
  4    V_XML.schemaValidate();
  5  end;
  6  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.02
SQL>

Published by: mdrake on December 3, 2010 08:18

Tags: Database

Similar Questions

  • Get all the details for xmltype.schemavalidate errors LSX

    I was wondering if there is a way to see all the details of LSX xmltype.schemavalidate errors.

    For example...

    ORA-31154: invalid XML document

    ORA-19202: an error has occurred in the processing of XML

    LSX-00320: missing required < all >

    .. .is a frustrating level of detail to receive when no doubt the parser is aware of what elements are missing.

    I am aware that XMLSpy and other tools give this level of detail, but I would really like to be able to announce this in Oracle.

    There is not much longer to wait, I'm afraid.

    Maybe the level of detail has been improved on 12.1 but I do not know, I have not yet checked.

    Other classes of validation errors (such as invalid enum element, incompatibility of model, number of occurrences) reported however with the necessary details.

  • A parameter of xmltype extraction problem

    Hello
    I am using oracle 11g and I am trying to use an xmltype as input to an SP parameter, here's my SP:

    create or replace PROCEDURE ABC
    (FE_Param OF XMLType)
    AS
    BEGIN
    I'm IN
    (
    SELECT XMLTYPE. EXTRACT (VALUE (a),
    ' Root/FE_ID/text()').getstringval (LIKE FE_ID)
    TABLE
    (XMLSEQUENCE (FE_Param.EXTRACT
    ("/ FEData/Root")
    ) ) a )

    LOOP
    INSERT INTO table1
    VALUES (i.FE_ID);
    END LOOP;

    The XML parameter looks like this:
    <? XML version = "1.0" encoding = "utf - 8"? >
    < FEData >
    < root > < FE_ID > 900000031 < / FE_ID >
    < FE_ID > 900000032 < / FE_ID > < FE_ID > 900000050 < / FE_ID > < / root > < / FEData >

    Triple post - what's happened? :-)

    Published by: Kim Berg Hansen on August 22, 2011 16:47

  • How to pass parameter in the function extract (for XMLTYPE)

    I have a table with XMLTYPE field xml_column PROBLEMXML. In this column, there are many deffinitions for the problem. There is no amount deffinitions max and there can be no definition at all. I need to return all the definitions of all the problems a string wirh separate definitions by '; '.

    Query
    SELECT extract (prob. Def,'/definitions/definition[1]/@var'). ';'|| excerpt (prob. Def,'/definitions/definition[2]/@var')
    OF PROBLEMXML j.
    XMLTABLE)
    "/ problem.
    PASSAGE j.xml_column
    Probid VARCHAR COLUMNS (31) PATH ' / problem/@id',
    Prob def XMLTYPE PATH ' / problem/definitions ")
    where PROBLEM_ID = 1;
    Returns exactly what I want one; m.
    But
    declare
    my_variable varchar2 (2000): = null;
    number of N1;
    number of N2;
    Start
    N1: = 1;
    N2: = 2;
    SELECT extract (prob. Def,'/definitions/definition[N1]/@var'). '|'|| excerpt (prob. Def,'/definitions/definition[N2]/@var') in my_variable
    OF ETL_PROBLEMXML_STG_T j.
    XMLTABLE)
    "/ problem.
    PASSAGE j.xml_column
    Probid VARCHAR COLUMNS (31) PATH ' / problem/@id',
    Prob def XMLTYPE PATH ' / problem/definitions ")
    where PROBLEM_ID = 1;
    dbms_output.put_line ($my_var);
    end;
    Returns null.
    Is there a way to switch the setting to extract the function?

    You have string literal death of n1 and n2. Note the change to select it.

    DECLARE
      my_var VARCHAR2(2000) := NULL;
      n1     NUMBER;
      n2     NUMBER;
    BEGIN
      n1 := 1;
      n2 := 2;
      SELECT extract(prob.def, '/Definitions/Definition[' || n1 || ']/@var') || '|' ||
             extract(prob.def, '/Definitions/Definition[' || n2 || ']/@var')
        INTO my_var
        FROM etl_problemxml_stg_t j,
             xmltable('/problem' passing j.xml_column columns probid VARCHAR(31) path '/problem/@id',
                      def xmltype path '/problem/Definitions') prob
       WHERE problem_id = 1;
      dbms_output.put_line(my_var);
    END;
    

    Published by: RPuttagunta on December 13, 2010 09:18

  • Display the error when the xml document is not valid against the schema

    Hello

    I'm using isChemaValid() in a way that, to determine if the xml document is valid against the xml schema.

    This function returns only 0 or 1, and I want to display the error and the line number if the xml is not valid.

    How can I achieve this?

    Thanks in advance,

    Elad

    Use the XMLType schemaValidate() method. It will throw an exception whose message contains the validation error.

    Get a number of 'line' is not sensible as XML is concerned.

  • XML with XSD validation when there is more than one XSD.

    Hello

    I need to validate an XML against a set of xsd.

    I am aware that, when there is a single XSD to compare, it is possible to compare using xmlDoc.schemaValidate () with xmlDoc and xmlSchema.

    But in my case, there is more than one XSD against which I need to compare the XML code.

    My main XSD has the statement as mentioned below.

    " < xs: import namespace = ' http://www.w3.org/1999/xxxx "schemaLocation ="xxxx.xsd"/ > "

    " < xs: import namespace = ' http://www.w3.org/1999/02/yyyy "schemaLocation ="yyyy.xsd"/ > "

    I don't know how to handle this situation.

    Please, help me!

    Thank you

    Vicky

    Hi Vicky,

    This situation is not different, just validate the main schema.

    But, to use the XMLType schemaValidate method, you must save the schema in the database (via the DBMS_XMLSCHEMA API).

    If the main schema contains imports then these referenced schemas must be saved too.

    To sum up: register all 3 patterns in their order of dependency, then you will be able to validate your XML with the main XSD code.

    () dbms_xmlschema.registerSchema

    schemaURL-online , for example 'xxxx.xsd'

    schemaDoc =>

    local-online true

    genTypes-online fake

    genTables-online fake

    enableHierarchy-online dbms_xmlschema. ENABLE_HIERARCHY_NONE

    ) ;

  • Mahesh

    Hi all

    I want to create an XML based on xsd, and then I want to validate the same XML with xsd

    Please provide some information about it.

    Everything in the PLSQL code

    Mahesh

    47e033bd-D313-47bd-9372-871358ce3c3e wrote:

    If I want to store it as xml and also the xsd validation, which would be the best way please suggest a few ideas

    I already showed you how do it.

    1. Generate your XML document from your base tables using SQL/XML (XMLElement, XMLAttributes, XMLAgg etc..)
    2. Validate the resultant XMLType schemaValidate() method

    Which of these two points you do not understand?

  • Validate the XML: DateTime-&gt; ORA-01830 / 01858

    Hello

    I'm trying to parse an XML document that contains an element which is defined as DateTime
    <CreDtTm>2012-06-02T09:30:47.000Z</CreDtTm>
    The xsd is as follows
    <xs:element name="CreDtTm" type="ISODateTime"/>
    ...
    <xs:simpleType name="ISODateTime">
      <xs:restriction base="xs:dateTime"/>
    </xs:simpleType>
    For me the format looks OK, but I get
    ORA-01830: date format picture ends before converting entire input string
    I found http://stackoverflow.com/questions/6370035/why-dbms-xmlschema-fails-to-validate-a-valid-xsdatetime/6382096#6382096
    and changed the schema:
    <xs:simpleType name="ISODateTime" xdb:SQLType="TIMESTAMP WITH TIME ZONE">
    Now, I get
    ORA-01858: a non-numeric character was found where a numeric was expected
    So I tried
    ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT='yyyy-mm-dd"T"hh24:mi:ss.ff3"Z"';
    and tested
    select systimestamp from dual;
    
    SYSTIMESTAMP
    ----------------------------------------
    2012-07-27T10:52:05.860Z
    The exact format, but still ORA-01858.

    Validation is performed with
    DECLARE
      xmldoc XMLTYPE;
    DECLARE
      xmldoc XMLTYPE;
    BEGIN
        xmldoc := XMLTYPE(q'[<?xml version="1.0" encoding="UTF-8"?>
          ...
          <CreDtTm>2012-06-02T09:30:47.000Z</CreDtTm>
          ...]');
        xmldoc := xmldoc.createSchemaBasedXML('http://...xsd');
        XMLTYPE.schemaValidate(xmldoc);
    END;
    Anyone know where I am going wrong?
    select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for HPUX: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Concerning
    Marcus

    Published by: Marwim on 27.07.2012 11:45
    Addition of the db version

    Hi Marcus,

    This one is interesting.
    I had already implemented my own example shortly before posting your own, then here's something that works for me:

    BEGIN
    
      dbms_xmlschema.registerSchema(
        schemaURL => 'test_ts.xsd'
      , schemaDoc => 
    
      '
    
      
      
        
      
    '
    
      , local => true
      , genTypes => false
      , genTables => false
      , enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE
      );
    
    END;
    /
    
    SQL> DECLARE
      2    doc xmltype := xmltype('2012-06-02T09:30:47.000Z', 'test_ts.xsd');
      3  BEGIN
      4    doc.schemaValidate();
      5  END;
      6  /
    DECLARE
    *
    ERROR at line 1:
    ORA-30992: error occurred at Xpath /CreDtTm[@SYS_XDBBODY$]
    ORA-01858: a non-numeric character was found where a numeric was expected
    ORA-06512: at "SYS.XMLTYPE", line 354
    ORA-06512: at line 4
    

    OK, same error so far.

    SQL> REM : change from ", " to ".,"
    SQL> ALTER SESSION SET nls_numeric_characters = '.,';
    
    Session altered.
    
    SQL> DECLARE
      2    doc xmltype := xmltype('2012-06-02T09:30:47.000Z', 'test_ts.xsd');
      3  BEGIN
      4    doc.schemaValidate();
      5  END;
      6  /
    
    PL/SQL procedure successfully completed.
    

    Now it's working.

    I know that there is an implicit conversion happening in addition to automatic mapping "dateTime"--> 'TIMESTAMP WITH time ZONE'.
    Documentation, although not very clear, seems to hint in that direction:

    With the help of Z back to indicate the time zone UTC

    XML Schema allows the time zone specified under Z, component to indicate the UTC time zone. When a leaking Z value is stored in a SQL TIMESTAMP WITH time ZONE TIMES column, the time zone is actually stored as + 00:00. Thus, the value retrieved contains the leak + 00:00, not the original Z. For example, if the value in the input XML document is 1973-02-12 T 13: 44:32Z, the output is 1973-02 - 12 T 13: 44:32.000000 + 00:00.

    So I think that Oracle is attempting to expand "2012-06 - 02T 09: 30:47.000Z" at "2012-06 - 02 T 09: + 00:00 30:47.000000"but relying on the NLS configuration session to determine the decimal separator used in the fractional part of timestamp.»

  • Based on two different XSD validation XML table

    Hello

    Is it possible to create a table of validation XML (which will automatically validate the XML with an XSD file) with two XML type column, and the two columns relate other two recorded patterns. My goal is to store the XMl files and validate, but some XMl files are based on XSD1 and some XML files are based on XSD2, I am already registered patterns, now I need to create a table with two type of XML or a column of XML type to validate and store the different XSD base XML files.

    Thanks in advance

    Rizly

    Hello

    something like this:
    Purchase.xsd and purchase2.xsd are a few simple xsd.
    XML validation is performed inside the trigger.
    What follows is a 11.1.0.6

    SQL> create or replace directory xmldir as '/tmp';
    
    Directory created.
    
    SQL>
    SQL> begin
      2   dbms_xmlschema.registerschema(
      3      schemaurl=>'http://xmlns.oracle.com/xdb/purchase'
      4    , schemadoc=>bfilename('XMLDIR','purchase.xsd')
      5    , gentypes=>false
      6    , gentables=>false
      7    , genbean=>false
      8    , owner=>'SCOTT');
      9  end;
     10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> begin
      2   dbms_xmlschema.registerschema(
      3      schemaurl=>'http://xmlns.oracle.com/xdb/purchase2'
      4    , schemadoc=>bfilename('XMLDIR','purchase2.xsd')
      5    , gentypes=>false
      6    , gentables=>false
      7    , genbean=>false
      8    , owner=>'SCOTT');
      9  end;
     10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> create table test_xml(
      2     id number
      3   , xcol  xmltype
      4   , xcol2 xmltype)
      5  xmltype column xcol
      6  element "http://xmlns.oracle.com/xdb/purchase#PurchaseOrder"
      7  xmltype column xcol2
      8  element "http://xmlns.oracle.com/xdb/purchase2#PurchaseOrder2";
    
    Table created.
    
    SQL>
    SQL> create trigger test_xml_trg before insert or update on test_xml for each row
      2  declare
      3   l_xml xmltype;
      4  begin
      5   if :new.xcol is not null then
      6     l_xml := :new.xcol;
      7     xmltype.schemavalidate(l_xml);
      8   end if;
      9
     10   if :new.xcol2 is not null then
     11    l_xml := :new.xcol2;
     12    xmltype.schemavalidate(l_xml);
     13   end if;
     14  end;
     15  /
    
    Trigger created.
    
    SQL>
    SQL> insert into test_xml(id,xcol)
      2  values(1,xmltype('
      3                   1234567890123456789
      4                  '));
    
    1 row created.
    
    SQL>
    SQL> insert into test_xml(id,xcol)
      2  values(1, xmltype('1') );
    values(1, xmltype('1') )
              *
    ERROR at line 2:
    ORA-30937: No schema definition for 'a' (namespace '') in parent '/'
    ORA-06512: at "SYS.XMLTYPE", line 354
    ORA-06512: at "SCOTT.TEST_XML_TRG", line 6
    ORA-04088: error during execution of trigger 'SCOTT.TEST_XML_TRG' 
    
    SQL>
    SQL> insert into test_xml(id, xcol2)
      2  values(1, xmltype('
      3                      1234567890123456789
      4               '));
    
    1 row created.
    
    SQL>
    SQL> insert into test_xml(id, xcol, xcol2)
      2  values(1, xmltype('
      3                      1234567890123456789
      4               ')
      5          ,xmltype('
      6                  1234567890123456789
      7              '));
    
    1 row created.
    
    SQL>
    SQL> --clean
    SQL> drop trigger test_xml_trg;
    
    Trigger dropped.
    
    SQL> drop table test_xml;
    
    Table dropped.
    
    SQL> purge recyclebin;
    
    Recyclebin purged.
    
    SQL> exec dbms_xmlschema.deleteschema('http://xmlns.oracle.com/xdb/purchase',3);
    
    PL/SQL procedure successfully completed.
    
    SQL> exec dbms_xmlschema.deleteschema('http://xmlns.oracle.com/xdb/purchase2',3);
    
    PL/SQL procedure successfully completed.
    
    SQL> spool off;
    

    Ants

  • XDB. XMLIndex problem and table (XMLSEQUENCE (EXTRACT (xmltype, path))

    Hello
    I have a database of Oracle 11 g Release 11.1.0.6.0 - 64 bit Production With the Real Application Clusters option.

    I feel something strange with an XMLType column.
    I have a table configurator.t_vehicle_configuration (id_vehicle x_configuration NUMBER, XMLType).
    x_configuration is unstructured.

    I created an index on the field of xml in this way:

    CREATE INDEX idx_vehicle_configuration ON configurator.t_vehicle_configuration (x_configuration) INDEXTYPE IS XDB. XMLIndex;

    Then I have a package implementing a function that count nodes in the xml field and its return values

    This does not (return 0 instead of 1):
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    This mode of operation (return 1):
        str_ := '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen';
    
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration,str_))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    As this mode of operation:
        SELECT /*+ NO_XMLINDEX_REWRITE */ count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    And also this way it works:
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="228"]/user[@id="49"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    I sailed a bit on the internet but I have found no help for my problem...
    I guess that's something concerning the substitution on the fly of the variables, which does not work with an index.
    Do you have any suggestions?
    Is there a way that will prevent the rewriting of all the functions?

    Thanks in advance

    First

    On 11.1.0.6.0 Please do not use table (xmlsequence (extract ())) Please use the SQL/XML standard XMLTAble operator...

    SELECT COUNT(*)
       INTO count_
      FROM configurator.v_vehicle_configuration vc,
               XMLTABLE
              (
                  '$XML/vehicleconf/GeoFence/spaceTarget[@id=$ID_SPACE_TARGET]/user[@id=$ID_USER]/alarmwhen'
                  passing vc.x_configuration as "XML",  in_id_space_target as "ID_SPACE_TARGET",  in_id_user as "ID_USER"
               )
         WHERE vc.id_vehicle = in_id_vehicle;
    
        RETURN count_;
    

    2. never generate XPATH strings dynamically (Note XMLTABLE simply will not allow it). It is almost impossible to optimize since in the case escalated, the query may be a function of the processing line, and it leaves the vulnerable application WHO the problems of injection. Earlier versions of XML DB supported the use of string concatenation technique to provide the value of predicate as a method of implementation of the bind variable, but from what I remember, this is only implemented and tested for storage relatiion object. Even when workng with storage relational object this technique should not be used in the development of new code n a 10.2.x post database. As far as I know this was not implemented for binary XML / XML INdex since the implementations of XMLQUERY, XMLTable and XMLEXists provided a much more robust implementation and standardized to link the underlying values at query runtime

    If you do not know the XPATH expression until run time please build the complete SQL statement dynamically and run it via EXECUTE IMMEDIATE or DBMS_SQL, then pay attention to injection vunerabilities in your application.

    The fact that you get different results seems to be the result of the previous method of binding of predicates works do not correctly with the XML Index. If the solution I gave above does not work, please fill out a bug and that we can continue the investigation

    Published by: mdrake on February 25, 2011 17:32

  • problem with 'xmltype.existsnode '.

    Hi people,

    I'm trying to download a "fairly simple".xml file in db with below the part of the code, but for some reason any that it does not work :(

    No idea what I am doing wrong?

    XML file:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <BulkExportRootElement xmlns:ns2="http://homeoffice.gov.uk/ immigration/migrant/cas/bulk-cas-common-200903" xmlns="http://homeoffice.gov.uk/ immigration/migrant/cas/bulk-cas-export-200903">
      <ExportFileHeader>
        <BulkExportId>152eec86-d151-4fea-affd-e93ab1d05173</BulkExportId>
        <ReportConstructionDate>2009-09-16</ReportConstructionDate>
      </ExportFileHeader>
      <CASExportData>
        <CASNumber>E4G3AA1A09W0A4</CASNumber>
        <CASStatus>ASSIGNED</CASStatus>
        <LastStatusChanged>2009-09-16</LastStatusChanged>
        <ApplicantId>1010101</ApplicantId>
        <FamilyName>Smith</FamilyName>
        <GivenName>John</GivenName>
        <Nationality>AUS</Nationality>
        <DateOfBirth>
          <ns2:FullDate>1980-02-20</ns2:FullDate>
        </DateOfBirth>
        <PassportTravelDocumentNumber>703121021</PassportTravelDocumentNumber>
        <CourseId>13031</CourseId>
        <CourseCurriculumTitle>Iron Age History</CourseCurriculumTitle>
        <CourseStartDate>2010-01-08</CourseStartDate>
        <ExpectedCourseEndDate>2010-02-13</ExpectedCourseEndDate>
      </CASExportData>
      <CASExportData>
        <CASNumber>E4G3AA1A09V0A7</CASNumber>
        <CASStatus>USED</CASStatus>
        <LastStatusChanged>2009-09-16</LastStatusChanged>
        <ApplicantId>1010102</ApplicantId>
        <FamilyName>March</FamilyName>
        <GivenName>Wi</GivenName>
        <Nationality>AUS</Nationality>
        <DateOfBirth>
          <ns2:FullDate>1983-06-25</ns2:FullDate>
        </DateOfBirth>
        <PassportTravelDocumentNumber>PQ254689</PassportTravelDocumentNumber>
        <CourseId>13031</CourseId>
        <CourseCurriculumTitle>Iron Age History</CourseCurriculumTitle>
        <CourseStartDate>2010-01-08</CourseStartDate>
        <ExpectedCourseEndDate>2010-02-13</ExpectedCourseEndDate>
      </CASExportData>
    </BulkExportRootElement>
    my code:
    declare
        p_aplus_ukba_xml_id number := 671601494;
        l_message clob;
    
        l_xmldoc  clob;
        l_xml  xmltype;
    
        e_cannot_parse exception;
      begin
        select xml
          into l_xmldoc  -- a CLOB, where xml file is stored
        from APLUS_UKBA_XML
        where object_id = p_aplus_ukba_xml_id;
        
        
        l_xml  := xmltype.createxml(l_xmldoc);
        
        dbms_output.put_line('START HEADER');
        
        if xmltype.existsnode(l_xml, 'BulkExportRootElement/ExportFileHeader') = 1 then
          dbms_output.put_line('BulkExportRootElement/ExportFileHeader exists');
          dbms_output.put_line( xmltype.extract(l_xml,'BulkExportRootElement/ExportFileHeader/BulkExportId/text()').getstringval()  );
        else
          dbms_output.put_line('BulkExportRootElement/ExportFileHeader NOT exists!');  
        end if;
        
        -- END;
        update APLUS_UKBA_XML
           set job_id = null, 
               timestamp = sysdate,
               status = 'PROCESSED'
         where object_id = p_aplus_ukba_xml_id;
         
      exception
        when e_cannot_parse then
          l_message := 'ap_ukba_upload.process_xml.e_cannot_parse'||CHR(10)||sqlerrm;
          
          update APLUS_UKBA_XML
          set status     = 'ERROR',
              error_desc = l_message,
              job_id     = null,
              timestamp  = sysdate
          where object_id = p_aplus_ukba_xml_id;
          commit;
          raise_application_error(-20333, 'Cannot parse export file');
        when others then
          l_message := sqlerrm;
         update APLUS_UKBA_XML
          set status     = 'ERROR',
              error_desc = l_message,
              job_id     = null,
              timestamp  = sysdate
          where object_id = p_aplus_ukba_xml_id;
          commit;
          raise;
      end;
    OUTPUT:
    START HEADER
    BulkExportRootElement/ExportFileHeader NOT exists!
    As you can see, output says that there is no such thing as "BulkExportRootElement/ExportFileHeader", but based on the XML file, there are.

    Please advise, as I don't see where is the problem.

    Kind regards
    Tomas

    (I used a similar approach in the various projects and no problem)

    you will have something to hope for... ;)
    Try this pending

    with test as
    (select xmltype (
    '
    
      
        152eec86-d151-4fea-affd-e93ab1d05173
        2009-09-16
      
      
        E4G3AA1A09W0A4
        ASSIGNED
        2009-09-16
        1010101
        Smith
        John
        AUS
        
          1980-02-20
        
        703121021
        13031
        Iron Age History
        2010-01-08
        2010-02-13
      
      
        E4G3AA1A09V0A7
        USED
        2009-09-16
        1010102
        March
        Wi
        AUS
        
          1983-06-25
        
        PQ254689
        13031
        Iron Age History
        2010-01-08
        2010-02-13
      
    ') xmlmsg from dual
    )
    select extract (xmlmsg
                   ,'/BulkExportRootElement/ExportFileHeader/BulkExportId/text()'
                   ,'xmlns:ns2="http://homeoffice.gov.uk/immigration/migrant/cas/bulk-cas-common-200903" xmlns="http://homeoffice.gov.uk/immigration/migrant/cas/bulk-cas-export-200903"'
                   ).getStringVal()
      from test
    
  • Problem with table with XMLTYPE column extractvalue.

    I don't know there is a simple answer, but I have problems
    extract data from a column of xmltype type.
    I have two tables
    descr dab_xml
    Name
    -----------------------------------------------------
    XMLTYPE TABLE
    descr dab_test
    Name
    -----------------------------------------------------
    A NUMBER
    NUMBER OF AB
    CLOB DATA
    DATA2 VARCHAR2 (1600)
    MYXML XMLTYPE

    I inserted the Oracle XML purchaseOrder.xml example in the two dab_xml
    and the myxml in dab_test column.

    When I run the following:

    SELECT extractvalue (OBJECT_VALUE, ' / PurchaseOrder/reference "")
    OF dab_xml;

    SBELL-2002100912333601PDT returned

    When I run the present:

    SELECT extractvalue (OBJECT_VALUE, ' / PurchaseOrder/reference "")
    FROM (select dab_test myxml);

    ERROR on line 1:
    ORA-00904: "OBJECT_VALUE": invalid identifier

    Why are the two different?

    Any help will be appreciated.

    Kind regards

    David

    In short, you want to

    SELECT extractvalue(myxml, '/PurchaseOrder/Reference')
    FROM dab_test;
    

    This difference is that for dab_xml, it has no columns defined for the table, so you are [OBJECT_VALUE | http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/pseudocolumns006.htm#sthref830] as an alias for a column does not exist.

    With dab_test, you have a column that contains the XML, you must use this column instead of OBJECT_VALUE name.

  • Excerpt from XMLType problem with different namespaces

    Hello

    I need some advice on how to extract the child element to the XML fragment where the parent namespace differs child name space. I have done the broad research and I've tried several options but have had no success.

    This is fragment plsql sample

    vTheXML: = XMLType ("< GeneratedDocument xmlns ="http://tempuri.org/"> ")

    " < file_name xmlns =" http://services.DPM.com.au/intelledox/ "> Test.pdf < / Filename > .

    (< / GeneratedDocument > ');

    Below successfully returns a GeneratedDocument element (IE any fragment)

    vExtractXML: = vTheXML.extract ('/ GeneratedDocument ',' xmlns = "http://tempuri.org/"');

    But none of below works. They return null. I do not know how to represent the different namespaces in the function call retrieves XMLType

    vExtractXML: = vTheXML.extract ('/ GeneratedDocument/filename ',' xmlns = "http://services.dpm.com.au/intelledox/"');

    vExtractXML: = vTheXML.extract ('/ GeneratedDocument/filename ',' xmlns = "http://tempuri.org/"xmlns ="http://services.dpm.com.au/intelledox/"');

    vExtractXML: = vTheXML.extract ('/ GeneratedDocument/filename ',' xmlns = "http://tempuri.org/"');

    Below works, but would ideally use more precise criteria of XPath

    vExtractXML: = vTheXML.extract ("/ / filename ',' xmlns ="http://services.dpm.com.au/intelledox/"'");

    Thank you

    Hello

    Of course, you cannot declare two namespaces by default in the namespace mapping, use at least a prefix to distinguish them:

    vExtractXML: = vTheXML.extract ('/ GeneratedDocument / ns1:FileName ',' xmlns = "http://tempuri.org/" xmlns:ns1 = "http://services.dpm.com.au/intelledox/"');

    (NB: extract and extractvalue, etc. have been deprecated in 11.2)

  • Multilingual in XMLTYPE problem

    Hi Experts,

    My database as follows:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for Linux: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    WE8ISO8859P1 NLS_CHARACTERSET

    IM XML storage in one of the table in my database in the XMLTYPE column. But when my XML node contains a multilingual value (Ex: Chinese) is to show the Junk value. Is it possible to store it's?

    INSERT IN web_xml_file (file_no, web_file_data, record_status, user_created, created) VALUES (v_file_no, xmltype.createxml (p_in_xml), "UNP", USER, SYSDATE);

    NUMBER FILE_NO,

    XMLTYPE OF the WEB_FILE_DATA,

    RECORD_STATUS VARCHAR2 (3),

    MSG_ERREUR VARCHAR2 (4000).

    USER_CREATED VARCHAR2 (50).

    DATE OF CREATION,

    USER_CHANGED VARCHAR2 (50).

    MODIFICATION DATE

    The following seems to work but be aware, that this is still a hack and certainly not bulletproof.

    The best way to handle this is to have the AL32UTF8 migrated db character set, or the external analysis.

    Select utl_i18n.raw_to_nchar (utl_i18n.string_to_raw (skywardsnumber), 'AL32UTF8') as skywardsnumber

    utl_i18n.raw_to_nchar (utl_i18n.string_to_raw (title), "AL32UTF8") as the title

    utl_i18n.raw_to_nchar (utl_i18n.string_to_raw (firstname), "AL32UTF8") as a first name

    utl_i18n.raw_to_nchar (utl_i18n.string_to_raw (familyname), "AL32UTF8") as familyname

    from xmltable ('/ data/passengerinformation ')

    from xmltype (dbms_xslprocessor.read2clob ('XML_DIR', 'multi.xml', nls_charset_id('CHAR_CS')))

    path of columns skywardsnumber varchar2 (100) 'skywardsnumber '.

    , title varchar2 (100) path 'title '.

    , path of varchar2 (100) firstname "firstname".

    , familyname varchar2 (100) path "familyname".

    ) x ;

    Explanations:

    (1) I put your example of XML in a file saved with UTF-8 encoding and it shipped to a database directory (DOC_DIR).

    (2) I have access to the file as CLOB using DBMS_XSLPROCESSOR.read2clob, and (here's the trick) considering the file in the db character set (mine was WE8ISO8859P15). Accordingly, all multibyte characters are converted into single-byte characters in the DB character set.

    (3) I use the XMLType constructor to construct an instance of XMLType off the CLOB and analyze with XMLTABLE.

    (4) who gives me four columns which I then convert into sequences of bytes (utl_i18n.string_to_raw) and finally to NCHAR (utl_i18n.raw_to_nchar) by specifying the encoding of the original file.

  • Problem in the select statement on the xmltype table

    Hello

    I have a table xmltype with a type of object/atrribute to the CLOB data type. When I now do a query, I get the error ORA-22835 - what goes wrong? The data type of the attribute of the source and the declared variable is CLOB.
    DECLARE
      vFoto  CLOB;
    BEGIN
      SELECT SUBSTR(pe.foto_pass, 1, 100) INTO vFoto
        FROM fp_epass_pass_antraege pa
           , XMLTABLE('/PassAntrag'
             PASSING pa.sys_nc_rowinfo$
             COLUMNS antrag     XMLTYPE PATH '/PassAntrag/Antrag'
                   , person     XMLTYPE PATH '/PassAntrag/Person') paan
           , XMLTABLE('/'
             PASSING paan.antrag
             COLUMNS uuid       VARCHAR2(38) PATH 'UUID') an
           , XMLTABLE('/'
             PASSING paan.person
             COLUMNS foto_pass  CLOB PATH 'FotoPass') pe
             WHERE an.uuid = '84239536904120131828493266953553299522';
    END;
    Thanks in advance.

    Kind regards
    Martin

    Martin1 wrote:
    But now I have to decode the base64binary data.

    The BLOB that results already contains the decoded base64 data.

    Now, given your sample, it seems the decoded content (or at least a part of it) contains data base64 again. Is this right?

Maybe you are looking for

  • Google vs Apple pics photos

    I recently heard about the Photos of Google app, and I was wondering if it is the same as the pictures Apple app?

  • Cannot access bios or UEFI in laptop upgraded

    System HP pavilion dv6-2190us original windows 7 64 bit operating system upgrade to windows install clean 8.1 found and updated all the drivers victory entirely 8.1 update trying to enter in the settings of the uefi... no luck trying to enter in the

  • Windows image acquisition

    I can scan is no longer on my canon D480 image class. I get the message "windows could not start Windows Image Acquisition (wia) service on computor local e.» Error 1068 the dependency service or group could start

  • Air of the iPad at all lights is also full of its battery

    Air of the iPad at all lights is also full of its battery

  • Receive errors from BSOD and unable to start Windows.

    Unable to boot vista receive bsod: (1) irql not less or equal with stop 0xA. 2 memory management) with stop 0x1A, (3) no location of battery more irp with don't stop 0 x 35 the computer is Dell I tried to go back to the factory default - still not go