Unstructured Xml Storage with Namespaces - Problem in DML Queries

Hai All,
I worked with xml namespace with registering schema in db and referred in my xml document.It worked fine.
But i want to work in unstructured xml document with namespaces, to do all dml queries like, select,update,delete using Xpath to xmltype.
I could insert the records,When i try to select some element from xmltype field using Xptah from db,it does not bring any thing like element value or any error.It just displaying as empty value.I am using oracle 10g R2.
Please help me how to select the element value from xmltype using XPath or whatever it is.
Please help me out from this to follow
Advance Thanks,
P.Savananan

SQL> create user marco identified by marco account unlock;
User created.
SQL> grant dba, xdbadmin to marco;
Grant succeeded.
SQL> conn marco/[email protected]
Connected.
SQL> create table xml_tab ( details xmltype);
Table created.
SQL> insert into xml_tab values(XMLTYPE('<?xml version="1.0" ?>
  2  <customers xmlns="http://localhost/openuri.org" >
  3  <customer>
  4  <order xmlns="http://orcl.com" >
  5  <ordername>Computer</ordername>
  6  <cost>35785638</cost>
  7  </order>
  8  </customer>
  9  </customers>'));
1 row created.
SQL> commit;
Commit complete.
SQL> select extractValue(details,'/customers/customer/order/ordername') from xml_tab;
EXTRACTVALUE(DETAILS,'/CUSTOMERS/CUSTOMER/ORDER/ORDERNAME')
SQL> set long 10000
SQL> select * from xml_tab;
DETAILS
<?xml version="1.0"?>
<customers xmlns="http://localhost/openuri.org">
  <customer>
    <order xmlns="http://orcl.com">
      <ordername>Computer</ordername>
      <cost>35785638</cost>
    </order>
  </customer>
</customers>
SQL> select extract(details,'//order/ordername') XDATA
  2  from   xml_tab
  3  ;
XDATA
SQL> select extract(details,'//order/ordername','xmlns="http://orcl.com"') XDATA
  2  from   xml_tab
  3  ;
XDATA
<ordername xmlns="http://orcl.com">Computer</ordername>
SQL> select extractValue(details,'//order/ordername','xmlns="http://orcl.com"') XDATA
  2  from   xml_tab
  3  ;
XDATA
Computer
SQL> select extractValue(details,'/*/*/order/ordername','xmlns="http://orcl.com"') XDATA
  2  from   xml_tab
  3  ;
XDATA
Computer

Similar Messages

  • Using XSLT to extract value of a XML node with namespace

    I have a XML source code here.
    <?xml version="1.0" encoding="utf-8" ?>
    <rss version="2.0" xmlns:job="http://www.pageuppeople.com">
      <channel>
        <title>SMH Jobs</title>
        <link>internalrecruitment.smhgroup.com.au/jobsrss.ashx?stp=di</link>
        <description>A listing of jobs available here</description>
        <item>
          <title>eCommerce Optimisation Advisor</title>
          <description>A new and exciting opportunity exists for an experienced eCommerce Advisor to join</description>
          <job:location PUReferenceID="3711">Sydney - Inner Suburbs & CBD</job:location>
        </item>
      </channel>
    </rss>
    I want to use XSLT to extract value of a XML node with namespace <job:location>, and the returned value should be string 'Sydney - Inner Suburbs & CBD'. I tried a few XSL code below, but failed with error or nothing was returned.
    <xsl:value-of select="job:location" disable-output-escaping="yes"/>
    <xsl:value-of select="job/location" disable-output-escaping="yes"/>
    <xsl:value-of select="job\location" disable-output-escaping="yes"/>
    <xsl:value-of select="location" disable-output-escaping="yes"/>
    This might be an easy question for you, but I would appreciate if anyone can help.

    Hi Suncorp IT Learner,
    We need to tell the XSLT that some elements are in another namespace. Copy the xmls declarations for the prefixes you need to use. Then use the xsl format as:
    <xsl: value-of select=”job:location/@PUReferenceID”/>
    In following issue, Chriztian has a good explanation:
    http://our.umbraco.org/forum/developers/xslt/33353-XSLT-reading-XML-attribute-value
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Delete(xml) in Flex namespace problem

    hihi
    I have problem with AS3 xml
    I want delete nodes in the folowing XML, which has title
    "undefined". A sample from the xml:
    <xml>
    <page>
    <title>Szabályalapú
    reprezentáció</title>
    <id>tudásterület_74</id>
    <revision>
    <id>1</id>
    <timestamp>2008-05-27T09:58:13Z</timestamp>
    <contributor>
    <ip>Wikiadmin</ip>
    </contributor>
    <text aaa:space="preserve"></text>
    </revision>
    </page>
    <page>
    <title>undefined</title>
    <id>tudásterület_22</id>
    <revision>
    <id>1</id>
    <timestamp>2008-05-27T09:58:13Z</timestamp>
    <contributor>
    <ip>Wikiadmin</ip>
    </contributor>
    <text aaa:space="preserve"></text>
    </revision>
    </page>
    <page>
    <title>Döntési folyamat</title>
    <id>tudásterület_22</id>
    <revision>
    <id>1</id>
    <timestamp>2008-05-27T09:58:13Z</timestamp>
    <contributor>
    <ip>Wikiadmin</ip>
    </contributor>
    <text aaa:space="preserve"></text>
    </revision>
    </page>
    </xml>
    I tried this script but didnt worked:
    delete xml.*::page.(title=="undefined")
    In a basic this shuold be like:
    delete xml.page.(title=="undefined")
    How does it work in xmls with namespace?

    "rtalton" <[email protected]> wrote in
    message
    news:gecgfa$3rs$[email protected]..
    > Sure thing. I tried to find a one-line method but
    couldn't. E4x syntax
    > supports
    > filtering using expressions, but not the delete command
    as far as I could
    > tell.
    > Maybe someone else knows more. Good luck.
    I think the problem is the filter expression returns an
    XMLList. You can
    only delete a single node. So try:
    delete yourNodesFilteredByExpression[0];
    HTH;
    Amy

  • How must getElementsByTagName work on an xml file with namespaces?

    Hello together,
    is there any normative document, which specifies
    which nodes must be returned by
    the org.w3c.dom.Document method
    getElementsByTagName when which was
    created by a namespace aware dom parser
    from an xml file containing namespaces?
    In other words:
    when you have an xml file:
    <someprefix:somenode xmlns:someprefix="http://someuri">
    <someprefix:innertag>
    <someprefix:mostinnertag>
    </someprefix:mostinnertag>
    <someprefix:mostinnertag>
    </someprefix:mostinnertag>
    </someprefix:innertag>
    </someprefix>
    and you call
    document.getElementsByTagName( ... );
    1) How many nodes must be returned when giving
    "mostinnertag" as parameter?
    2) How many nodes when giving "someprefix:mostinnertag" as parameter?
    Is it allowed to use the "non namespaceaware"
    method and not "getElementsByTagNameNS"?
    I know:
    a) xerces returns 2 nodes when using
    alternative 2 and none with alternative 1
    b) oracle xml parser returns 2 nodes when using
    alternative 1 and none when using alternative 2
    Which implementation is right?
    Yours
    Stefan

    I've got some problems with this methos and xerces too.
    Perhaps the two implementations (xerces and oracle) are different. I mean xerces implementation gives you nodes of this name but without namespace and oracles's implementation gives you modes with namespace whose unprefix-name is "mostinnertag".

  • Selecting XML Children with Namespaces

    I am trying to select child nodes of an XML element that have
    a different namespace from the parent, but xml.child(name) returns
    an empty list.
    In the attached code, londonList contains a single XML
    element and parisList is empty. I can't figure out how to find the
    paris child, and have tried adding the prefix to findParis (so it
    is "ff:b") as well as turning findParis into an XML object with the
    name "b" and adding the ff namespace to it, then passing that to
    child. Neither of those have worked.
    Any help is appreciated.

    Unfortunately in my real scenario I don't know what the
    element will be called. It could be in <foo> or <bar>
    etc, so I need to be able to use a variable (in which the element
    name is set beforehand). With "::" I can't use a variable, so
    textXML.ns::findParis looks for a "findParis" element and not "b".
    That's why I'm trying to use testXML.child(findParis) because
    I can use a variable. I just can't figure out how to make it
    incorporate the namespace as well.

  • Please help with namespace problem

    Hello,
    I am trying to display a gif image an I have a namespace problem.
    Here is my xml document:
    <?xml version='1.0'?>
    <?xml-stylesheet type="text/xsl" href="authors.xsl"?>
    <authors>
    <author>
    <name>Mike Galos</name>
    <nationality>French</nationality>
    </author>
    <author>
    <name>Cynthia Randall</name>
    <nationality>Canadian</nationality>
    </author>
    </authors>
    Here is my xsl stylesheet:
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="//author">
    <image     xmlns:xlink="http://www.w3.org/1999/xlink"
                   xlink:type="simple"
                   xlink:href="logo.gif"
                   xlink:show="embed"/>
    </xsl:template>
    </xsl:stylesheet>
    I want the browser to diplay the gif image but it is only showing the image icon and not the actual gif image.
    Can anyone please help??
    Thanks in advance,
    Balteo.

    do you use a special browser?
    if not, do you really expect a standard browser to understand this kind of non-HTML image tag?
    <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:show="embed" xlink:href="logo.gif" xlink:type="simple">check HTML 4.0 (http://www.devguru.com/Technologies/html/quickref/html_img.html)
    or XHTML(http://www.devguru.com/Technologies/xhtml/quickref/xhtml_img.html)
    for the correct tag syntax.

  • Transforming signed XML document with namespace invalidates signature

    I am running into a problem signing an XML document. Well, signing the document isn't the problem, as I can sign it and then verify the signature with the public key successfully. The problem comes when I transform the document to a string. It all appears to be OK, but when I transform it back, the hash no longer verifies. After more testing, it appears that the issue is related to namespaces. When I remove namespaces from the document, the signing and transformations work just fine. Does anyone have any insight on this?
    Here is how I am transforming the document to an XML string that I and back.
        try
          signSAML( doc, assertionElement );
          xmlSource = new DOMSource( doc );
          baos = new ByteArrayOutputStream();
          outputTarget = new StreamResult( baos );
          xmlString  = new String( new ByteArrayInputStream( baos.toByteArray() ) );
          transformerFactory = TransformerFactory.newInstance();
          transformer = transformerFactory.newTransformer();
          transformer.transform( xmlSource, outputTarget ); 
          boolean verified = verify( doc );
          if ( verified )
            System.out.println( "Verified" );
          else
            System.out.println( "UNVerified" );
        catch ( Exception e )
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

    jtahlborn wrote:
    i'm not talking about the transform, i'm talking about this line:
    xmlString  = new String( new ByteArrayInputStream( baos.toByteArray() ) );which is a great way to break xml data.Yes. That's not the only kind of data it's good at breaking, either.
    To the OP: just have your transform output to a StringWriter in the first place. Don't muck about converting between chars and bytes unless you know the correct encoding and use it. Which you don't know it and you didn't use it.

  • Extracting XML values with namespace

    Hi!
    I have a XML file:<?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/styl.xsl"?>
    <wnio:Deklaracja
    xmlns:adr="http://crd.gov.pl/xml/schematy/adres/2008/05/09/"
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    xmlns:inst="http://crd.gov.pl/xml/schematy/instytucja/2008/05/09/"
    xmlns:meta="http://crd.gov.pl/xml/schematy/meta/2008/05/09/"
    xmlns:oso="http://crd.gov.pl/xml/schematy/osoba/2008/05/09/"
    xmlns:str="http://crd.gov.pl/xml/schematy/struktura/2009/11/16/"
    xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
    xsi:schemaLocation="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/ http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/schemat.xsd">
                                <wnio:OpisDokumentu><str:CID>[email protected]</str:CID><meta:Identyfikator typIdentyfikatora="idFormularza"><meta:Wartosc>InstytucjaPubliczna/Deklaracja podatku od środków transportowych DT-1</meta:Wartosc></meta:Identyfikator></wnio:OpisDokumentu>
                                <wnio:Naglowek>
                                    <wnio:KodFormularza kodSystemowy="DT-1(3)"/>
                                    <wnio:WariantFormularza>3</wnio:WariantFormularza>
                                    <wnio:Rok>2008</wnio:Rok>
                                    <wnio:ObowiazekSkladaniaDeklaracji>1</wnio:ObowiazekSkladaniaDeklaracji>
                                    <wnio:MiejsceSkladania/>
                                </wnio:Naglowek>
                                <wnio:Podatnik>
                                    <wnio:OsobaPrawna>
                                        <wnio:NIP>345678901</wnio:NIP>
                                        <wnio:PelnaNazwa>Testowa Instytucja Publiczna</wnio:PelnaNazwa>
                                        <wnio:NazwaSkrocona/>
                                        <wnio:REGON>234512345</wnio:REGON>
                                    </wnio:OsobaPrawna>
                                    <wnio:AdresSiedzibyZamieszkania>
                                        <wnio:KodKraju>PL</wnio:KodKraju>
                                        <wnio:Wojewodztwo>ŚLĄSKIE</wnio:Wojewodztwo>
                                        <wnio:Powiat>Katowice</wnio:Powiat>
                                        <wnio:Gmina>Katowice (gmina miejska)</wnio:Gmina>
                                        <wnio:Ulica>ul. Mikołowska</wnio:Ulica>
                                        <wnio:NrDomu>100</wnio:NrDomu>
                                        <wnio:NrLokalu>924</wnio:NrLokalu>
                                        <wnio:Miejscowosc>Katowice (miasto)</wnio:Miejscowosc>
                                        <wnio:KodPocztowy>40-065</wnio:KodPocztowy>
                                        <wnio:Poczta>Katowice</wnio:Poczta>
                                    </wnio:AdresSiedzibyZamieszkania>
                                </wnio:Podatnik>
                                <wnio:PozycjeSzczegolowe>
                                    <wnio:D.1>
                                        <wnio:P_22/>
                                        <wnio:P_23/>
                                    </wnio:D.1>
                                    <wnio:D.2>
                                        <wnio:P_28/>
                                        <wnio:P_29/>
                                    </wnio:D.2>
                                    <wnio:P_82/>
                                    <wnio:P_83/>
                                </wnio:PozycjeSzczegolowe>
                                <wnio:Zalacznik_DT-1A>
                                    <wnio:P_1/>
                                    <wnio:P_2/>
                                    <wnio:P_22>1</wnio:P_22>
                                </wnio:Zalacznik_DT-1A>
                                <wnio:Zalacznik_DT-1A>
                                    <wnio:P_1/>
                                    <wnio:P_2/>
                                    <wnio:P_22>3</wnio:P_22>
                                </wnio:Zalacznik_DT-1A>
                            </wnio:Deklaracja>and an overloaded function:
    function dodaj_DT1_z_xml(p_dt1 in out nocopy XMLType) return number as
      r_dt1   POD_SRTR_DT1%rowtype;
      r_dt1a  POD_SRTR_DT1A%rowtype;
      r_sdek  POD_SRTR_DEKLARACJE%rowtype;
      l_wariantDT1  number(2);
      l_xosf  XMLType;
      l_xosp  XMLType;
      l_xadr  XMLType;
      l_xszcz XMLType;
      l_zal   XMLType;
      l_z     XMLType;
      l_zno   pls_integer;
      l_xml   XMLType;
      l_ns    varchar2(10);
    -- xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
    begin
      if --p_dt1.existsNode('/wnio:Deklaracja')=0 and
         p_dt1.existsNode('/Deklaracja','xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')=0
      then  return -2;  end if;
      if p_dt1.existsNode('/wnio:Deklaracja')=1 then
        l_ns := 'wnio:';
      end if;
      if p_dt1.existsNode('/'||l_ns||'Deklaracja')=0 then                     return -2;  end if;
      if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Naglowek')=0 then            return -3;  end if;
      if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Podatnik')=0 then            return -4;  end if;
      if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'PozycjeSzczegolowe')=0 then  return -5;  end if;
      return 1;
    end;
    function dodaj_DT1_z_xml(p_dt1 in out nocopy CLOB) return number is
      l_xml   XMLType;
    begin
      l_xml := XMLType(p_dt1);
      return dodaj_DT1_z_xml(l_xml);
    end dodaj_DT1_z_xml;I run the code:declare
      v_clob  CLOB;
      v_out   number;
    begin
      SELECT dok_content INTO v_clob FROM EPUAP.epuap_dokumenty WHERE dok_id=13;
      v_out := POD_PCK_SRTR_DT1.DODAJ_DT1_Z_XML(v_clob);
      DBMS_OUTPUT.put_line(v_out);
    end;the output is -2. What must I change to find the node "wnio:Deklaracja"? I'm newbie in XML and namespaces :(
    Help me, please...

    Thanks, BluShadow!
    added:
    What if the structure of the XML is not always the same? Suppose that <aa:USER_INFO> sometimes contains subnode <aa:AUX>.
    WITH t as (select XMLTYPE('
       <RECSET xmlns:aa="http://www.w3.org">
         <aa:REC>
           <aa:COUNTRY>1</aa:COUNTRY>
           <aa:POINT>1800</aa:POINT>
           <aa:USER_INFO>
             <aa:USER_ID>1</aa:USER_ID>
             <aa:TARGET>28</aa:TARGET>
             <aa:STATE>6</aa:STATE>
             <aa:TASK>12</aa:TASK>
             <aa:AUX>
               <aa:AUX1>111</aa:AUX1> <aa:AUX2>222</aa:AUX2>
             </aa:AUX>
           </aa:USER_INFO>
           <aa:USER_INFO>
             <aa:USER_ID>5</aa:USER_ID>
             <aa:TARGET>19</aa:TARGET>
             <aa:STATE>1</aa:STATE>
             <aa:TASK>90</aa:TASK>
           </aa:USER_INFO>
         </aa:REC>
         <aa:REC>
           <aa:COUNTRY>2</aa:COUNTRY>
           <aa:POINT>2400</aa:POINT>
           <aa:USER_INFO>
             <aa:USER_ID>3</aa:USER_ID>
             <aa:TARGET>14</aa:TARGET>
             <aa:STATE>7</aa:STATE>
             <aa:TASK>5</aa:TASK>
             <aa:AUX>
               <aa:AUX1>333</aa:AUX1>
             </aa:AUX>
           </aa:USER_INFO>
         </aa:REC>
       </RECSET>') as xml from dual)
       -- END OF TEST DATA
       select x.country, x.point, y.user_id, y.target, y.state, y.task, z.aux1, z.aux2
       from t
           ,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
                     '/RECSET/aa:REC'
                     PASSING t.xml
                     COLUMNS country NUMBER PATH '/aa:REC/aa:COUNTRY'
                            ,point   NUMBER PATH '/aa:REC/aa:POINT'
                            ,user_info XMLTYPE PATH '/aa:REC/*'
                    ) x
           ,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
                     '/aa:USER_INFO'
                     PASSING x.user_info
                     COLUMNS user_id NUMBER PATH '/aa:USER_INFO/aa:USER_ID'
                            ,target  NUMBER PATH '/aa:USER_INFO/aa:TARGET'
                            ,state   NUMBER PATH '/aa:USER_INFO/aa:STATE'
                            ,task    NUMBER PATH '/aa:USER_INFO/aa:TASK'
                            ,aux     XMLTYPE PATH '/aa:USER_INFO/*'
                  ) y
           ,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
                     '/aa:AUX'
                     PASSING y.aux
                     COLUMNS aux1 NUMBER PATH '/aa:AUX/aa:AUX1'
                            ,aux2 NUMBER PATH '/aa:AUX/aa:AUX2'
                  ) z;This query returns only 2 rows. I'd like to have 3 rows returned :) 3 rows are returned when I add an empty <aa:AUX> node to the data but I wants to have 3 rows when the <aa:AUX> is missed also.

  • XML Parsing with namespace

    Hi All,
    I have a requirement to convert XML to itab to be processed further.
    I couldn't parse the XML which contains ns0 (namespace?) as following:
    <ns0:OrderNo>887140</ns0:OrderNo>
    <ns0:CPROD>BD</ns0:CPROD>
    <ns0:CURR>USD</ns0:CURR>
    I'm able to parse If I remove the namespace ns0 from the file as following:
    <OrderNo>887140</OrderNo>
    <CPROD>BD</CPROD>
    <CURR>USD</CURR>
    The thing is the XML file will always come with the namespace ns0.
    I'm using IF_IXML, IF_IXML_STREAM_FACTORY, IF_IXML_ISTREAM, IF_IXML_PARSER, IF_IXML_DOCUMENT to parse the XML.
    Any idea on how to overcome this?
    Thanks,
    Victor.

    Hello Victor,
    fine. I am glad, I could help you.
    Just one note to XSLT Transformations: When using them, you got even the ability to map directly to internal abap tables:
    CALL TRANSFORMATION ZXSLT_YOUR_TRANSFORMATION
      SOURCE XML l_xmlstring
      RESULT DATA = lt_data.
    You just need to transform you xml to the asx:abap name space and that's it
    Look at Re: Help needed XML to Internal table and vice versa, where I show a simple example, how this works.
    Kind regards,
    Hendrik

  • Read an XML file with namespace items

    I'm a beginner with XML and for the first time i have to read a file with columns.
    I have try this code, but the result is always the same: no rows selected.
    variable xml_response varchar2(4000)
    BEGIN
    :xml_response :=
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT xmlns="http://www.post.ch/schemas/dfu/2006/20/Report11">
      <Sender SenderID="1618" SenderName="Laurastar SA" ReportCreated="20141120053155">
      <Provider ProviderID="539ADAEE-FF18-49F8-84B8-B90232CBCC61" ProviderName="Pakete">
      <Data>
      <Item SendingID="a68f0007-c4df-4ecb-8dfe-d6da6c2e0cda" ItemID="5430243" IdentCode="993314781300000254" />
      <Item SendingID="beba5a0e-6363-42f1-aeb5-51c5171ed032" ItemID="5430241" IdentCode="993314781300000255" />
      <Item SendingID="beba5a0e-6363-42f1-aeb5-51c5171ed032" ItemID="5430241" IdentCode="993314781300000255" />
      </Data>
      </Provider>
      </Sender>
    </ROOT>';
    END;
    SELECT x.*
       FROM XMLTable(
       '/ROOT'
       passing xmltype(:xml_response)
       columns
      ReportCreated varchar2(30)  path 'Sender/@ReportCreated'
       , SendingID  varchar2(50)  path 'Sender/Provider/Data/Item/@SendingID'
       , ItemID  varchar2(30)  path 'Sender/Provider/Data/Item/@ItemID'
       , IdentCode  varchar2(30)  path 'Sender/Provider/Data/Item/@IdentCode'
       ) x
    I could not found what is wrong.

    I could not found what is wrong.
    Two things are wrong :
    1) Lack of namespace declaration
    2) You're trying to project repeating nodes into a single row
    This should work :
    SELECT x1.ReportCreated
         , x2.*
    FROM XMLTable(
           XMLNamespaces(default 'http://www.post.ch/schemas/dfu/2006/20/Report11')
         , '/ROOT/Sender'
           passing xmltype(:xml_response)
           columns
             ReportCreated varchar2(30) path '@ReportCreated'
           , items         xmltype      path 'Provider/Data/Item'
         ) x1
       , XMLTable(
           XMLNamespaces(default 'http://www.post.ch/schemas/dfu/2006/20/Report11')
         , 'Item'
           passing x1.items
           columns
             SendingID     varchar2(50)  path '@SendingID'
           , ItemID        varchar2(30)  path '@ItemID'
           , IdentCode     varchar2(30)  path '@IdentCode'
         ) x2

  • Is it possible to create indexes & use them on xml docs with namespaces?

    I have put an XML doc in a BDBXML container which looks like this:
    *<ns1:note xmlns:ns1="http://www.testsch.org/ns">*
    *<ns1:to>Eric</ns1:to>*
    *<ns1:from>Brendan</ns1:from>*
    *<ns1:msg>How r u?</ns1:msg>*
    *</ns1:note>*
    Now, I am creating an index on the element "to", as:
    addIndex "ns1" "to" node-element-equality-string
    Though the index has been shown as getting created using the listIndexes command, if I lookup that index with the following command:
    lookupIndex node-element-equality-string "ns1" "to"
    the output is:
    *0 objects returned for eager index lookup 'node-element-equality-string'*
    Whereas, if I do the whole procedure without the namespaces in the document & the commands, the result is fine:
    *1 object returned for eager index lookup 'node-element-equality-string'*
    Can someone please tell me whether using namespaces, the indexes can be created or not? If yes, how?
    Thanks,
    Dev
    Edited by: user11871332 on Sep 7, 2009 3:53 PM

    Hi Dev,
    When using XML, the prefix for the namespace is really just syntactic sugar. The actual namespace in your example is "http://www.testsch.org/ns", and that's the value that you need to use when creating your index:
    addIndex "http://www.testsch.org/ns" "to" node-element-equality-stringJohn

  • XML access with namespaces?

    Hi!
    I started learning Flex by using Flex but now I have the
    first problem I can't solve. I think this will be only a basic
    problem but in other forums nobody could help me. And of course I
    didn't find anything about this in the help. :)
    In the following MXML-Code I tried to use the flickr SOAP API
    which works, but I don't get the real usage of the new XML class.
    As you can see in the function called "recieveFlickrResult" I'm not
    able to access the attribute I want to. The syntax seems to be
    correct in my eyes because, if I create a new XML-Object using the
    XMLString I can access the attribute. I also tried several other
    methods like attributes(), children() and so on. I really don't get
    it.
    I think I'm making a fundamental mistake! Maybe the way I'm
    using the access through namespaces (function
    "extractFlickrResponse") is wrong?
    Maybe you want to try this MXML-File:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="init();">
    <mx:HTTPService id="flickrService" url="
    http://api.flickr.com/services/soap/"
    useProxy="false" contentType="application/xml"
    resultFormat="xml"></mx:HTTPService>
    <mx:Script>
    <![CDATA[
    public var apiURL:String = "
    http://api.flickr.com/services/soap/";
    public var api_key:String =
    "0cdbd0b93883f563e3bea67611e44c83";
    public var nsid:String;
    public var urlRequest:URLRequest;
    public var resultLoader:URLLoader;
    public function debug(s:String):void{
    debugTxt.text += s + "\r";
    var sNS:Namespace = new Namespace("
    http://www.w3.org/2003/05/soap-envelope");
    var xNS:Namespace = new Namespace("urn:flickr");
    public function generateSOAPRequestXML(method:String,
    params:Object):XML{
    var requestXML:XML = <s:Envelope
    xmlns:s="
    http://www.w3.org/2003/05/soap-envelope"
    xmlns:xsi="
    http://www.w3.org/1999/XMLSchema-instance"
    xmlns:xsd="
    http://www.w3.org/1999/XMLSchema"
    >
    <s:Body>
    <x:FlickrRequest xmlns:x="urn:flickr">
    <method>{method}</method>
    <api_key>{api_key}</api_key>
    </x:FlickrRequest>
    </s:Body>
    </s:Envelope>
    var flickrXMLList:XMLList =
    requestXML.sNS::Body.xNS::FlickrRequest;
    for (var param:String in params){
    var newparamNode:XML =
    <{param}>{params[param]}</{param}>
    flickrXMLList.appendChild(newparamNode);
    return requestXML;
    public function extractFlickrResponse(response:XML):XMLList{
    return response.sNS::Body.xNS::FlickrResponse;
    public function startFlickrRequest(requestXML:XML):void{
    urlRequest = new URLRequest(apiURL);
    urlRequest.contentType = "text/xml";
    urlRequest.method = URLRequestMethod.POST;
    urlRequest.data = requestXML;
    resultLoader = new URLLoader(urlRequest);
    resultLoader.addEventListener("complete",
    recieveFlickrResult);
    public function recieveFlickrResult(evt:Event):void{
    if (evt.type == "complete"){
    var resultXML:XML = new XML(resultLoader.data);
    debug("resultXML :\r" + resultXML);
    var response:XMLList = extractFlickrResponse(resultXML);
    debug("");
    debug("response :\r" + response);
    debug("response.@nsid : " + response.@nsid); // returns
    nothing!
    var newXML:XML = new XML(response.toString());
    debug("");
    debug("newXML :\r" + newXML);
    debug("");
    debug("newXML.@nsid : " + newXML.@nsid); //returns the value
    public function init():void{
    var nsidRequestXML:XML =
    generateSOAPRequestXML('flickr.people.findByUsername', {username
    :"der_raab"});
    startFlickrRequest(nsidRequestXML);
    ]]>
    </mx:Script>
    <mx:TextArea id="debugTxt" text="" left="10" right="10"
    bottom="10" top="10"/>
    </mx:Application>

    I've never used the Flickr API before, but everything appears
    to me to be behaving as expected. It appears, oddly enough, that
    for some reason the FlickrResponse tag returns XML which is encoded
    as a blob of text. That's strange to me, but perhaps there's a
    reason for it -- but in any case, here is the XML that came back (I
    captured this using the Charles web debugging proxy from
    http://www.xk72.com/charles):
    <s:Envelope xmlns:s="
    http://www.w3.org/2003/05/soap-envelope"
    xmlns:xsi="
    http://www.w3.org/1999/XMLSchema-instance"
    xmlns:xsd="
    http://www.w3.org/1999/XMLSchema">
    <s:Body>
    <x:FlickrResponse xmlns:x="urn:flickr">
    &lt;user id=&quot;42441977@N00&quot;
    nsid=&quot;42441977@N00&quot;&gt;
    &lt;username&gt;der_raab&lt;/username&gt;
    &lt;/user&gt;
    </x:FlickrResponse>
    </s:Body>
    </s:Envelope>
    So check that out, there's that escaped XML on the inside. As
    far as E4X is concerned, that is just text, so . So, as you do near
    the end of your sample, you must take that text and use it to
    create an XML object.
    The "response.@nsid" which returned nothing is actually
    looking for an nsid attribute on the <x:FlickrResponse> tag,
    not on the text which is inside that tag.

  • Extracting XML values with namespace prefixes

    Hint: I put this topic in "SQL and PL/SQL" but that was a bad idea, I think.
    Hi!
    I have a XML file:<?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/styl.xsl"?>
    <wnio:Deklaracja
    xmlns:adr="http://crd.gov.pl/xml/schematy/adres/2008/05/09/"
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    xmlns:inst="http://crd.gov.pl/xml/schematy/instytucja/2008/05/09/"
    xmlns:meta="http://crd.gov.pl/xml/schematy/meta/2008/05/09/"
    xmlns:oso="http://crd.gov.pl/xml/schematy/osoba/2008/05/09/"
    xmlns:str="http://crd.gov.pl/xml/schematy/struktura/2009/11/16/"
    xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
    xsi:schemaLocation="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/ http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/schemat.xsd">
                                <wnio:OpisDokumentu><str:CID>[email protected]</str:CID><meta:Identyfikator typIdentyfikatora="idFormularza"><meta:Wartosc>InstytucjaPubliczna/Deklaracja podatku od środków transportowych DT-1</meta:Wartosc></meta:Identyfikator></wnio:OpisDokumentu>
                                <wnio:Naglowek>
                                    <wnio:KodFormularza kodSystemowy="DT-1(3)"/>
                                    <wnio:WariantFormularza>3</wnio:WariantFormularza>
                                    <wnio:Rok>2008</wnio:Rok>
                                    <wnio:ObowiazekSkladaniaDeklaracji>1</wnio:ObowiazekSkladaniaDeklaracji>
                                    <wnio:MiejsceSkladania/>
                                </wnio:Naglowek>
                                <wnio:Podatnik>
                                    <wnio:OsobaPrawna>
                                        <wnio:NIP>345678901</wnio:NIP>
                                        <wnio:PelnaNazwa>Testowa Instytucja Publiczna</wnio:PelnaNazwa>
                                        <wnio:NazwaSkrocona/>
                                        <wnio:REGON>234512345</wnio:REGON>
                                    </wnio:OsobaPrawna>
                                    <wnio:AdresSiedzibyZamieszkania>
                                        <wnio:KodKraju>PL</wnio:KodKraju>
                                        <wnio:Wojewodztwo>ŚLĄSKIE</wnio:Wojewodztwo>
                                        <wnio:Powiat>Katowice</wnio:Powiat>
                                        <wnio:Gmina>Katowice (gmina miejska)</wnio:Gmina>
                                        <wnio:Ulica>ul. Mikołowska</wnio:Ulica>
                                        <wnio:NrDomu>100</wnio:NrDomu>
                                        <wnio:NrLokalu>924</wnio:NrLokalu>
                                        <wnio:Miejscowosc>Katowice (miasto)</wnio:Miejscowosc>
                                        <wnio:KodPocztowy>40-065</wnio:KodPocztowy>
                                        <wnio:Poczta>Katowice</wnio:Poczta>
                                    </wnio:AdresSiedzibyZamieszkania>
                                </wnio:Podatnik>
                                <wnio:PozycjeSzczegolowe>
                                    <wnio:D.1>
                                        <wnio:P_22/>
                                        <wnio:P_23/>
                                    </wnio:D.1>
                                    <wnio:D.2>
                                        <wnio:P_28/>
                                        <wnio:P_29/>
                                    </wnio:D.2>
                                    <wnio:P_82/>
                                    <wnio:P_83/>
                                </wnio:PozycjeSzczegolowe>
                                <wnio:Zalacznik_DT-1A>
                                    <wnio:P_1/>
                                    <wnio:P_2/>
                                    <wnio:P_22>1</wnio:P_22>
                                </wnio:Zalacznik_DT-1A>
                                <wnio:Zalacznik_DT-1A>
                                    <wnio:P_1/>
                                    <wnio:P_2/>
                                    <wnio:P_22>3</wnio:P_22>
                                </wnio:Zalacznik_DT-1A>
                            </wnio:Deklaracja>and an overloaded function:
    function dodaj_DT1_z_xml(p_dt1 in out nocopy XMLType) return number as
      r_dt1   POD_SRTR_DT1%rowtype;
      r_dt1a  POD_SRTR_DT1A%rowtype;
      r_sdek  POD_SRTR_DEKLARACJE%rowtype;
      l_wariantDT1  number(2);
      l_xosf  XMLType;
      l_xosp  XMLType;
      l_xadr  XMLType;
      l_xszcz XMLType;
      l_zal   XMLType;
      l_z     XMLType;
      l_zno   pls_integer;
      l_xml   XMLType;
      l_ns    varchar2(10);
    -- xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
    begin
      if --p_dt1.existsNode('/wnio:Deklaracja')=0 and
         p_dt1.existsNode('/Deklaracja','xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')=0
      then  return -2;  end if;
      if p_dt1.existsNode('/wnio:Deklaracja')=1 then
        l_ns := 'wnio:';
      end if;
      if p_dt1.existsNode('/'||l_ns||'Deklaracja')=0 then                     return -2;  end if;
      if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Naglowek')=0 then            return -3;  end if;
      if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Podatnik')=0 then            return -4;  end if;
      if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'PozycjeSzczegolowe')=0 then  return -5;  end if;
      return 1;
    end;
    function dodaj_DT1_z_xml(p_dt1 in out nocopy CLOB) return number is
      l_xml   XMLType;
    begin
      l_xml := XMLType(p_dt1);
      return dodaj_DT1_z_xml(l_xml);
    end dodaj_DT1_z_xml;I run the code:declare
      v_clob  CLOB;
      v_out   number;
    begin
      SELECT dok_content INTO v_clob FROM EPUAP.epuap_dokumenty WHERE dok_id=13;
      v_out := POD_PCK_SRTR_DT1.DODAJ_DT1_Z_XML(v_clob);
      DBMS_OUTPUT.put_line(v_out);
    end;the output is -2. What must I change to find the node "wnio:Deklaracja"? I'm newbie in XML and namespaces :(
    Help me, please...
    Oracle version is 10.2.0.3

    Hi,
    If you declare a namespace prefix then corresponding elements must be qualified.
    So, either do :
    p_dt1.existsNode('/wnio:Deklaracja','xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')or use a default namespace declaration :
    p_dt1.existsNode('/Deklaracja','xmlns="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')BTW, could you explain what are you trying to accomplish?

  • Creating XML object with namespaces

    I'm trying to create the following XML
    <xs:schema id='MySchema' xmlns:xs='
    http://www.w3.org/2001/XMLSchema'
    xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
    <xs:element name='MySchema' msdata:IsDataSet='true'
    msdata:UseCurrentLocale='true'/>
    </xs:schema>
    Following the documentation it appears that the following
    code should do the trick
    private const xs:Namespace = new Namespace("
    http://www.w3.org/2001/XMLSchema");
    private const msdata:Namespace = new
    Namespace("urn:schemas-microsoft-com:xml-msdata");
    var testXml:XML = <schema></schema>;
    testXml.addNamespace(xs);
    testXml.addNamespace(msdata);
    testXml.@id = "MySchema";
    testXml.xs::element.@name = "MySchema";
    testXml.element.@msdata::IsDataSet = true;
    testXml.element.@msdata::UseCurrentLocale = true;
    However, this results in the following XML
    <schema id="PERSONDETAILS">
    <element name="PERSONDETAILS" xmlns="
    http://www.w3.org/2001/XMLSchema"/>
    <element IsDataSet="true" UseCurrentLocale="true"
    xmlns="urn:schemas-microsoft-com:xml-msdata"/>
    </schema>
    Can anyone tell me what I'm doing wrong? Thanks

    Got it, this seems to work...
    var testXml:XML = <xs:schema xmlns:xs='
    http://www.w3.org/2001/XMLSchema'
    xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'></xs:schema>;
    testXml.@id = "MySchema";
    testXml.xs::element.@name = "MySchema";
    testXml.element.@msdata::IsDataSet = true;
    testXml.element.@msdata::UseCurrentLocale = true;

  • Parsing this XML file with namespace

    I need to parse the following XML structure:
    <?xml version="1.0" encoding="utf-8"?>
    <ArrayOfTitles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/">
      <Titles>
        <articleID>123</articleID>
        <articleTitle>Title 1</articleTitle>
      </Titles>
      <Titles>
        <articleID>456</articleID>
        <articleTitle>Title 2</articleTitle>
      </Titles>
      <Titles>
        <articleID>789</articleID>
        <articleTitle>Title 3</articleTitle>
      </Titles>
    </ArrayOfTitles>
    I am using this code:
    var ns:Namespace = new Namespace("http://example.com/");
    var strings:XMLList = xml.ns::Titles;
    for each(var str:XML in strings)
    trace(str);
    But the output still has the namespace in each node.

    Well, I have to say openning a new file writer every time you write a block of characters is pretty horrible, why not just use one buffered writer for the whole operation. I can't see the memory leak, but I think this would run agonisingly slowly.

Maybe you are looking for