How to apply condition when parsing XML using XMLTable

Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
XML Response to be processed by stored proc:
<TFSResponse>
<TFS>
          <referenceNumber>39760</referenceNumber>
          <reqId>39760</reqId>
          <fromAccount>
               <id>1550796</id>
               <number>0003210011</number>
          </fromAccount>
          <toAccount>
               <id>1550769</id>
               <number>3199109643</number>
          </toAccount>
          <createdBy>
               <userId>627892</userId>
               <userLoginId>AAAAAA</userLoginId>
               <userTypeId>1</userTypeId>
          </createdBy>
          </TFS>
</TFSResponse>
Register schema script:
DECLARE
l_schema CLOB;
BEGIN
l_schema := '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<xs:element name="TFSResponse" type="TFSResponseWSResponseType" xdb:defaultTable="TEMP_RESULT" />
     <xs:complexType name="TFSResponseWSResponseType">
          <xs:sequence>
          <xs:element maxOccurs="unbounded" name="TFS" type="TFSSummaryWSTO"/>
          </xs:sequence>
     </xs:complexType>
     <xs:complexType name="TFSSummaryWSTO">
          <xs:sequence>
               <xs:element name="referenceNumber" type="xs:string"/>
               <xs:element name="reqId" type="xs:long"/>
               <xs:element name="fromAccount" type="tns:AccountSummaryWSTO" />
<xs:element name="toAccount" type="tns:AccountSummaryWSTO"/>
               <xs:element name="createdBy" type="tns:userWSTO"/>
          </xs:sequence>
     </xs:complexType>
     <xs:complexType name="AccountSummaryWSTO">
          <xs:sequence>
               <xs:element minOccurs="1" name="accountId" type="xs:long" />
               <xs:element minOccurs="1" name="accountNumber" type="xs:string" />
          </xs:sequence>
     </xs:complexType>
     <xs:complexType name="userWSTO">
          <xs:sequence>
               <xs:element name="userId" type="xs:long" />
               <xs:element name="userLoginId" type="xs:string" />
               <xs:element name="userTypeId" type="xs:short" />
          </xs:sequence>
     </xs:complexType>
</xs:schema>';
dbms_xmlSchema.registerSchema(schemaurl => 'TFSWebService_schema.xsd',
schemadoc => l_schema,
enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE);
END;/
Object Type:
CREATE OR REPLACE TYPE DOC_ROWTYPE AS OBJECT
REFERENCENUMBER VARCHAR2(255),
REQID NUMBER(12),
FROMACCOUNTID NUMBER(12),
FROMACCOUNTNUMBER VARCHAR2(35),
TOACCOUNTID NUMBER(12),
TOACCOUNTNUMBER VARCHAR2(35),
CREATEDBYUSERID NUMBER(12),
CREATEDBYUSERLOGINID VARCHAR2(12)
Collection Type:
CREATE OR REPLACE TYPE DOC_TABLETYPE IS TABLE OF DOC_ROWTYPE;
CREATE OR REPLACE PROCEDURE SP_TFS_REPORT (LoginId IN STRING,
requestedByUser IN STRING,
result_cursor OUT SYS_REFCURSOR)
IS
SYSTEM_USER VARCHAR2(12) := 'SYSTEM';
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_string_request VARCHAR2(1024);
l_result_xml XMLTYPE;
docExtTable_XML DOC_TABLETYPE := DOC_TABLETYPE();
docExtRecord DOC_ROWTYPE;
BEGIN
l_string_request := .....(prepare web service request here)
l_http_response := UTL_HTTP.get_response(l_http_request);
resp_in_xml := XMLTYPE(l_clob_response);
INSERT INTO TEMP_RESULT VALUES l_result_xml;
SELECT DOC_ROWTYPE (t1.referenceNumber, t1.reqId, t2.accountId, t2.accountNumber, t3.accountId, t3.accountNumber,
                                             t4.userLoginId, t4.userId)
BULK COLLECT INTO docExtTable_XML
FROM TEMP_RESULT ltr,
XMLTABLE('/TFSResponse/TFS'
PASSING ltr.object_value
COLUMNS
referenceNumber VARCHAR2(255 BYTE) PATH 'referenceNumber',
reqId NUMBER(12)                PATH 'reqId',
fromAccountXML XMLTYPE PATH 'fromAccount',
toAccountXML XMLTYPE      PATH 'toAccount',
createdByXML XMLTYPE      PATH 'createdBy'
) t1,
XMLTABLE('/fromAccount'
PASSING t1.fromAccountXML
COLUMNS
accountId NUMBER(12) PATH 'accountId',
accountNumber VARCHAR2(35 BYTE) PATH 'accountNumber'
) t2,
XMLTABLE('/toAccount'
PASSING t1.toAccountXML
COLUMNS
accountId NUMBER(12) PATH 'accountId',
accountNumber VARCHAR2(35 BYTE) PATH 'accountNumber'
) t3,
XMLTABLE('/createdBy'
PASSING t1.createdByXML
COLUMNS
userId NUMBER(12) PATH 'userId',
userLoginId VARCHAR2(12 BYTE) PATH 'userLoginId' ----- This value should be set based on a condition*
) t4
OPEN result_cursor FOR SELECT * FROM TABLE (DOC_TABLETYPE);
COMMIT;
END SP_TFS_REPORT
The condition is like this
IF (requestedByUser = true and createdByUserType = '2') then
CREATEDBYUSERLOGINID := SYSTEM_USER;
ELSE
     Take CREATEDBYUSERLOGINID from XML value 'userLoginId'
