Comparison of XPath to a node empty in xmltable oddity

Hello

I'm on 11.2.0.3 and trying to figure out if I can do a comparison logic in my XMLTABLE. I thought I'd seen pretty much sussed, except when it came to compare to an empty node. Then things began to get weird when I was trying to work where my test went wrong.

So it works:

Select x.*
from xmltable (' / has "passer-by xmltype (" < a > < b > < c > < d > < / d > < e > vale < /e > < / c > < / b > < / has > ' "))
number of columns c_val_check path "count(b/c[d=""])."
d_val_check path number 'count(b/c[e="vale"])') x;

C_VAL_CHECK D_VAL_CHECK
----------- -----------
1           1

The same way:

with sd as (select 1 id, xmltype ("< a > < b > < c > < d > < / d > < e > vale < /e > < / c > < / b > < / has > '") double col1)
Select x.*
the SD,.
XMLTable ('/ ' in passing sd.col1)
number of columns c_val_check path "count(b/c[d=""])."
d_val_check path number 'count(b/c[e="vale"])') x;

C_VAL_CHECK D_VAL_CHECK
----------- -----------
1           1

But it does not work on the d = "" test, even if the two xmls are the same as in the previous two examples: "

with sd as (select 1 id, xmltype ("< a > < b > < c > < d > < / d > < e > vale < /e > < / c > < / b > < / has > '") col1 in double union all)
Select 2 id, xmltype ("< a > < b > < c > < d > < / d > < e > vale < /e > < / c > < / b > < / has > '") double col1)
Select sd.id, x.*
the SD,.
XMLTable ('/ ' in passing sd.col1)
number of columns c_val_check path "count(b/c[d=""])."
d_val_check path number 'count(b/c[e="vale"])') x;

ID C_VAL_CHECK D_VAL_CHECK
---------- ----------- -----------
1           0           1
2           0           1

And if I change the < c > < e > value to something different, which does not help also:

with sd as (select 1 id, xmltype ("< a > < b > < c > < d > < / d > < e > vale < /e > < / c > < / b > < / has > '") col1 in double union all)
Select 2 id, xmltype ("< a > < b > < c > < d > < / d > < e > val0 < /e > < / c > < / b > < / has > '") double col1)
Select sd.id, x.*
the SD,.
XMLTable ('/ ' in passing sd.col1)
number of columns c_val_check path "count(b/c[d=""])."
d_val_check path number 'count(b/c[e="vale"])') x;

ID C_VAL_CHECK D_VAL_CHECK
---------- ----------- -----------
1           0           1
2           0           0

What I am doing wrong? I guess I am doing something stupid here, and is not an Oracle bug!

Hello

I guess I am doing something stupid here, and is not an Oracle bug!

Well, maybe it is.

To use the indicator NO_XML_QUERY_REWRITE works around the problem, as does using a slightly different predicate:

SQL > with sd as (select 1 id, xmltype ('vale') double col1)

2 Union all the

3 select 2 id, xmltype ('vale') double col1

4              )

5 Select sd.id, x.*

6 of the sd,

7 xmltable ('/ ' in passing sd.col1)

path number 8 columns c_val_check ' count (b/c [not (d / text ())]). "

9 number of d_val_check path 'count(b/c[e="vale"])') x;

ID C_VAL_CHECK D_VAL_CHECK

---------- ----------- -----------

1           1           1

2           1           1

Tags: Database

