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

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

  • 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

  • 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".

  • XML parser with document support

    Hi all,
    For a whole week now, I m still looking for a nice (but lite) XML parser for J2ME applications. Of course I found kXML 2 parser but I'm confused.
    kXML 2 implements the XmlPull API (xmlpull.org) so you can parse easly an XML file with functions as next(), ...
    BUT, I would like to deal with a Document Object Model (DOM) (like JDom for J2SE), with this I will be able to do some nice stuff like doc.getRoot().getElement....
    In kXML2 Javadoc I found something like this but apparently it doesnt work well (or I dont know how to use it).
    Do someone know this API ? http://kxml.sourceforge.net/kxml2/javadoc/
    I can't find any example on Internet, everybody seems to use it without DOM....
    Until someone give me an answer I will continue to use kXML2 without document object model :(
    thanks guys,

    just a search..in http://sourceforge.net/
    http://sourceforge.net/search/?type_of_search=soft&type_of_search=soft&words=dom+j2me

  • XML Parsing with XSL Performance lag

    Hi there
    I should qualify this post by saying I am fairly new to EJB's and have based the below on a Java Working with XML Tutorial I read.
    I have an EJB which is being developed to parse XML documents with an XSL stylesheet and return HTML for display. The code is working fine however there is a fairly hefty performance lag when using the EJB to generate the HTML as opposed to the straight HTML. I am getting an average response time of 95000ms using the EJB as opposed to 45000ms when viewing the straight HTML. The code I am using to do the parsing is :
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(dataFile);
    // Convert docs into StreamSource
    StreamSource stylesource = new StreamSource(styleSheet);
    StreamSource source = new StreamSource(dataFile);
    StringWriter strWrite = new StringWriter();
    StreamResult result = new StreamResult(strWrite);
    // Use a Transformer for output
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(stylesource);
    transformer.transform(source, result);
    There is then some error handling and the strWrite object is placed into an array to be returned.
    I am really looking to find out if the performance lag I am experiencing is normal or if there is anything I can do to improve the speed of the code.
    All comments and help is most appreciated.
    Cheers
    Justin.

    You should be able to increase performance by caching Templates objects in memory as a previous post suggested.
    Here is some untested code:public final class TransformerCache
         private static Map cache = new Vector();
         private TransformerCache(){}
         public static Transformer getTransformer( String filename )
              if( ! cache.containsKey( filename ) )
                   TransformerFactory tf = TransformerFactory.newInstance();
                   Templates template = tf.newTemplates( new StreamSource( filename ) );
                   cache.put( filename, template );     
              return ( ( Templates ) cache.get( filename ) ).newTransformer();
    }This aproach works in a clustered environment, just bear in ming that there will be an instance of the cache on each server instance (virtual machine).

  • 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.

  • Using a xml parser with jbuilder

    I'm using jbuilder and the required librairies I've just added require me to add an XML parser to the path. I've just downloaded one from www.apache.org.
    How do I incorporate this parser into my project. I need to use the following packages but I'm not sure how I can put everything together.
    If you understand what my problem is please help. Thanks , B.
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;

    Go to tools | configure libraries.
    click the new button on the left
    Type in the name you want the library to be identified with (XML Parser or something)
    Choose the location (this determines how many people and projects have access to the libraries)
    Click the add button and find the *.jar files.
    Ok back out of the dialogs
    Now select the Project Properties (or default props to have the library available to all projects, not recommended tho)
    Select the paths tab
    Click Add and select the Library you added in the earlier steps.
    If you have any probs, www.borland.com has heaps of stuff on configuring libraries

  • XML parsing with SQL/PL-SQL

    Hi,
    My question is about how can an XML message can be best parsed using SQL/PL-SQL.
    The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.
    In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.
    Apologies for this basic question but I have never done XML parsing in SQL/PL-SQL before.
    Thank you.
    PS I have copied this question to the XML forum.
    Edited by: user3112983 on May 19, 2010 3:30 PM
    Edited by: user3112983 on May 19, 2010 3:39 PM

    user3112983 wrote:
    The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.Parsing is done using the XMLTYPE data type (object class) in Oracle.
    Something as follows:
    SQL> create table xml_doc( id number, doc clob );
    Table created.
    SQL>
    SQL> insert into xml_doc values( 1, '<root><row><name>John</name></row><row><name>Jack</name></row></root>' );
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> declare
      2          rawXml  xml_doc.doc%type;
      3          xml     xmltype;
      4  begin
      5          -- get the raw XML (as a CLOB)
      6          select doc into rawXml from xml_doc where id = 1;
      7
      8          -- parse it
      9          xml := new xmltype( rawXml );  
    10         -- process the XML...
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL>The variable xml in the sample code is the XML DOM object. XML functions can be used against it (e.g. to extract values in a tabular row and column structure).
    Note that the CLOB needs to contain a valid XML. An XML containing XML fragments is not valid and cannot be parsed. E.g.
    SQL> declare
      2          xml     xmltype;
      3  begin
      4          -- attemp to parse fragments
      5          xml := new xmltype( '<row><name>John</name></row>  <data><column>Name</column></data>' );
      6  end;
      7  /
    declare
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00245: extra data after end of document
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 301
    ORA-06512: at line 5This XML contains 2 fragments. A row structure and a data structure. It is not a valid XML and as such cannot be parsed. If a root tag is used to encapsulate these 2 fragments, then it will be a valid XML structure.
    In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.Have not run into any XML performance problems specifically - and am using it extensively. Even large XMLs (10's of 1000's of elements) parse pretty fast.

  • 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.

  • XML Parsing with Tags increasing in no's

    I have an XML that I am recieving it from other system like below :
    <ResultSet>
      <ERROR_CODE_ID>0</ERROR_CODE_ID>
      <ERROR_DESCRIPTION>Success</ERROR_DESCRIPTION>
    <Rows>
    <Row1>
      <RATE_EFFECTIVE_DT>2013-08-24
    00:00:00.0</RATE_EFFECTIVE_DT>
    <INDEX_NAME>LN-EBOR-7D-AED              
    </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>7D</TERM>
      <TERM_NO>7</TERM_NO>
      <TERM_PERIOD>D</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.15430000</RATE>
    </Row1>
    <Row2>
      <RATE_EFFECTIVE_DT>2013-08-26
    00:00:00.0</RATE_EFFECTIVE_DT>
      <INDEX_NAME>LN-EBOR- 1M-AED  
               </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>1M</TERM>
      <TERM_NO>1</TERM_NO>
      <TERM_PERIOD>M</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.52430000</RATE>
    </Row2>
    <Row3>
      <RATE_EFFECTIVE_DT>2013-08-25
    00:00:00.0</RATE_EFFECTIVE_DT>
    <INDEX_NAME>LN-EBOR-2M-AED              
    </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>2M</TERM>
      <TERM_NO>2</TERM_NO>
      <TERM_PERIOD>M</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.66710000</RATE>
    </Row3>
    <Row4>
      <RATE_EFFECTIVE_DT>2013-08-24
    00:00:00.0</RATE_EFFECTIVE_DT>
      <INDEX_NAME>LN-EBOR-
    3M-AED             
    </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>3M</TERM>
      <TERM_NO>3</TERM_NO>
      <TERM_PERIOD>M</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.86140000</RATE>
    </Row4>
    <Row5>
      <RATE_EFFECTIVE_DT>2011-05-23
    00:00:00.0</RATE_EFFECTIVE_DT>
      <INDEX_NAME>LN-EBOR-
    4M-AED             
    </INDEX_NAME>
      <TYPE>LN</TYPE>
      <RATE_TYPE>EBOR</RATE_TYPE>
      <TERM>4M</TERM>
      <TERM_NO>4</TERM_NO>
      <TERM_PERIOD>M</TERM_PERIOD>
      <CCY>AED</CCY>
      <RATE>0.0</RATE>
    </Row5>
    </Rows>
    </ResultSet>
    The data is comming in multiple row tag with Row1,Row2,Row3...so on.
    I am not able to parse the XML with Row1,Row2..etc. I need some help.

    Do you want to do this using Oracle database (which version?), or some other tools ?

  • 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.

  • 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.

  • XML parsing with digester

    Hi all,
    I'm trying to parse the following xml document:
    <?xml version="1.0" encoding="UTF-8"?>
    <map>
         <entry key='PAGE2.SNOME'>
              <bean key='nomeCliente'>field</bean>
         </entry>
         <entry key='PAGE3.TIPO_CONSTRUCAO'>
              <bean key='tipoConstrucao'>radio</bean>
         </entry>
    </map>with Digester. I'm trying to create a Map that holds Maps as Objects. My first approach was:
    Digester digester = new Digester();
    digester.addObjectCreate("map", HashMap.class);
    digester.addObjectCreate("map/entry", HashMap.class);
    digester.addCallMethod("map/entry", "put", 2);
    digester.addCallParam("map/entry", 0, "key");
    digester.addCallMethod("map/entry/bean", "put", 2);
    digester.addCallParam("map/entry/bean", 0, "key");
    digester.addCallParam("map/entry", 1);But it didn't return the results i expected. Is the order of the instructions wrong? What do i have to change to fix it?
    Hope someone can help me with this.
    Cheers,
    Carlos Ferreira

    Element rootelement = document.getDocumentElement();
    mainNodes = rootelement.getChildNodes();
    for(int i = 0; i<mainNodes.getLength(); i++) {
       Node eachParent = mainNodes.item(i);
       if(!eachParent.getNodeName().equals("#text")) {
          System.out.println(eachParent.getNodeName());
          for(Node child= eachParent.getFirstChild(); child != null; child=child.getNextSibling()) {
             if(!child.getNodeName().equals("#text")) {
                System.out.println(child.getNodeName()+" --- "+child.getFirstChild().getNodeValue());
    }This (your) code will only process the directchild nodes of your rootelement!
    try something like this instead:
    public void processDocument(Document document) {
       processElement(document.getDocumentElement();
    public void processElement(Node node) {
       if(!(node instanceof TextNode)) {
          System.out.println(eachParent.getNodeName());
          NodeList nodeChildren = node.getChildNodes();
          for(int i=0; i<nodeChildren.getLength(); i++) {
             proecessElement(nodeChildren.item(i));
    }

  • XML parsing with DocumentBuilder

    Hi,
    I use to parse an XML document using DocumentBuilder and Document objects.
    When i have within my XML document the following line :
    <value>MY_VALUE</toto>
    How can i get the value "MY_VALUE" using Node objects without searching elements by tag name or criteria ???
    Chris

    Parse document with dom4j parser and get the tag value with xpath.
    http://www.dom4j.org/guide.html

Maybe you are looking for

  • Error when installing NW 7.3 AS Java

    Dear predecessors, There is an error when I installing NW 7.3. In the step of "Create database statistics" when installing Application Server Java after AS ABAP installation, system tips in the fellowing: An error occurred while processing option SAP

  • BUG - FTP with case sensitive server

    My provider uses case sensitive file and directory names. I created a directory 'OtherStuff' on the server directly (not from remote view). In Dreamweaver's FTP setup I erred by specifying the subdirectory of 'otherstuff'. When I created a default ht

  • Wait for rev B?

    Hi, all. What's the word on rev B Intel iMacs? Are they worth waiting for, or are people generally pleased with their rev A? I know there are no certain answers to such questions, but I was just curious what iMac users here thought. I have a great pr

  • Virus related to Unzipping files

    I have a weird problem: Zipped files will not decompress with the BOMArchiveHelper (double clinking on them) but when I use Stuffit expander 2009, the files decompress into some PBeM game called "Big Bang 4-In-A-Row" From Freeverse Software, by Ian L

  • Jsp error:  req cannot be resolved

    Hi I'm trying to run the following error page jsp <%@ page import="javax.servlet.http.*;" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>untitled</title> </head> <body> <%= new java.util.Date().toSt