where 'requestedByUser' is the input parameter to the stored procedure and 'createdByUserType' is the value from XML.
'userTypeId' is not required to be set in collection.
Now my question is how to put that condition when doing the XML parsing.
Edited by: 991900 on Mar 19, 2013 9:54 AM

Add a projection for "userTypeId" in T4, then use a CASE statement in the SELECT clause :
SELECT  DOC_ROWTYPE (
        t1.referenceNumber, t1.reqId, t2.accountId, t2.accountNumber, t3.accountId, t3.accountNumber,
                                        t4.userId,
        CASE WHEN requestedByUser = 'true' AND t4.userTypeId = 2
                  THEN system_user
             ELSE t4.userLoginId
        END
BULK COLLECT INTO docExtTable_XML
    FROM TEMP_RESULT ltr,
    XMLTABLE('/TFSResponse/TFS'
               PASSING ltr.object_value
               COLUMNS
                   referenceNumber    VARCHAR2(255 BYTE)        PATH 'referenceNumber',
                   reqId              NUMBER(12)                   PATH 'reqId',                                       
                   fromAccountXML      XMLTYPE                  PATH 'fromAccount',                 
                   toAccountXML        XMLTYPE                     PATH 'toAccount',
                   createdByXML       XMLTYPE                     PATH 'createdBy'                                       
                ) t1,
    XMLTABLE('/fromAccount'
               PASSING t1.fromAccountXML
               COLUMNS
                   accountId              NUMBER(12)    PATH 'accountId', 
                   accountNumber     VARCHAR2(35 BYTE)  PATH 'accountNumber'                                       
               ) t2,
    XMLTABLE('/toAccount'
               PASSING t1.toAccountXML
               COLUMNS
                   accountId            NUMBER(12)    PATH 'accountId', 
                   accountNumber   VARCHAR2(35 BYTE)  PATH 'accountNumber'
               ) t3,
    XMLTABLE('/createdBy'
               PASSING t1.createdByXML
               COLUMNS
                   userId           NUMBER(12)        PATH 'userId',
                   userLoginId      VARCHAR2(12 BYTE) PATH 'userLoginId',
                   userTypeId       NUMBER            PATH 'userTypeId'
               ) t4
    ;

Similar Messages

  • How get DOCTYPE name when parsing XML Doc?

    My XML document has this:
    <!DOCTYPE Users SYSTEM "Users.dtd" []>
    So the name of this document's type is "Users", i.e. it is a Users document. However, I cannot figure out how to get that during parsing! I have set the following (and implemented all the correct interfaces):
         pa.setContentHandler( userHandler );
         pa.setDTDHandler( userHandler );
         pa.setEntityResolver( userHandler );
         pa.setErrorHandler( userHandler );My userHandler object is of class: XMLUserHandler (I made it up) that extends DefaultHandler and implements:
    DTDHandler, EntityResolver, ErrorHandler, ContentHandler
    and overrides all the nec. methods.
    What am I missing? how do I get it to return "Users" from:
    <!DOCTYPE Users SYSTEM "Users.dtd" []>
    or if it was:
    <!DOCTYPE MyDumbName SYSTEM "Users.dtd" []>
    how can I get it to return "MyDumbName"?
    Thank you all for your help in advance!

    For anyone wondering, the answer is to use LexicalHandler. However, they made it "hidden" in the sense that setting this property is not as easy as setting the ContentHandler, for example. Also, not every implementation has to recognize the LexicalHandler. You do it this way:
    //MY CLASS THAT IMPLEMENTS LexicalHandler INTERFACE
    MyLexicalHandler myHandler = new MyLexicalHandler();
    myXMLReader.setProperty( "http://xml.org/sax/properties/lexical-handler", myHandler );then just call "parse()" and it will automatically call your lexical handler, assuming it implements that.
    The main method in LexicalHandler here (i.e. the one that handles what I was looking for) is:
    public void startDTD(String name, String publicId, String systemId) throws SAXException

  • How to ignore DOCTYPE when parsing xml java?

    Hello
    i am trying to parse some sml files that have:
    <!DOCTYPE ModuleRoot SYSTEM "C:\xxx\xmlapp.dtd">
    i don;t have the dtd file
    how can i ignore it by changing my code and not changing the xml file.
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    this.doc = documentBuilder.parse(xmlFileName);
    i got exception in this.doc = documentBuilder.parse(xmlFileName);
    (The system cannot find the path specified)
    Thanks in advance.

    You need to create an EntityResolver that returns a dummy DTD. Since you aren't actually validating, this can be as simple as:
            db.setEntityResolver(new EntityResolver()
                public InputSource resolveEntity(String publicId, String systemId)
                    throws SAXException, IOException
                    return new InputSource(new StringReader(""));
            });For more information, here's an article that I wrote on [XML parsing and validation|http://www.kdgregory.com/index.php?page=xml.parsing].

  • How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?

    How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?
    Hi,
    I do generate XML-Files by using DBMS_XMLGEN with output by UTL_FILE
    but it seems, the xml-Datafile I get on end is not really UTF-8 encoding
    ( f.ex. cannot verifying it correct in xmlspy )
    my dbms is
    NLS_CHARACTERSET          = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET     = AL16UTF16
    NLS_RDBMS_VERSION     = 10.2.0.1.0
    I do generate it in this matter :
    declare
    xmldoc CLOB;
    ctx number ;
    utl_file.file_type;
    begin
    -- generate fom xml-view :
    ctx := DBMS_XMLGEN.newContext('select xml from xml_View');
    DBMS_XMLGEN.setRowSetTag(ctx, null);
    DBMS_XMLGEN.setRowTag(ctx, null );
    DBMS_XMLGEN.SETCONVERTSPECIALCHARS(ctx,TRUE);
    -- create xml-file:
    xmldoc := DBMS_XMLGEN.getXML(ctx);
    -- put data to host-file:
    vblob_len := DBMS_LOB.getlength(xmldoc);
    DBMS_LOB.READ (xmldoc, vblob_len, 1, vBuffer);
    bHandle := utl_file.fopen(vPATH,vFileName,'W',32767);
    UTL_FILE.put_line(bHandle, vbuffer, FALSE);
    UTL_FILE.fclose(bHandle);
    end ;
    maybe while work UTL_FILE there is a change the encoding ?
    How can this solved ?
    Thank you
    Norbert
    Edited by: astramare on Feb 11, 2009 12:39 PM with database charsets

    Marco,
    I tryed to work with dbms_xslprocessor.clob2file,
    that works good,
    but what is in this matter with encoding UTF-8 ?
    in my understandig, the xmltyp created should be UTF8 (16),
    but when open the xml-file in xmlSpy as UTF-8,
    it is not well ( german caracter like Ä, Ö .. ):
    my dbms is
    NLS_CHARACTERSET = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET = AL16UTF16
    NLS_RDBMS_VERSION = 10.2.0.1.0
    -- test:
    create table nh_test ( s0 number, s1 varchar2(20) ) ;
    insert into nh_test (select 1,'hallo' from dual );
    insert into nh_test (select 2,'straße' from dual );
    insert into nh_test (select 3,'mäckie' from dual );
    insert into nh_test (select 4,'euro_€' from dual );
    commit;
    select * from nh_test ;
    S0     S1
    1     hallo
    1     hallo
    2     straße
    3     mäckie
    4     euro_€
    declare
    rc sys_refcursor;
    begin
    open rc FOR SELECT * FROM ( SELECT s0,s1 from nh_test );
    dbms_xslprocessor.clob2file( xmltype( rc ).getclobval( ) , 'XML_EXPORT_DIR','my_xml_file.xml');
    end;
    ( its the same when using output with DBMS_XMLDOM.WRITETOFILE )
    open in xmlSpy is:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <S0>1</S0>
    <S1>hallo</S1>
    </ROW>
    <ROW>
    <S0>2</S0>
    <S1>straޥ</S1>
    </ROW>
    <ROW>
    <S0>3</S0>
    <S1>m㢫ie</S1>
    </ROW>
    <ROW>
    <S0>4</S0>
    <S1>euro_€</S1>
    </ROW>
    </ROWSET>
    regards
    Norbert

  • I purchased the teacher and student lightroom 5. I put in my code and uploaded my evidence to show that I am a teacher. I am guessing it was sent through to someone. How do I know when I can use the software? I don't understand what to do next.

    I purchased the teacher and student lightroom 5. I put in my code and uploaded my evidence to show that I am a teacher. I am guessing it was sent through to someone. How do I know when I can use the software? I don't understand what to do next.

    Please refer below link for more information
    Education FAQ

  • How to apply paragraph styles to xml tag?

    Hi All,
    How to apply paragraph style to xml tag?

    Hi Learner,
    Try the below js code.
    var myDoc = app.activeDocument;
    try{
        mySel=app.selection[0];
        myDoc.xmlElements[0].xmlElements.add({markupTag:"TEST", xmlContent:mySel});
        }catch(e){
            alert(e);
    var myDocument = app.activeDocument;
    app.findGrepPreferences.appliedParagraphStyle = "test";
    app.findGrepPreferences.findWhat = ".+(?=\\r)"
    var mySearch = myDocument.findGrep(false);
    for (a=0; a<mySearch.length; a++){
        myDocument.xmlElements[0].xmlElements.add({markupTag:"TEST", xmlContent:mySearch[a]});
    thx,
    csm_phil

  • How to parse XML using SAX Parser sequencially

    I have a requirement to parse XML file sequencially. But I need to stop the parsing in-between for doing some processing.
    Let me explain with example
    I have a file with following structure.
    <InputFile>
    <Invoice>
         <InvoiceNo = "Inv1"/>
    <InvoiceDt = "12012002"/>
    </Invoice>
    <Invoice>
         <InvoiceNo = "Inv2"/>
    <InvoiceDt = "12012002"/>
    </Invoice>
    <Invoice>
         <InvoiceNo = "Inv3"/>
    <InvoiceDt = "12012002"/>
    </Invoice>
    For each Invoice node I need to process some activites. So I need to write a method which will open the XML file and parse and returns me a complete element from <invoice> to </Invoice> sequencially.
    Please let me know whther some body has solution for this.
    Manoj.

    If you're using a SAX parser then you can implement your code in the startElement(), endElement(), and characters() methods... have a look at the tutorial here:
    http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/index.html

  • Parsing Xml using Jdom

    Hi all,
    I am reposting it as I was told to format the code and send it again.
    I am trying to parse a xml file using a jdom java code.This code works fine if I remove xmlns attribute in the root element. (I get the expected result) .If the "xmlns" attribute is put in the xml as it should be then the parsing and retrieving returns null. Please tell me how to fix this issue.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Xml
    <process name="CreateKBEntryService" targetNamespace="http://serena.com/CreateKBEntryService" suppressJoinFailure="yes" xmlns:tns="http://serena.com/CreateKBEntryService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:nsxml0="http://localhost:8080/axis/services/CreateKBEntryService" xmlns:nsxml1="http://DefaultNamespace" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="tns:CreateKBEntryService" myRole="CreateKBEntryServiceProvider"/>
    <partnerLink name="CreateKBEntryPartnerLink" partnerLinkType="nsxml0:CreateKBEntryLink" partnerRole="CreateKBEntryProvider"/>
    </partnerLinks>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
    Java:
    import java.io.*;
    import java.util.*;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.input.SAXBuilder;
    public class sample1 {
    public static void main(String[] args) throws Exception {
    // create a XML parser and read the XML file
    SAXBuilder oBuilder = new SAXBuilder();
    Document oDoc = oBuilder.build(new File("**xml file location**"));
    Element root = oDoc.getRootElement();
    System.out.println(root.getName());
    String tgtns= root.getAttributeValue("targetNamespace");
    System.out.println("tgt ns "+ tgtns);
    List list= root.getChildren("partnerLinks");
    Iterator it1= list.iterator();
    System.out.println("Iterator 1 - "+list.size());
    while(it1.hasNext()){
    Element partnerlinks = (Element)it1.next();
    List list2= partnerlinks.getChildren("partnerLink");
    System.out.println("iterator 2 - "+list2.size());
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Result:
    Without Xmlns in xml file(Expected and correct output)
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 1//expected and correct result that comes when I remove xmlns attribute from xml
    iterator 2 - 2
    Result with xmlns:
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 0 //instead of 0 should return 1

    Hi all,
    I am reposting it as I was told to format the code and send it again.
    I am trying to parse a xml file using a jdom java code.This code works fine if I remove xmlns attribute in the root element. (I get the expected result) .If the "xmlns" attribute is put in the xml as it should be then the parsing and retrieving returns null. Please tell me how to fix this issue.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Xml
    <process name="CreateKBEntryService" targetNamespace="http://serena.com/CreateKBEntryService" suppressJoinFailure="yes" xmlns:tns="http://serena.com/CreateKBEntryService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:nsxml0="http://localhost:8080/axis/services/CreateKBEntryService" xmlns:nsxml1="http://DefaultNamespace" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="tns:CreateKBEntryService" myRole="CreateKBEntryServiceProvider"/>
    <partnerLink name="CreateKBEntryPartnerLink" partnerLinkType="nsxml0:CreateKBEntryLink" partnerRole="CreateKBEntryProvider"/>
    </partnerLinks>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
    Java:
    import java.io.*;
    import java.util.*;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.input.SAXBuilder;
    public class sample1 {
    public static void main(String[] args) throws Exception {
    // create a XML parser and read the XML file
    SAXBuilder oBuilder = new SAXBuilder();
    Document oDoc = oBuilder.build(new File("**xml file location**"));
    Element root = oDoc.getRootElement();
    System.out.println(root.getName());
    String tgtns= root.getAttributeValue("targetNamespace");
    System.out.println("tgt ns "+ tgtns);
    List list= root.getChildren("partnerLinks");
    Iterator it1= list.iterator();
    System.out.println("Iterator 1 - "+list.size());
    while(it1.hasNext()){
    Element partnerlinks = (Element)it1.next();
    List list2= partnerlinks.getChildren("partnerLink");
    System.out.println("iterator 2 - "+list2.size());
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Result:
    Without Xmlns in xml file(Expected and correct output)
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 1//expected and correct result that comes when I remove xmlns attribute from xml
    iterator 2 - 2
    Result with xmlns:
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 0 //instead of 0 should return 1

  • Flash Player 10 removes HTML encoding in CDATA when parsing XML

    I have an application that was written with Flash Professional 8/AS2 and it parses XML for rendering dynamic media content. The XML pulls text with HTML markup out of CDATA sections and places them into an html enabled text field. Everything has worked wonderfully until Flash Player 10.
    Now, if we use html escape characters for greater than or less than symbols, they are being decoded by the xml parser.
    Here's my example CDATA section:
    Here <u>we</u> go: This &#60;node&#62; &lt;works&gt; 
    when I grab its value using nodeValue or toString, the results are different from Flash Player 9 to 10. Here's what I'm getting:
    node.nodeValue (Flash Player 9):
    Here <u>we</u> go: This &#60;node&#62; <works>
    node.nodeValue (Flash Player 10):
    Here <u>we</u> go: This <node> <works>
    node.toString (Flash Player 9):
    Here <u>we</u> go: This &#60;node&#62; &lt;works&gt;
    node.toString (Flash Player 10):
    Here <u>we</u> go: This <node> <works>
    In Flash 10, if I escape the ampersand, it will work, but this doesn't work in 9. for example, the following works in 10:
    <![CDATA[Here <u>we</u> go: This &amp;#60;node&amp;#62; &amp;lt;works&amp;gt;]]>
    This all happens before I assign it to a text field. How do I keep the parser from destroying my escaped characters in Flash 10? Do I just need to drop support for Flash Player 9 and go for what works in 10, or is there a solution for both?
    Message was edited by: Xygar

    I'm not an action script programmer. I'm just trying to fix some code written like 3 years ago. So I think I am wrong about where this problem is coming from.
    The original developer actually set up a class to load a remote xml file via sendAndLoad on a LoadVars object. It passes an object with an onData delegate set that passes the event object to an xml parsing method.
    the parsing method looks like this:
         private function parseXml(eventObj:Object){
              if(eventObj != undefined)
                   try
                        //ExternalInterface.call("logMessage", eventObj.toString());
                        _xmlDoc.parseXML(eventObj.toString());
                        _xmlDoc.loaded = true;
                        _xmlDoc.onLoad(true);
                   catch(ex)
                        _xmlDoc.onLoad(false);
              else
                   _xmlDoc.onLoad(false);
    I added the ExternalInterface call so that I could log the stuff out in javascript (since I'm not sure how to debug this app).
    _xmlDoc is defined as: private var _xmlDoc:XML;
    The eventObj receives the xml string and then passes it to the parseXML thing. Here's the odd part. In Flash Player 10, if I comment out my ExternalInterface call, the xml string has the escaped character decoded before it gets to the parser.
    However, if I uncomment my ExternalInterface call, it logs the escaped strings as i would expect, but the parser gets the correct formatting this time! Suddenly it all works.
    I really wish I had an AS2 programmer on campus still....

  • Persisting unexplained errors when parsing XML with schema validation

    Hi,
    I am trying to parse an XML file including XML schema validation. When I validate my .xml and .xsd in NetBeans 5.5 beta, I get not error. When I parse my XML in Java, I systematically get the following errors no matter what I try:
    i) Document root element "SQL_STATEMENT_LIST", must match DOCTYPE root "null".
    ii) Document is invalid: no grammar found.
    The code I use is the following:
    try {
    Document document;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(true);
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse( new File(PathToXml) );
    My XML is:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!-- Defining the SQL_STATEMENT_LIST element -->
    <xs:element name="SQL_STATEMENT_LIST" type= "SQL_STATEMENT_ITEM"/>
    <xs:complexType name="SQL_STATEMENT_ITEM">
    <xs:sequence>
    <xs:element name="SQL_SCRIPT" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <!-- Defining simple type ApplicationType with 3 possible values -->
    <xs:simpleType name="ApplicationType">
    <xs:restriction base="xs:string">
    <xs:enumeration value="DawningStreams"/>
    <xs:enumeration value="BaseResilience"/>
    <xs:enumeration value="BackBone"/>
    </xs:restriction>
    </xs:simpleType>
    <!-- Defining the SQL_SCRIPT element -->
    <xs:element name="SQL_SCRIPT" type= "SQL_STATEMENT"/>
    <xs:complexType name="SQL_STATEMENT">
    <xs:sequence>
    <xs:element name="NAME" type="xs:string"/>
    <xs:element name="TYPE" type="xs:string"/>
    <xs:element name="APPLICATION" type="ApplicationType"/>
    <xs:element name="SCRIPT" type="xs:string"/>
    <!-- Making sure the following element can occurs any number of times -->
    <xs:element name="FOLLOWS" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    and my XML is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    Document : SQLStatements.xml
    Created on : 1 juillet 2006, 15:08
    Author : J�r�me Verstrynge
    Description:
    Purpose of the document follows.
    -->
    <SQL_STATEMENT_LIST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://www.dawningstreams.com/XML-Schemas/SQLStatements.xsd">
    <SQL_SCRIPT>
    <NAME>CREATE_PEERS_TABLE</NAME>
    <TYPE>CREATION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    CREATE CACHED TABLE PEERS (
    PEER_ID           VARCHAR(20) NOT NULL,
    PEER_KNOWN_AS      VARCHAR(30) DEFAULT ' ' ,
    PRIMARY KEY ( PEER_ID )
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>CREATE_COMMUNITIES_TABLE</NAME>
    <TYPE>CREATION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    CREATE CACHED TABLE COMMUNITIES (
    COMMUNITY_ID VARCHAR(20) NOT NULL,
    COMMUNITY_KNOWN_AS VARCHAR(25) DEFAULT ' ',
    PRIMARY KEY ( COMMUNITY_ID )
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>CREATE_COMMUNITY_MEMBERS_TABLE</NAME>
    <TYPE>CREATION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    CREATE CACHED TABLE COMMUNITY_MEMBERS (
    COMMUNITY_ID VARCHAR(20) NOT NULL,
    PEER_ID VARCHAR(20) NOT NULL,
    PRIMARY KEY ( COMMUNITY_ID, PEER_ID )
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>DROP_PEER_TABLE</NAME>
    <TYPE>DELETION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    DROP TABLE PEERS IF EXISTS
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>DROP_COMMUNITIES_TABLE</NAME>
    <TYPE>DELETION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    DROP TABLE COMMUNITIES IF EXISTS
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>DROP_COMMUNITY_MEMBERS_TABLE</NAME>
    <TYPE>DELETION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    DROP TABLE COMMUNITY_MEMBERS IF EXISTS
    </SCRIPT>
    </SQL_SCRIPT>
    <SQL_SCRIPT>
    <NAME>CREATE_COMMUNITY_MEMBERS_VIEW</NAME>
    <TYPE>CREATION</TYPE>
    <APPLICATION>DawningStreams</APPLICATION>
    <SCRIPT>
    CREATE VIEW COMMUNITY_MEMBERS_VW AS
    SELECT P.PEER_ID, P.PEER_KNOWN_AS, C.COMMUNITY_ID, C.COMMUNITY_KNOWN_AS
    FROM PEERS P, COMMUNITIES C, COMMUNITY_MEMBERS CM
    WHERE P.PEER_ID = CM.PEER_ID
    AND C.COMMUNITY_ID = CM.COMMUNITY_ID
    </SCRIPT>
    <FOLLOWS>CREATE_PEERS_TABLE</FOLLOWS>
    <FOLLOWS>CREATE_COMMUNITIES_TABLE</FOLLOWS>
    </SQL_SCRIPT>
    </SQL_STATEMENT_LIST>
    Any ideas? Thanks !!!
    J�r�me Verstrynge

    Hi,
    I found the solution in the following post:
    Validate xml with DOM - no grammar found
    Sep 17, 2003 10:58 AM
    The solution is to add a line of code when parsing:
    try {
    Document document;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(true);
    factory.setNamespaceAware(true);
    factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse( new File(PathToXml) );
    The errors are gone !!!
    J�r�me Verstrynge

  • Problem in parsing XML using DOM Parser.

    Hi,
    I am parsing an XML using DOM Parser.
    When i try to get attributes of a node, i dont get in the order it is written. For Eg. This the node:
    <Level0 label="News" link="/website/ing_news.nsf/ViewNewsForm?OpenForm&All" level="202" uid="COGN-4MNMT3" parentid="aaaa">
    When i try to print the attribute values i should get in the order:
    News, /website/ing_news.nsf/ViewNewsForm?OpenForm&All, 202, COGN-4MNMT3, aaaa
    BUT I AM GETTING IN THE ORDER:
    News, 202, /website/ing_news.nsf/ViewNewsForm?OpenForm&All, aaaa, COGN-4MNMT3
    Is there any way to sort this problem out?
    Thanks and Regards,
    Ashok

    Hi Guys,
    Thanks a lot for your replies.
    But i want to keep all the values as attributes only.
    the XML file is as shown below:
    <Menu>
    <Level0 label="News" link="/website/ing_news.nsf/ViewNewsForm?OpenForm&All" level="202" uid="COGN-4MNMT3" parentid="aaaa" children="3">
         <Level1 label="ING News" link="" level="1" uid="COGN-4MNN89" parentid="COGN-4MNMT3" children="3" >
              <Level2 label="All ING News" link="/website/ing_news.nsf/ViewNewsForm?OpenForm&All" level="2" uid="INGD-4MVTK2" parentid="COGN-4MNN89" children="0">
              </Level2>
    </Level1>
    </Level0>
    The code i was using to get attributes is:
    String strElementName = new String(node.getNodeName());
         // System.out.println("strElementName:"+node.getNodeName());
    NamedNodeMap attrs = node.getAttributes();
    if (attrs != null) {
    int iLength = attrs.getLength();
    for (int i = 0; i < iLength; i++) {
    String strAttributes = (String) attrs.item(i).getNodeName();
    String strValues = (String) attrs.item(i).getNodeValue();
    Also is it not possible to Enforce the order using some Schema/DTD in this case?
    TIA
    Ashok

  • Error in Parsing XML using fx:XML/ [Error- 1090: XML parser failure: element is malformed]

    Hi All,
    I am getting error while loading XML in <fx:XML> tag.
    Error:
    TypeError: Error #1090: XML parser failure: element is malformed.
    MXML Code:
    <fx:Declarations>
    <fx:XML id="xmlSource2" source="sample.xml"/>
    </fx:Declarations>
    Sample XML Used: (sample.xml)
    <?xml version="1.0" encoding="UTF-8"?>
    <File>
        <Chemical id="000035676" displayFormula="C39-H45-N2-O6"
            displayName="Dimethyltubocurarine">
            <NameList>
                <NameOfSubstance>
                    Dimethyltubocurarine
                    <SourceList>
                        <Source>MESH</Source>
                    </SourceList>
                </NameOfSubstance>
                <SystematicName>
                    Tubocuraranium, 6,6',7',12'-tetramethoxy-2,2',2'-trimethyl-
                    <SourceList>
                        <Source>NLM</Source>
                    </SourceList>
                </SystematicName>
                <Synonyms>
                    Dimethyltubocurarine
                    <SourceList>
                        <Source>NLM</Source>
                    </SourceList>
                </Synonyms>
                <Synonyms>
                    Dimethyltubocurarinium
                    <SourceList>
                        <Source>NLM</Source>
                    </SourceList>
                </Synonyms>
                <Synonyms>
                    Methyltubocurarinum
                    <SourceList>
                        <Source>NLM</Source>
                    </SourceList>
                </Synonyms>
            </NameList>
            <NumberList>
                <CASRegistryNumber>
                    35-67-6
                    <SourceList></SourceList>
                </CASRegistryNumber>
                <RelatedRegistryNumber>
                    518-26-3 (iodide.hydriodide)
                    <SourceList>
                        <Source>MESH</Source>
                    </SourceList>
                </RelatedRegistryNumber>
            </NumberList>
            <ClassificationList>
                <ClassificationCode>
                    Neuromuscular nondepolarizing agents
                    <SourceList>
                        <Source>MESH</Source>
                    </SourceList>
                </ClassificationCode>
            </ClassificationList>
            <FormulaList>
                <MolecularFormula>
                    C39-H45-N2-O6
                    <SourceList>
                        <Source>NLM</Source>
                    </SourceList>
                </MolecularFormula>
            </FormulaList>
            <FormulaFragmentList></FormulaFragmentList>
            <NoteList></NoteList>
            <LocatorList>
                <FileLocator
                    url="http://cnetdb.nci.nih.gov/cgi-bin/srchcgi.exe?DBID=****3&SFMT=****_basic%2F10%2F0%2F0&TYPE=search&SRCHFORM=passthru%3D%Asrchform%3ASRCH%3A&FIELD_001=[CAS]35-67-6&#38;GoButton=Search&#38;FIELD_001_CTL=EXPR&#38;FIELD_908=&#38;FIELD908_CTL=HASABSTRACT&#38;FIELD_903=&#38;FIELD_903_CTL=YEARFORE&#38;DOCPAGE=10">CANCERLIT</FileLocator>
                <FileLocator
                    url="http://toxnet.nlm.nih.gov/cgi-bin/sis/search/r?dbs+toxline:@and+@term+@rn+35-67-6+@term+@org+DART">DART/ETIC</FileLocator>
                <FileLocator
                    url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db=PubMed&term=35-67-6[ECNO]+OR+&#34;~&#34;[MH]">MEDLINE</FileLocator>
                <FileLocator
                    url="http://www.nlm.nih.gov/cgi/mesh/2K/MB_cgi?term=35-67-6&rn=1">MESH</FileLocator>
                <FileLocator
                    url="http://toxnet.nlm.nih.gov/cgi-bin/sis/search/r?dbs+toxline:@term+@rn+35-67-6+@OR+@mh+""">TOXLINE</FileLocator>
            </LocatorList>
        </Chemical>
    </File>
    Also, when I am using HttpService to load same XML I am getting no such error!!
    <s:HTTPService id="employeeService"
                           url="sample.xml"
                           result="employeeService_resultHandler(event)"
                           fault="employeeService_faultHandler(event)"/>
    Please help!!
    Thanks.
    Abhinav

    I think url in XML is creating problem here.
    <FileLocator
                    url="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db=PubMed&term=23-95-0[ECNO]+OR+&#34;~&#34;[MH]">MEDLINE</FileLocator>
    Is there any way to parse this XML using <fx:XML/> ??
    Thanks.

  • Parsing xml using DOM parser in java

    hi there!!!
    i don have much idea about parsing xml.. i have an xml file which consists of details regarding indentation and spacing standards of C lang.. i need to read the file using DOM parser in java n store each of the attributes n elements in some data structure in java..
    need help as soon as possible!!!

    DOM is the easiest way to parse XML document, google for JDOM example it is very easy to implement.
    you need to know what is attribute, what is text content and what is Value in XML then easily you can parse your document with dom (watch for space[text#] in your XML document when you parse it).
    you get root node then nodelist of childs for root then go further inside, it is easy believe me.

  • Importing/Parsing XML using SQL and/or PL/SQL

    What is the recomended way of importing/parsing XML data using SQL and/or PL/SQL?
    I have an XSD that defines the structure of the file, and an XML file that has the content in the appropriate structure. I have parsed (checked) the structure of the XML file using JDOM in my java application, and then passed it to a function in a package on the database as a CLOB.
    What I need to do is parse the contents of the XML file that is passed into the function and extract the values of each XML element so that I can then do some appropriate validation before inserting and committing the data to the database (hence completing the import function).
    A DBA colleague of mine has been experimenting with various ways of acheiving this, but has encountered a number of problems along the way, one of which being that he thinks that it is not possible to parse XML elements that are nested more than four levels deep - is this the case?
    The structure of the XSD/XML that the database function needs to manipulate and import data from is very complex (and recursive by it's nature).
    I would appreciate any suggestions as to how I can achieve the above in the most efficient manner.
    Thanks in advance for your help
    David

    This is the forum for the SQLDeveloper tool. You will get better answers in the SQL and PL/SQL forum, and especially the XML DB forum.
    Oracle has comprehensive and varied support for XML, including a PL/SQL parser.

  • Parsing xml using j2me

    hi
    how can i insert into file xml in midlet for exemple
    <users>
    <user>
    <name>manel<name>
    </user>
    </users>
    it will be
    <users>
    <user>
    <name>manel<name>
    </user>
    <user>
    <name>hajer<name>
    </user>
    </users>
    thx

    You can use kxml for this.
    Regards,
    David.

Maybe you are looking for

  • Dreamweaver hangs up after opening files

    Hi, I have only had this problem since I started using Dreamweaver CS5.5. Before this I was using an earlier Macromedia version (on an older Windows 2000 PC) and never had any problems. It usually happens shortly after I open a file for editing - mos

  • Flashplayer doesn't work on some sites, but works on others?

    There are a lot of sites on which the flashplayer doesn't work, eventhough I have the latest version installed. It does work on youtube for example. Please help me!

  • Deploy a web page in webserver

    How can I deploy my web page in web server without the need of going for a build of war file

  • Transfer entries in Table Control

    Plz tell me how can i transfter entries made in table control into an inertnal table. so that I could save all entries of table control into database. Regards....

  • Equivalent of sys/ptrace.h on Solaris 10

    HI, We are using the <sys/ptrace.h> as par to our shell scripts. This file, <sys/ptrace.h> is supported both on Linux and Solaris 8. But somehow it's missing in Solaris 10 and I heard it's supported. Is it true?? Please could somebody who has worked