Similar Questions

  • XPath to capture nodes between two nodes

    Hi all

    I met a problem a seemingly simple challenge of mine.

    I have the following xml code.

    Basically, I would like to capture the text between the begin-end blocks

    <? XML version = "1.0" encoding = "UTF-8"? >

    < document >

    < body >

    < paragraph >

    < run >

    < fld type = 'start' / >

    < / run >

    < run >

    < text > SAMPLE < / text >

    < / run >

    < run >

    < text > < / text >

    < / run >

    < run >

    < text > FIELD < / text >

    < / run >

    < run >

    < fld type = 'end' / >

    < / run >

    < run >

    < text > TEXT UNWANTED SOME < / text >

    < / run >

    < / paragraph >

    < paragraph >

    < run >

    < fld type = 'start' / >

    < / run >

    < run >

    < text > SAMPLE < / text >

    < / run >

    < run >

    < text > < / text >

    < / run >

    < run >

    < text > Field2 < / text >

    < / run >

    < run >

    < fld type = 'end' / >

    < / run >

    < run >

    < text > TEXT UNWANTED SOME < / text >

    < / run >

    < run >

    < fld type = 'start' / >

    < / run >

    < run >

    < text > SAMPLE < / text >

    < / run >

    < run >

    < text > < / text >

    < / run >

    < run >

    < text > FIELD3 < / text >

    < / run >

    < run >

    < fld type = 'end' / >

    < / run >

    < / paragraph >

    < / body >

    < / document >

    So far, what I came up with is:

    WITH temp AS (
    SELECT 
           XMLTYPE ('<?xml version="1.0" encoding="UTF-8"?>
                      <document>
                         <body>
                            <paragraph>
                               <run>
                                  <fld type="begin" />
                               </run>
                               <run>
                                  <text>SAMPLE</text>
                               </run>
                               <run>
                                  <text> </text>
                               </run>
                               <run>
                                  <text>FIELD</text>
                               </run>
                               <run>
                                  <fld type="end" />
                               </run>
                               <run>
                                  <text>SOME UNWANTED TEXT</text>
                               </run>
                            </paragraph>
                            <paragraph>
                               <run>
                                  <fld type="begin" />
                               </run>
                               <run>
                                  <text>SAMPLE</text>
                               </run>
                               <run>
                                  <text> </text>
                               </run>
                               <run>
                                  <text>FIELD2</text>
                               </run>
                               <run>
                                  <fld type="end" />
                               </run>
                               <run>
                                  <text>SOME UNWANTED TEXT</text>
                               </run>
                               <run>
                                  <fld type="begin" />
                               </run>
                               <run>
                                  <text>SAMPLE</text>
                               </run>
                               <run>
                                  <text> </text>
                               </run>
                               <run>
                                  <text>FIELD3</text>
                               </run>
                               <run>
                                  <fld type="end" />
                               </run>
                            </paragraph>
                         </body>
                      </document>') AS xml_template
    FROM dual
    )
    SELECT x.*
      FROM temp
          ,XMLTABLE('//*/paragraph/run[fld/@type="begin"]/following-sibling::run[following-sibling::run[fld/@type="end"]]/text'
                    PASSING temp.xml_template
                    COLUMNS res varchar2(100) PATH '.'
                   )x
    

    Result:

    RES

    SAMPLE

    FIELD

    SAMPLE

    FIELD2

    SOME UNWANTED TEXT

    SAMPLE

    FIELD3

    Unfortunately what I wrote XPath is not good enough, because with regard to the text between the two blocs of start-end it still captures the unwanted text.

    My XPath knowledgege dept unfortunately not so I would appriciate annything you can help me with even an idea could get through on the edge.

    Thank you

    Steve

    Steve,

    XQuery can help in this case:

    SELECT x.*
    FROM temp
       , XMLTABLE('for $begin in /document/body/paragraph/run[fld/@type="begin"]
                   let $end := $begin/following-sibling::run[fld/@type="end"][1]
                   return $begin/following-sibling::run[. << $end]'
           PASSING temp.xml_template
           COLUMNS res varchar2(100) PATH 'text'
         ) x  ;
    

    Explanation:

    This FLWOR expression traverses all nodes 'start' in the document, finds the corresponding node of the 'end' and returns the sequence of "run" nodes follows 'begin' and above 'end '.

    If you want to concatenate all the fragments of text in a block, you can also do it directly, like this:

    for $begin in /document/body/paragraph/run[fld/@type="begin"]
    let $end := $begin/following-sibling::run[fld/@type="end"][1]
    return string-join($begin/following-sibling::run[. << $end]/text, "")
    

    She's going back 3 ranks:

    RES

    -------------

    EXAMPLE OF A FIELD

    SAMPLE FIELD2

    SAMPLE FIELD3

  • XPath provides no node

    Hi gentlemen,

    I'm having trouble reading az XML instance with Java 7 and XPath. The relevant extract from the file is:

    {code}

    <? XML version = "1.0" encoding = "ISO-8859-1? >

    < xmlns:ehd = ehd:ehd "" urn: DHM / 001 ""

    xmlns = "urn: DHM/BOM/001.

    " xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance "

    ehd_version '1.30' = >

    < ehd:header >

    <!--

    ->

    < ehd:id EX = "1100" RT="1.2.276.0.76.3.1.1"/ >

    < ehd:document_type_cd V = "BOM" S = "1.2.276.0.76.5.100' DN ="Stammdatei-Datenannahmestellen"/ >

    < ehd:service_tmr V = "2006-07-01.." / >

    < ehd:origination_dttm V = "2006-05-09" / > <! - Erstellungsdatum der Datei - >

    <!--

    ->

    < ehd:provider >

    < ehd:organization >

    < ehd:id EX = "1.2.276.0.76.3.1.1" RT="1.2.276.0.76"/ >

    < ehd:organization.nm V = "Kassenärztliche Bundesvereinigung" / >

    < ehd:addr >

    < ehd:CNT V = "Deutschland" / >

    < ehd:CTY V = "Berlin" / >

    < ehd:HNR V = "2" / >

    < ehd:ZIP V = "10623" / >

    < ehd:STR V = "Herbert-Lewin-Platz" / >

    < / ehd:addr >

    " < ehd:telecom V = ' http://www.KBV.de "/ > "

    < / ehd:organization >

    < / ehd:provider >

    <!--

    ->

    < ehd:interface >

    < ehd:id EX = "19441" RT="1.2.276.0.76.5.109"/ >

    < ehd:interface.nm V = "BOM" / >

    < ehd:version V = '1.07' / >

    < / ehd:interface >

    < / ehd:header >

    < / ehd:ehd >

    {code}

    And here is the very short program to read an attribute:

    {code}

    import java.io.File;

    import java.io.FileInputStream;

    to import java.io.FileNotFoundException;

    import java.io.IOException;

    import java.io.BufferedReader;

    import java.io.FileReader;

    Import javax.xml.parsers.DocumentBuilder;

    Import javax.xml.parsers.DocumentBuilderFactory;

    Import javax.xml.parsers.ParserConfigurationException;

    Import javax.xml.xpath.XPath;

    Import javax.xml.xpath.XPathConstants;

    Import javax.xml.xpath.XPathExpression;

    Import javax.xml.xpath.XPathExpressionException;

    Import javax.xml.xpath.XPathFactory;

    Import javax.xml.namespace.NamespaceContext;

    Import org.xml.sax.InputSource;

    to import org.W3C.DOM.document;

    Import org.w3c.dom.Node;

    Import org.w3c.dom.NodeList;

    Import org.xml.sax.SAXException;

    public class xpath {}

    Public Shared Sub main (String [] args) {}

    try {}

    InputSource inputSource = new InputSource ("sdda_01.07_kbv.xml");

    DocumentBuilderFactory plant = DocumentBuilderFactory.newInstance ();

    factory.setNamespaceAware (true);

    DocumentBuilder builder = factory.newDocumentBuilder ();

    Document document = builder.parse (inputSource);

    XPath xpath is XPathFactory.newInstance () .newXPath ();.

    String expr = "/ ehd:ehd/ehd:header/ehd:id/@EX/text()";

    Result of NodeList = (NodeList) xpath.evaluate (expr, inputSource, XPathConstants.NODESET);

    for (int i = 0; i < = result.getLength (); i ++)

    System.out.println (result. Item (i) .getNodeName ());

    }

    catch (Exception e) {}

    e.printStackTrace ();

    }

    }

    }

    {code}

    The program compiles fine, but it offers zero nodes. What can be my fault? Please help if you can. The program pulled an IBM site help programmers - I've changed it according to my needs.

    Thank you in advance, best regards

    Miklós Herboly

    Thank you very much. Has been very helpful.

  • Empty query XMLTABLE results

    I can successfully submit the SOAP request, retrieve the expected answer, store the answer in the column of XMLTYPE table but attempt to stored query XML using XMLTABLE response returns 0 rows.  I looked through other forum on this subject entries, suspect the problem, it's something simple/syntactic, have tried many things to fix, but without success.   Any help would be greatly appreciated.   I tried to provide relevant details below.   Thanks in advance!

    Create the table with a column of type XMLTYPE to hold the SOAP call response:

    CREATE TABLE unfilled_ss

    (

    ID NUMBER,

    XMLTYPE data

    );

    Insert line in table created above with the answer of the function 'soap_call' as the value of the column of type XMLTYPE data:

    insert into unfilled_ss

    Select

    2,

    () soap_call

    ' < wsc:search >

    < arg0 >

    system of < user name > < / username >

    password <>systempassword < / password >

    <>criteria

    < DmsShipL and vacuum >

    < ShipmentHeader-ShipDate > > 10/07/2015 = < / ShipmentHeader-ShipDate >

    < ItemWarehouseMaster stock_item > Y < / ItemWarehouseMaster-stock_item >

    the territory < CustomerMaster > LMHS. CFHA; SMHS < / CustomerMaster-territory >

    < / DmsShipL and empty >

    < / criteria >

    < LignesMax > 2 < / LignesMax >

    < / arg0 >

    < / wsc:search > ',

    ' http://elite-app.leesar.com/prod_841/WS/WmsWebService ',

    ' http://elite-app.leesar.com/prod_841/WS/WmsWebService '

    )

    Double;

    Query the table above showing characters of the response XML "soap_call", inserted in the column of type XMLTYPE data:

    SELECT id, substr(data,1,160) 'FIRST_FEW_CHARS_OF_XMLDOC' from unfilled_ss where id = 2;

    ID FIRST_FEW_CHARS_OF_XMLDOC

    ---------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------

    " 2 < envelope soap: xmlns:soap = ' http://schemas.xmlsoap.org/SOAP/envelope/ ">                                                                                          

    < soap: Body >

    < ns2:searchResponse xmlns:ns2 = "wsclient.wms.tecsys.com" >

    < return >

    Here's value for the column 'DATA' type response representing XMLTYPE SOAP appeal referenced above in full:

    " < envelope soap: xmlns:soap = ' http://schemas.xmlsoap.org/SOAP/envelope/ ">

    < soap: Body >

    < ns2:searchResponse xmlns:ns2 = "wsclient.wms.tecsys.com" >

    < return >

    < status >

    < code > 0 </postcode >

    < description > success < / description >

    < timestamp > 2015-07-10 10:45:16 < / timestamp >

    < / status >

    <>criteria

    < DmsShipL and vacuum >

    < ShipmentHeader-ShipDate > > 10/07/2015 = < / ShipmentHeader-ShipDate >

    < ItemWarehouseMaster stock_item > Y < / ItemWarehouseMaster-stock_item >

    the territory < CustomerMaster > LMHS. CFHA; SMHS < / CustomerMaster-territory >

    < / DmsShipL and empty >

    < / criteria >

    < LignesMax > 2 < / LignesMax >

    < result >

    < DmsShipL and vacuum >

    < ShipmentHeader-open > 1 < / open ShipmentHeader >

    < > 01 warehouse < / warehouse >

    < pps_num > 178625 < / pps_num >

    < ShipmentHeader DateAndTimePpsWasPrinted > 2015-07-09 09:31:03 < / ShipmentHeader-DateAndTimePpsWasPrinted >

    < LineNumber > 1 < / LineNumber >

    < KitComponentLineNumber > 0 < / KitComponentLineNumber >

    < element > 2002686 < / Item >

    < AllocatedQuantity > 6,000 < / AllocatedQuantity >

    < QuantityShippedInSellingUom > 0.000 < / QuantityShippedInSellingUom >

    < QuantityShipped > 0.000 < / QuantityShipped >

    < AssetItemQuantityReturned > 0.000 < / AssetItemQuantityReturned >

    < SellingUom > PK < / SellingUom >

    < ShipmentHeader-SalesOrderHeader-Order > 181035 < / ShipmentHeader-SalesOrderHeader-Order >

    < Client-SalesInvoiceHeader-ShipmentHeader > 355000 < / ShipmentHeader-SalesInvoiceHeader-client >

    < SalesOrderHeader-ShipmentHeader-CustomerPo > Lmackin < / SalesOrderHeader-ShipmentHeader-CustomerPo >

    PK < ItemMaster-StockingUom > < / ItemMaster-StockingUom >

    < WarehouseTransfer / >

    < TransferLine-ToWarehouse / >

    < TransferBackorder / >

    < ShipmentLineChargeGrid > 0 | 2254373 < / ShipmentLineChargeGrid >

    < CreatedOn > 2015-07-09 09:31:03 < / CreatedOn >

    TECSYS < CreatedBy > < / CreatedBy >

    < ModifiedOn > 2015-07-09 09:31:03 < / ModifiedOn >

    TECSYS < ModifiedBy > < / ModifiedBy >

    < VersionCounter > 1 < / VersionCounter >

    < / DmsShipL and empty >

    < DmsShipL and vacuum >

    < ShipmentHeader-open > 1 < / open ShipmentHeader >

    < > 01 warehouse < / warehouse >

    < pps_num > 178628 < / pps_num >

    < ShipmentHeader DateAndTimePpsWasPrinted > 2015-07-09 09:31:50 < / ShipmentHeader-DateAndTimePpsWasPrinted >

    < LineNumber > 57 < / LineNumber >

    < KitComponentLineNumber > 0 < / KitComponentLineNumber >

    < element > 2069220 < / Item >

    < AllocatedQuantity > 0.000 < / AllocatedQuantity >

    < QuantityShippedInSellingUom > 0.000 < / QuantityShippedInSellingUom >

    < QuantityShipped > 0.000 < / QuantityShipped >

    < AssetItemQuantityReturned > 0.000 < / AssetItemQuantityReturned >

    < SellingUom > RL < / SellingUom >

    < ShipmentHeader-SalesOrderHeader-Order > 181041 < / ShipmentHeader-SalesOrderHeader-Order >

    < Client-SalesInvoiceHeader-ShipmentHeader > 612000 < / ShipmentHeader-SalesInvoiceHeader-client >

    < SalesOrderHeader-ShipmentHeader-CustomerPo > 417096_612105 < / SalesOrderHeader-ShipmentHeader-CustomerPo >

    RL < ItemMaster-StockingUom > < / ItemMaster-StockingUom >

    < WarehouseTransfer / >

    < TransferLine-ToWarehouse / >

    < TransferBackorder / >

    < ShipmentLineChargeGrid > 0 | 2254481 < / ShipmentLineChargeGrid >

    < CreatedOn > 2015-07-09 09:31:50 < / CreatedOn >

    TECSYS < CreatedBy > < / CreatedBy >

    < ModifiedOn > 2015-07-09 09:31:50 < / ModifiedOn >

    TECSYS < ModifiedBy > < / ModifiedBy >

    < VersionCounter > 1 < / VersionCounter >

    < / DmsShipL and empty >

    < / result >

    dms_ship_l.unfilled < viewName > < / viewName >

    < / return >

    < / ns2:searchResponse >

    < / soap: Body >

    < / envelope soap: >

    Here's my problem - when I try to use XMLTABLE at end of the contents of the request of the column 'DATA' as query tabular data, completed without error but no lines are returned:

    with xml_table_data as

    (

    SELECT x.*

    Of e unfilled_ss,.

    XMLTABLE)

    xmlnamespaces ('http://schemas.xmlsoap.org/soap/envelope' as "SOAP", "wsclient.dms.tecsys.com" like "ns2"),

    ' /: soap envelope / soap: Body / ns2:searchResponse / back/result/DmsShipL-empty '

    PASSAGE e.data

    COLUMNS

    Varchar2 (50) warehouse PATH "/ DmsShipL/warehouse empty."

    VARCHAR2 (50) PATH of the pps_num ' / DmsShipL-empty/pps_num, "

    Point varchar2 (30) PATH ' / DmsShipL-vacuum/Item. "

    Varchar2 (50) PATH of the SellingUom ' / DmsShipL-vacuum/SellingUom.

    ) x

    where e.id = 2

    )

    Select count (*)

    of xml_table_data;

    COUNT (*)

    ----------

    0

    Thanks for the detailed test case.

    You have typos in the mapping of namespaces.

    Here's the good:

    XmlNamespaces)

    "http://schemas.xmlsoap.org/soap/envelope/" as "SOAP."

    ' wsclient. wms.tecsys.com' as "ns2.

    )

    SQL> SELECT  x.*
      2  FROM unfilled_ss e
      3     , XMLTABLE(
      4         XMLNamespaces(
      5           'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
      6         , 'wsclient.wms.tecsys.com'  as "ns2"
      7         )
      8       , '/soap:Envelope/soap:Body/ns2:searchResponse/return/result/DmsShipL-Unfilled'
      9         PASSING e.data
     10         COLUMNS
     11           Warehouse  varchar2(50) PATH '/DmsShipL-Unfilled/Warehouse'
     12         , pps_num    varchar2(50) PATH '/DmsShipL-Unfilled/pps_num'
     13         , Item       varchar2(30) PATH '/DmsShipL-Unfilled/Item'
     14         , SellingUom varchar2(50) PATH '/DmsShipL-Unfilled/SellingUom'
     15       ) x
     16  WHERE e.id = 2 ;
    
    WAREHOUSE    PPS_NUM   ITEM     SELLINGUOM
    ------------ --------- -------- -------------
    01           178625    2002686  PK
    01           178628    2069220  RL
    
  • BEA-382505 - action ALSB validate invalid; XPath statement production

    When I tray service proxy on my ALSB, we saw this error, what should I do to solve this problem:

    BEA-382505 - action ALSB validate invalid; Instruction XPath produces no nodes to validate

    Maybe everything simply you run an XPath that returns an empty result, and this cannot be validated if necessary.

    Try to assign the result of your XPath to a variable and save it before you post. If it is empty, then fix your Xpath expression - or avoid the step of validation if the variable is empty. I could be wrong however.

  • Virgins of the nodes and describe queries

    I can't do a post containing my problem. I get a message that "due to the size, this content is blocked".

    When I removed the examples, it worked. I don't know what triggered your spam filter example. I hope that the text below is the logic even without examples.

    -Try again here: deletion of all examples. .

    On other implementations of the SPARQL Protocol, (i.e. Jenas TDB), a DESCRIBE query returns a container model.

    1. the subject resource

    2. all the resources related to the subject to any property.

    3. If the resource found in (2) is an empty node, repeat (1) with this node empty as a subject.

    Except if: to describe this blank node has been done before.

    This ensures that the empty nodes are useful when using describe. If this is not the case, the resulting model is useless. For example, we get the following response (omitted prefixes)

    < removed >

    As you can see, the restrictions on complex OWL, who uses the empty nodes are omitted.

    The same query using SEM GAME gives me, among other things, this line:

    < removed >

    I know that we can use this to create a PL/SQL method that produces iteratively a series of triples by following the bnodes, but I trust Oracle on myself to write this function effectively.

    Is this something you're aware and fixing, or will the task fall to me?

    BR,

    Morten

    Hi Morten,

    This problem has been fixed. Please check that the SR. Jorge has already updated it.

    Thank you

    Zhe

  • OSB: xpath as a result of the XQuery output?

    Hello

    I have a related XML non-schema as input. Value of one of the tags will be 'KEYWORD'.
    I want a dynamic text 'Hello' instead of the KEYWORD.
    From now I convert XML to a string with fn - bea: serialize() and then create a fn: replace.

    Viz:
    Let $received_input: = KEYWORD < C > < D >/< d: > < / c >
    Let $convertedXML: = fn-serialize ($received_input)
    Let $temp_string: = fn:replace($convertedXML,"KEYWORD","hello")
    Let $final_output: = fn - bea:inlinedXML ($temp_string)
    return $final_output

    Now, notice that the xml entry still varies as * < Z > keyword / < z > * or keyword < B > < C > < D >/< d: > < E > keyword < /E > < / c > < / b > or anything, only 'KEYWORD' will be there for you.

    Because xml input varies, I don't have a diagram. What if I want to use to replace action by node contained in the variable received_input? I need to calculate the xpath of the node that has the value = KEYWORD. It is a dynamic calculation of xpath.

    I wonder if there is a feature of xquery that I could use in OSB for this? Basically idea is to contribute a value and function returns the xpath of the node which conntains the value.


    Thanks and greetings
    Patricia Kharwadkar

    Hi Patricia Kharwadkar,.

    You can do what you want using plain xpath...

    $input =

    
    b
    keyword
    d
    keyword
    
    

    $value = "Hello".

    Replace the Xpath = / / * [. = 'keyword'] variable = expression of $input = $value (replace content of the node) will give you...

    
    b
    hello
    d
    hello
    
    

    This works for any schema that the xpath expression is looking for content only.

    I hope this helps...

    See you soon,.
    Vlad

  • Read the column of XMLTYPE with Parent and several child nodes

    Hello

    I have an xmltype column which stores the data in the format below. There is possible that some of the parent node will have several child nodes. I'm not able to extract children nodes. Get the error as a value of type multiset... required singleton...
    I tried the sub query, but it returns only the records from parent with children nodes.

    < CrntRgstns >
    < CrntRgstn empStDt = '2000-08-21' Auth = 'ABCD' regCat = 'BM' u4FlngDt = '2011-05-12' stDt = '2011-11-08' st 'EMPTY' = actvReg = "N" updateTS = "2011-11 - 08T 00: 37:42" >
    < CrntDfcnys / >
    < / CrntRgstn >
    < CrntRgstn empStDt = '2000-08-21' Auth = 'ABCD' regCat = 'BM' u4FlngDt = '2012-01-13' stDt = '2012-01-13' st = 'DÉFICIENT' actvReg = 'Y' updateTS = "2012-01 - 13 T 18: 02:19" >
    < CrntDfcnys >
    < CrntDfcny dfcnyCd = "TEST" exmCd = "M10" createDt = "2012-01-13" / >
    < CrntDfcny dfcnyCd = "TEST" exmCd = "X 40" createDt = "2012-01-13" / >
    < / CrntDfcnys >
    < / CrntRgstn >
    < CrntRgstn empStDt = "2000-08-21" Auth = "XYZ" regCat = "SU" u4FlngDt = '2012-01-13' stDt = '2012-01-13' st = 'DÉFICIENT' actvReg = 'Y' updateTS = "2012-01 - 13 T 18: 02:19" >
    < CrntDfcnys >
    < CrntDfcny dfcnyCd = "TEST" exmCd = "M10" createDt = "2012-01-13" / >
    < CrntDfcny dfcnyCd = "TEST" exmCd = "X 40" createDt = "2012-01-13" / >
    < / CrntDfcnys >
    < / CrntRgstn >
    < / CrntRgstns >

    I tried to use 2 xmltable querys and using the child node of the xmltable 1 as input to xmltable 2. But it returns only the records that has child nodes. But I wanted all the records of CrntRgstn and if no child node CrntDfcnys so that also displays.

    Thank you
    Vinod K

    I tried to use 2 xmltable querys and using the child node of the xmltable 1 as input to xmltable 2. But it returns only the records that has child nodes.

    You're almost there, you just have to do an outer join:

    SQL> select x1.empStDt
      2       , x1.Auth
      3       , x1.regCat
      4       , x2.*
      5  from documents t
      6     , xmltable(
      7         '/CrntRgstns/CrntRgstn'
      8         passing t.xmldoc
      9         columns empStDt date         path '@empStDt'
     10               , Auth    varchar2(30) path '@Auth'
     11               , regCat  varchar2(2)  path '@regCat'
     12               , CrntDfcnys xmltype   path 'CrntDfcnys'
     13       ) (+) x1
     14     , xmltable(
     15         '/CrntDfcnys/CrntDfcny'
     16         passing x1.CrntDfcnys
     17         columns dfcnyCd  varchar2(30) path '@dfcnyCd'
     18               , exmCd    varchar2(3)  path '@exmCd'
     19               , createDt date         path '@createDt'
     20       ) (+) x2
     21  ;
    
    EMPSTDT     AUTH                           REGCAT DFCNYCD                        EXMCD CREATEDT
    ----------- ------------------------------ ------ ------------------------------ ----- -----------
    21/08/2000  ABCD                           BM
    21/08/2000  ABCD                           BM     EXAM                           M10   13/01/2012
    21/08/2000  ABCD                           BM     EXAM                           X40   13/01/2012
    21/08/2000  XYZ                            SU     EXAM                           M10   13/01/2012
    21/08/2000  XYZ                            SU     EXAM                           X40   13/01/2012
     
    

    Note: I have tested the above on 11.2.0.2 and it seems that there is a bug, if we add an outer join on the first XMLTable operator too.
    Normally, the first outer join is not necessary, in order to also test on your version without it.

  • How to find the Xpath

    Please help me find the XPath for these nodes
    <IPAddses>
    <IPAddss><ix>0</ix><addss >124.123.123.330</addss ><desc /></IPAddss>
    <IPAddss><ix>1</ix><addss >124.123.123.331</addss ><desc /></IPAddss>
    <IPAddss><ix>2</ix><addss >124.123.123.332</addss ><desc /></IPAddss>
    <IPAddss><ix>3</ix><addss >124.123.123.333</addss ><desc /></IPAddss>
    <IPAddss><ix>4</ix><addss >124.123.123.334</addss ><desc /></IPAddss>
    <IPAddss><ix>5</ix><addss >124.123.123.335</addss ><desc /></IPAddss>
    <IPAddss><ix>6</ix><addss >124.123.123.336</addss ><desc /></IPAddss>
    <IPAddss><ix>7</ix><addss >124.123.123.337</addss ><desc /></IPAddss>
    <IPAddss><ix>8</ix><addss >124.123.123.338</addss ><desc /></IPAddss>
    <IPAddss><ix>9</ix><addss >124.123.123.339</addss ><desc /></IPAddss>
    </IPAddses>
    in this, I need xpath to obtain the value of her IPS for example for 124.123.123.330 xpath should I use?

    If you want to search for a position on the base (first, second or third IP address or etc.), use one of the options mentioned by Tsuji.
    This is typically used when you want to treat all similarly IP addresses or IP address on a specific position in the list for a reason any.
    Based on your XML XPath correct would be:
    / IPAddses/IPAddss [1] / GOLD/IPAddses/IPAddss [position () = 1] addss / addss for the first IP address, return 124.123.123.330
    / IPAddses/IPAddss [2] / GOLD/IPAddses/IPAddss [position () = 2] addss / addss for the second IP, you will return 124.123.123.332
    and so on.

    Another alternative is the research based on a specific value any order, the values appear in the XML document, which you can use as suggested by Alexandr. This will be used when you need to retrieve an IP address specific, based on the IX.
    The correct XPath expression will be:
    / IPAddses/IPAddss [ix = '0'] / addss for IP where IX = 0, return 124.123.123.330
    / IPAddses/IPAddss [ix = '5'] / addss for IP when IX = 5, you return 124.123.123.335

  • Logical string/Message in VBAI

    Experts AND good day,

    I have a little problem with the logic of the chain. What I mean is that I have two 2 entered string. I have a priority and replace the string. My output message must be what,

    priority message contains. But where priority message is empty, the output message must be the substitution string that is in my example "_".

    Please refer to the image as an attachment. Thank you very much.

    Sincerely,

    Andrei K.

    You can use the functions of the range of comparison to check if it is empty and a chain of backup if the priority of string is empty. See attached screenshot for an example.

    Hope this helps,

    Brad

  • Select all the elements with the same name of XMLTYPE

    Hello

    I have the following xml code stored in the XMLTYPE column:

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  -->
    <!-- 2016-01-02T23:09:52 -->
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8f749217-51eb-4c79-9b11-5a3e11b5b1b4">
        <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="MyXE_ssh"/>
        <queryString>
            <![CDATA[select * from dept where deptno=10]]>
        </queryString>
        <field name="DEPTNO" class="java.math.BigDecimal"/>
        <field name="DNAME" class="java.lang.String"/>
        <background>
            <band splitType="Stretch"/>
        </background>
        <title>
            <band height="221" splitType="Stretch">
                <staticText>
                    <reportElement x="7" y="2" width="100" height="30" uuid="2bc03b83-e484-46e5-8681-48a9b01ac437"/>
                    <text><![CDATA[DEPTNO]]></text>
                </staticText>
                <staticText>
                    <reportElement x="160" y="2" width="100" height="30" uuid="3dfc25f3-6ff1-4186-8ee6-c71759a749a7"/>
                    <text><![CDATA[DNAME]]></text>
                </staticText>
                <subreport>
                    <reportElement x="10" y="60" width="544" height="20" uuid="e947974e-27bc-4b90-b0ee-f709b969c91b"/>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    <subreportExpression><![CDATA["subreport.jasper"]]></subreportExpression>
                </subreport>
            </band>
        </title>
        <pageHeader>
            <band height="73" splitType="Stretch"/>
        </pageHeader>
        <columnHeader>
            <band height="36" splitType="Stretch"/>
        </columnHeader>
        <detail>
            <band height="35" splitType="Stretch"/>
        </detail>
        <columnFooter>
            <band height="45" splitType="Stretch"/>
        </columnFooter>
        <pageFooter>
            <band height="54" splitType="Stretch"/>
        </pageFooter>
        <summary>
            <band height="44" splitType="Stretch">
                <subreport>
                    <reportElement x="130" y="10" width="200" height="34" uuid="892a1adf-f7e7-4804-8f7f-a5227516afb5"/>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    <subreportExpression><![CDATA["rep1/subrep2.jasper"]]></subreportExpression>
                </subreport>
            </band>
        </summary>
    </jasperReport>
    

    Please, is it possible to select all < subreport > items, so the result of a query would be something like:

    <subreport>
                    <reportElement x="10" y="60" width="544" height="20" uuid="e947974e-27bc-4b90-b0ee-f709b969c91b"/>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    <subreportExpression><![CDATA["subreport.jasper"]]></subreportExpression>
     </subreport>
     <subreport>
                    <reportElement x="130" y="10" width="200" height="34" uuid="892a1adf-f7e7-4804-8f7f-a5227516afb5"/>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    <subreportExpression><![CDATA["rep1/subrep2.jasper"]]></subreportExpression>
    </subreport>
    

    The problem is this subreport sections can be nested more or less anywhere, so I do not know the path. Any suggestions would be much appreciated.

    Thank you

    Pavel

    The XPath ' / /' means selects nodes in the document from the current node that match the selection, regardless of where they are.  If the XPath ' / / the subreport ' will extract all nodes called subreport wherever they are in the document or not.  So something like...

    data (donnees_xml))

    Select xmltype)

    '

    "http://JasperReports.sourceforge.net/JasperReports" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" "xsi: schemaLocation ="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"name ="Blank_A4"pageWidth ="595"pageHeight = columnWidth"842"="555"leftMargin ="20"rightMargin ="20"topMargin ="20"bottomMargin ="20"uuid ="8f749217-51eb-4c79-9b11-5a3e11b5b1b4">

    <p class="reply"> <p class="reply"><band height="221" splittype="Stretch"><p class="reply"> <p class="reply"><staticText><p class="reply"> <p class="reply"><reportElement x="7" y="2" width="100" height="30" uuid="2bc03b83-e484-46e5-8681-48a9b01ac437"></reportElement></p> <p class="reply"><text><![CDATA[DEPTNO]]></text></p> <p class="reply"></staticText></p> <p class="reply"><staticText><p class="reply"> <p class="reply"><reportElement x="160" y="2" width="100" height="30" uuid="3dfc25f3-6ff1-4186-8ee6-c71759a749a7"></reportElement></p> <p class="reply"><text><![CDATA[DNAME]]></text></p> <p class="reply"></staticText></p> <p class="reply"><subreport><p class="reply"> <p class="reply"><reportElement x="10" y="60" width="544" height="20" uuid="e947974e-27bc-4b90-b0ee-f709b969c91b"></reportElement></p> <p class="reply"><connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression></p> <p class="reply"><subreportExpression><![CDATA["subreport.jasper"]]></subreportExpression></p> <p class="reply"></subreport></p> <p class="reply"></band></p> <p class="reply">

    the double)

    Select *.

    from xmltable (XMLNamespaces (DEFAULT 'http://jasperreports.sourceforge.net/jasperreports'),

    ' / / the subreport '

    passage (select donnees_xml data)

    columns

    xmltype subreport path '.')

    SUBREPORT

    http://JasperReports.sourceforge.NET/JasperReports">

    http://JasperReports.sourceforge.NET/JasperReports">

    2 selected lines.

  • Customization problems a tree with a CheckBoxTreeCell

    I built a tree using a CheckBoxTreeCell.
    I would customize its presentation, so an image (map) appears to the left of the label. I tried to customize its presentation with the following custom tree cell:
    private class MyCell extends CheckBoxTreeCell<MyTree>  {
              @Override 
              public void updateItem(MyTree node, boolean empty) {
                   super.updateItem(node, empty);
                   if(node == null) {
                        setText("");
                   } else {
                        //setText(node.getName()); //this works fine
                        Label label = new Label(node.getName());
                        HBox hBox = new HBox();
                                    ImageView imageView = ...
                        hBox.getChildren().add(imageView, label);
                        setGraphic(hBox); //this does not work
                   }
              }
    }
    But it breaks the correct presentation of the box tree (among other things, checking the boxes are gone).
    Which is the right way to customize the layout of an element (for example, adding a clickable image) in this scenario?

    Finally, what happens if I want to add not only a picture, but a context menu items in that tree?

    Published by: be * on 21 may 2013 09:47

    I have the feeling of something that does not class

    You should check the incident handler:
    https://JavaFX-JIRA.Kenai.com/browse/RT-24666 "Public TreeCell extensions do not have graphics attribute of the element.
    https://JavaFX-JIRA.Kenai.com/browse/RT-30372 "CheckBoxTreeItem: extra checkbox on Treeview.
    https://JavaFX-JIRA.Kenai.com/browse/RT-30388 ' HelloTreeView: checked TreeView left aligned children. "

  • ORA: getPreference in an xslt file to transform the activity as input.

    Hello
    We have the following situation:

    We send input to a system fields target via a transformation (xslt) the value is '01486 '. We want to use an ora:getPreference('myPrefSecurityCode') to add the field to the plan of the configuration when we deploy the process. Because the field will change to test environment for the prod environment.

    "I assigned the ora:getPreference('myPrefSecurityCode') to a variable of type string named ' < SubscriberCode > < SubscriberCode xmlns =" "" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:ns = "http://www.w3.org/2001/XMLSchema" xsi: type = "ns:string" > 01486 < / SubscriberCode > < / SubscriberCode >.
    As you can see above, the field is assigned without any problem.


    But when I try to assign the field in a Transform (xslt), I get the following error:


    < bpelFault > < faultType > 0 < / faultType > < selectionFailure xmlns = "http://schemas.xmlsoap.org/ws/2003/03/business-process/" > < a name = "summary" part > < summary > query string XPath returns zero node.
    The activity assign the query node returns zero node.
    Either the data node or in the node xpath query was invalid.
    According to BPEL4WS 1.1 spec section 14.3, check the value of line number 371 node in the BPEL source.
    < / Summary > < / piece > < / selectionFailure > < / bpelFault >

    Edited by: 849200 29/04/2013 06:43

    Hello

    To pass the values of variables in the XSLT file, create an element in one of the schema of the source of your XSLT.
    Use an action entitled before this transformation, and assigns the value of var preferably to the newly created variable.
    Use this value to the variable to map to the required target node.

    I hope this helps.

    Kind regards
    Karan
    http://learn-oraclesoa.blogspot.com/

  • Insert zero (0) in a field of type integer db

    Hello

    With the help of:

    -CF8 (8.0.1.195765)

    -MySQL (5.5.19)

    I'm trying to update digital values in a MySQL database with all the fields are defined in full. The update process is done via a web form.

    If any number other than zero (0) and is entered in the respective form field, the update process is completed as expected. However, if a zero (0) is entered in the field DB is set to a value of null rather then insertion of the value of zero (0).

    I checked to ensure the value of zero (0) is increased from the form and rated as isNumeric. What I'm missing here? Here is the < cfquery > updated the process I use.

    Thanks - Leonard B

    <cfquery name="rsUpdate" datasource="*****">

    Update run_counts Set

    fire = nullif(<cfqueryparam value="#form.fire_count#" cfsqltype="cf_sql_integer">,'')

    , ems_rescue = nullif(<cfqueryparam value="#form.ems_rescue#" cfsqltype="cf_sql_integer">,'')

    , hazardous_conditions = nullif(<cfqueryparam value="#form.hazardous_conditions#" cfsqltype="cf_sql_integer">,'')

    , service_calls = nullif(<cfqueryparam value="#form.service_calls#" cfsqltype="cf_sql_integer">,'')

    , good_intent = nullif(<cfqueryparam value="#form.good_intent#" cfsqltype="cf_sql_integer">,'')

    , false_calls = nullif(<cfqueryparam value="#form.false_calls#" cfsqltype="cf_sql_integer">,'')

    , other = nullif(<cfqueryparam value="#form.other#" cfsqltype="cf_sql_integer">,'')

    , als_runs = nullif(<cfqueryparam value="#form.als_runs#" cfsqltype="cf_sql_integer">,'')

    , bls_runs = nullif(<cfqueryparam value="#form.bls_runs#" cfsqltype="cf_sql_integer">,'')

    </cfquery>

    It sounds like the result of implicit conversion. You compare two different data types: integer, and varchar. MySQL must convert to a single data type for comparison. So it converts the empty string "" to zero: that is, IFNULL (0, 0) where the null result.  However, why not just use attribute null of cfqueryparam?

    That is to say SET false_calls =

    cfsqltype = "cf_sql_integer".

    NULL = "#not len (form.false_calls) #" >

  • Reading and XSD and Auto generate entries

    Hello

    I need to read an XML schema and to identify the types and automatically generate entries. could someone direct me to a useful content?

    Kind regards

    Select this option.

    XML schema is an XML document. Use XPath for the node values.

Maybe you are looking for

  • problems with localhost

    Right after the update to Firefox 7 I can not move around localhost as usual. I type a url and get a Google search rather than the page you are looking for. How can I get the previous version back so that I can get some work done? And why you hide th

  • Satellite 3000 drivers graphics?

    I received a Satellite 3000 laptop for my birthday recently. I reinstalled windows, but I can't use the resolution of 1024 x 760 with 32-bit color, which is imperative for what I'm going to use the laptop for. So if someone could point me in the dire

  • HP Photosmart C4795: HP Solution Center

    I had the Photosmart printer for many years. The Solution Center SW worked fine until today. I used the printer and the solution center with no problems under Windows XP, Windows 7 and Windows 10. I've been on 10 to win for a few months now. Today, I

  • Cannot install software completely

    recently, I reformatted my hard drive and installed windows 7 Home premium. I tried to install the software into my computer, but most of the programs cannot be completely installed. Software Adobe reader, Skype, PPStream, Windows Live etc... the ins

  • I have a Windows 8 system and an old Dell J740 printer. Help, please.

    I have a Windows 8 system and an old Dell J740 printer.  I downloaded the driver from CNET.  The computer only recognizes the J740 as object "not specified", and I can't let go and drag the printer in the printer category.  Help, please.