Parse attributes of a XML file

Hi My XML file is in the follwoing format
I have to extract all the autoloadid's at the CFTSContract level
so my sql output needs to be some thing like this
AUTOLOADID
1125
1126
1127
1128
etc ........
can any please help me how to right a sql to extract all the autoload id's at the CFTSContract level.
<?xml version="1.0" encoding="WINDOWS-1252"?>
<gbi:CFTSBillingRecordList country="ALL" company="ALL" senderId="ISSORCL" installationId="" applicatonId="GBI" cycleNumber="unique number" timeSent="HHMMYY" recordCount="unique number" returnCode="" returnText="" xsi:schemaLocation="http://w3-3.ibm.com/services/cft-s schema/CFTSBillingInterface.xsd" xmlns:gbi="http://w3-3.ibm.com/services/cft-s" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CFTSContract ContractType="IS" autoloadid="1125" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
<CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
<CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
</CFTSContract>
<CFTSContract ContractType="IS" autoloadid="1126" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
<CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
<CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
</CFTSContract>
<CFTSContract ContractType="IS" autoloadid="1127" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
<CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
<CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
<CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
</CFTSContract>
<CFTSContract ContractType="IS" autoloadid="1128" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
<CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
<CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
</CFTSContract>
<CFTSContract ContractType="IS" autoloadid="1129" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
<CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
<CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
<CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
</CFTSContract>
</gbi:CFTSBillingRecordList>
Thanks

SQL> with t as (select to_clob('<?xml version="1.0" encoding="WINDOWS-1252"?>
  2  <gbi:CFTSBillingRecordList country="ALL" company="ALL" senderId="ISSORCL" installationId="" applicatonId="GBI" cycleNumber="unique number" timeSent="HHMMYY" recordCount="unique number" returnCode="" returnText="" xsi:schemaLocation="http://w3-3.ibm.com/services/cft-s schema/CFTSBillingInterface.xsd" xmlns:gbi="http://w3-3.ibm.com/services/cft-s" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  3  <CFTSContract ContractType="IS" autoloadid="1125" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
  4  <CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
  5  <CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
  6  </CFTSContract>
  7  <CFTSContract ContractType="IS" autoloadid="1126" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
  8  <CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
  9  <CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
10  </CFTSContract>
11  <CFTSContract ContractType="IS" autoloadid="1127" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
12  <CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
13  <CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
14  <CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
15  </CFTSContract>')||
16  to_clob('<CFTSContract ContractType="IS" autoloadid="1128" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
17  <CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
18  <CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
19  </CFTSContract>
20  <CFTSContract ContractType="IS" autoloadid="1129" expirationdate="" Division="8F" Area="ISS" ServiceCenter="ISS" customertype="TAX Exempt Flag A or J" Startdate="11-FEB-06" enddate="" ibmAcceptanceDate="11-FEB-06" CustomerSignDate="10-FEB-06" OpportunityNumber="" channelindicator="" competency="BR" businesstransactiontype="1" excemptioncode="10" pocindicator="N" consolidationcustomertype="TAX Exempt Flag A or J" ISSSalesRepName="" ISSSalesRepphone="" paymentmethod="" eposnumber="">
21  <CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
22  <CFTSWorknumber servicetype="IC" startdate="11-FEB-06" enddate="11-FEB-07" customertype="TAX Exempt Flag A or J" customercontrol="00" businesstype="IS8F" division="8F" exemptioncode="" opportunitynumber="" eposnumber=""/>
23  <CFTSContractAmount billingAmount="0" currencyId="JPY" actionCode="" returnCode=""/>
24  </CFTSContract>
25  </gbi:CFTSBillingRecordList>') str from dual)
26  --
27  select extractvalue(column_value,'//@autoloadid') autoloadid from t,table(xmlsequence(extract(xmltype(str),'//CFTSContract')))
28  /
AUTOLOADID
1125
1126
1127
1128
1129
SQL>

Similar Messages

  • How to get nodes and its attributes of an XML file usiong DOM parsing?

    how to get nodes and its attributes of an XML file usiong DOM parsing?
    i am new to XML parsing.......
    Thanking you........

    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;      ...
    //Setup the document
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
         Document doc = docBuilder.parse (new File("MY_XML_FILE.xml"));
    //get elemets by name
         String elementValue = doc.getElementsByTagName("MY_ELEMENT").item(0).getTextContent();
    //This method can return multiple nodes, in this instance I get item(0) , first nodeRead the api for other methods of getting data.

  • How to change the attributes of an XML file

    hi peeps 'ope you can help me here i need to change the attributes of an xml file, i parse it first using a DOM parser but i cant find a way to change the attributes in the XML file, setAttribute() works only at runtime and doesn't change the attribute in the file itself. I can't find a method that will answer my question. I've searched through the forum and found similar threads....they say in order to write and change the attribute i must use the write() method of the XmlDocument class defined in com.sun.xml.tree.XmlDocument. But, i found another thread, and it says that com.sun.xml.tree.XmlDocument is not safe to use and i should use org.apache.crimson.tree.XmlDocument.....i can't find the XmlDocument class and the API for this package so i really dont know where to start...hope you guys can help me! thnx

    thanks for responding roland....i already found the solution...i didn't use the XmlDocument class because i can't find any documents about it except for JAXP 1.0 here is my code snippet...i used the TransformerFactory and Transformer class to write
    import org.w3c.dom.*;
    import org.w3c.dom.traversal.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    Document doc = null;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    dbf.setValidating(false);
    doc = db.parse(fileGetFile); //this is the XML file
    n1 = (Node)doc.getDocumentElement();
    e1 = (Element) n1;
    NodeList nodeList = doc.getElementsByTagName ("File");
    //just insert whatever you want to do with the XML...parse it..set/change the attribute..etc....sample snippet below changes the attribute downloaded to "no"
    for(int iWriteFailed = 0; iWriteFailed <nodeList.getLength() ; iWriteFailed ++){     
    n2 = nodeList.item(iWriteFailed);
    e2 = (Element) n2;          
    e2.setAttribute("downloaded", "no");}
    try{
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(new DOMSource(doc), new StreamResult ( new FileOutputStream ( fileGetFile) ) );}
    catch(Exception trans){}
    thanks for responding and keeping the information interchange alive here in the forum...
    Pau

  • How do you make Xerces parser generate doctype to XML-file?

    When I use javacode (with xerces parser) to update an XML-file the doctype-line disappears!!!!
    Anyone how knows how to solve this problem????
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE test SYSTEM "StatisticStandard.dtd"> <---- This is the line I want to keep!!!
    <test>
    <totalanswered>5</totalanswered>
    <set>
    <alt>1</alt>
    </set>
    </test>

    Hi!
    I found a sort of solution to my problem. I don't think it is the best, but it works!
    Where you write to file you add this line (look for the arrow).
    (I use the javax.xml.transform package)
    Source xmlSource = new DOMSource(document);
    Result result = new StreamResult(
    new FileOutputStream(path+file));
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(javax.xml.transform.OutputKeys.DOCTYPE_SYSTEM, "dtdfilename.dtd"); <-- This one does the trick!!!
    transformer.transform(xmlSource, result);
    Anette :)

  • Parser dimension ACCOUNT's xml file error.

    Hi friends,
    i manully uploading master data in ACCOUNT dimension.
    what i did here, i manually added PARENTH1hierarchy and i changed that column position infront of "ACCTYPE" property. While pasting i might paste on ACCTYPE property & processed ACCOUNT dim.So it gone and disturbed underlying XML file. I checked 3 files XLS,XLT and XML files in UJFS. But XLS & XLT doesn't have ACCTYPE property. So how can i put it back? Any suggestions pls.
    Eventhough ACCTYPE dim property defined and existed(under maintain dim property of ACCOUNT dim). when i try to check maintain members data for manually entering data, it not available in columns. when i try to process ACCOUT dim, system saying below error message. 
    Parser dimension ACCOUNT's xml file error.
    How to correct this error.?
    Thanks,
    Naresh
    Edited by: Naresh P on Jan 13, 2011 7:20 AM

    Hi,
    It will be better to delete the XML file from UJFS and process your dimension once again. However, it might happen that you are still unable to edit the membersheet. In that case, it will be advisable to take a backup of the member sheet and recreate the same member sheet once again.
    Hope this helps.

  • HO w to use SAX parser to create an XML file on the fly

    Hi All,
    Currently I am using the DOM parser to create an XML file from a text file. But as the DOM takes much memory and inefficient, I need to convert the DOM translator to SAX translator. Can I do that ?? If YES then how to go about that and if NO then what may be the workaround for that.
    Please help me out
    Thanx in advance
    kaushik

    Incidentally, look at this thread:
    http://forum.java.sun.com/thread.jsp?forum=34&thread=252415
    It has an example of how to transform an XML file via XSLT. If you change this to use the zero-argument form of newTransformer, it will apply the "identity transformation" to your input, thus outputting your XML in valid form. Now you just need to figure out how to provide SAX input to this, and the JAXP download includes an example of that.

  • SQL*Loader problem - not efficient, parsing error for big xml files

    Hi Experts,
    First of all, I would like to store xml files in object relation way. Therefore I created a schema and a table for it (see above).
    I wants to propagate it (by using generated xml files), hence I created a control file for sql loader (see above).
    I have two problems for it.
    1, It takes a lot of time. It means I can upload a ~80MB file in 2 hours and a half.
    2, At bigger files, I got the following error messages (OCI-31011: XML parsing failed OCI-19202: Error occurred in XML processing LPX-00243: element attribute value must be enclosed in quotes). It is quite interesting because my xml file is generated and I could generated and uploaded the first and second half of the file.
    Can you help me to solve these problems?
    Thanks,
    Adam
    Control file
    UNRECOVERABLE
    LOAD DATA
    CHARACTERSET UTF8
    INFILE *
    APPEND
    INTO TABLE coll_xml_objrel
    XMLTYPE(xml)
    FIELDS
    ident constant 2
    ,file_name filler char(100)
    ,xml LOBFILE (file_name) TERMINATED BY EOF
    BEGINDATA
    generated1000x10000.xml
    Sql Loader command
    sqlldr.exe username/password@//localhost:1521/SID control='loader.ctl' log='loadr.log' direct=true
    Schema
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.something.com/shema/simple_searches" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.something.com/shema/simple_searches">
        <element name="searches" type="tns:searches_type"></element>
        <element name="search" type="tns:search_type"></element>
        <element name="results" type="tns:results_type"></element>
        <element name="result" type="tns:result_type"></element>
        <complexType name="searches_type">
            <sequence>
                <element ref="tns:search" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
        <complexType name="search_type">
            <sequence>
                <element ref="tns:results"></element>
            </sequence>
            <attribute ref="tns:id" use="required"></attribute>
            <attribute ref="tns:type" use="required"></attribute>
        </complexType>
        <complexType name="results_type">
            <sequence maxOccurs="unbounded">
                <element ref="tns:result"></element>
            </sequence>
        </complexType>
        <complexType name="result_type">
            <attribute ref="tns:id" use="required"></attribute>
        </complexType>
        <simpleType name="type_type">
            <restriction base="string">
                <enumeration value="value1"></enumeration>
                <enumeration value="value2"></enumeration>
            </restriction>
        </simpleType>
        <attribute name="type" type="tns:type_type"></attribute>
        <attribute name="id" type="string"></attribute>
    </schema>
    Create table
    create table coll_xml_objrel
    ident Number(20) primary key,
    xml xmltype)
    Xmltype column xml
    store as object relational
    xmlschema "http://www.something.com/schema/simple_searches.xsd"
    Element "searches";

    Hi Odie_63,
    Thanks for your answer.
    I will post this question in the XML DB forum too (edit: I realized that you have done it. Thanks for it).
    1, Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    2, see above
    3, I have registered my schema with using dbms_xmlschema.registerSchema function.
    Cheers,
    Adam
    XML generator:
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import javax.xml.stream.XMLOutputFactory;
    import javax.xml.stream.XMLStreamException;
    import javax.xml.stream.XMLStreamWriter;
    public class mainGenerator {
        public static void main(String[] args) throws FileNotFoundException, XMLStreamException {
            // TODO Auto-generated method stub
            final long numberOfSearches = 500;
            final long numberOfResults = 10000;
            XMLOutputFactory xof = XMLOutputFactory.newFactory();
            XMLStreamWriter writer = xof.createXMLStreamWriter(new FileOutputStream("C:\\Working\\generated500x10000.xml"));
            writer.writeStartDocument();
            writer.writeStartElement("tns","searches", "http://www.something.com/schema/simple_searches");
            writer.writeNamespace("tns", "http://www.something.com/schema/simple_searches");
            for (long i = 0; i < numberOfSearches; i++){
                Long help = new Long(i);
                writer.writeStartElement("tns","search", "http://www.something.com/schema/simple_searches);
                writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "type", "value1");
                writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "id", help.toString());
                writer.writeStartElement("tns","results", "http://www.something.com/schema/simple_searches");
                for (long j = 0; j < numberOfResults; j++){
                    writer.writeStartElement("tns","result", "http://www.something.com/schema/simple_searches");
                    Long helper = new Long(i*numberOfResults+j);
                    writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "id", helper.toString());
                    writer.writeEndElement();
                writer.writeEndElement();
                writer.writeEndElement();
            writer.writeEndElement();
            writer.writeEndDocument();
            writer.close();
    registerSchema:
    begin
    dbms_xmlschema.registerSchema(
    'http://www.something.com/schema/simple_searches',
    '<?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.something.com/schema/simple_searches" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.something.com/schema/simple_searches">
        <element name="searches" type="tns:searches_type"></element>
        <element name="search" type="tns:search_type"></element>
        <element name="results" type="tns:results_type"></element>
        <element name="result" type="tns:result_type"></element>
        <complexType name="searches_type">
            <sequence>
                <element ref="tns:search" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
        <complexType name="search_type">
            <sequence>
                <element ref="tns:results"></element>
            </sequence>
            <attribute ref="tns:id" use="required"></attribute>
            <attribute ref="tns:type" use="required"></attribute>
        </complexType>
        <complexType name="results_type">
            <sequence maxOccurs="unbounded">
                <element ref="tns:result"></element>
            </sequence>
        </complexType>
        <complexType name="result_type">
            <attribute ref="tns:id" use="required"></attribute>
        </complexType>
        <simpleType name="type_type">
            <restriction base="string">
                <enumeration value="value1"></enumeration>
                <enumeration value="value2"></enumeration>
            </restriction>
        </simpleType>
        <attribute name="type" type="tns:type_type"></attribute>
        <attribute name="id" type="string"></attribute>
    </schema>',
    TRUE, TRUE, FALSE, FALSE);
    end

  • How to read the attribute of the xml file using jaxb

    Thanks,
    Buddy as i have a issue i have to read the xml file using jaxb and xml file contains this data and i have read the attribute like name , desc and action for a particular menu name pls tell the code how to do this it will be a great favour to me
    thanx in advance
    Rasool
    <contextmenu>
    <menu name='Lead' >
    <menuitem name='newlead' desc='New Lead' action='/leads.do?dispatch=insert' />
    <menuitem name='editlead' desc='Edit Lead' action='' />
    <menuitem name='leadinfo' desc='Lead Information' action='' />
    </menu>
    <menu name='Cases' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    <menu name='Contact' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    </contextmenu>

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • Dom can't parse dtd reference in xml file

    Hi all,
    I am trying to parse a xml file (hibernate mapping file *.hbm.xml) using DOM. But itis getting timeout errorwhile parsing due to the external dtd reference in the xml file.
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >I understand that the program is trying to access the document and is not being able to do so. But I don't have any clue to solve this problem. I don't want to remove the reference from the xml file.
    The following method is trying to parse the xml file:
    public void parseXML(String file) {
            factory = DocumentBuilderFactory.newInstance();
            System.out.println(file);
             try {
                 builder = factory.newDocumentBuilder();
                 document = builder.parse(file);
                 Element docEle = document.getDocumentElement();
                 NodeList n1 = docEle.getElementsByTagName("class");
                for(int i = 0; i < n1.getLength(); i++) {
                       Element e1 = (Element) n1.item(i);
                       String nm = e1.getAttribute("name");
                     System.out.println(nm);
            } catch(Exception e) {
                throw new RuntimeException(e);
        }Please help me on this....I am at no end....Please let me know if there is any method so that the parser will overlook this reference and will parse the xml file....or any other sort of solution....
    Thanks in advance...
    Anir

    Can you provide a working sample?  Upload to Onedrive and share it with us.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • PARSING HTML ELEMNETS IN XML FILE?,Help please very urgent

    I am getting the input in this form
    <ul>
    <li>Strategies</li>
    <li>Planning</li>
    <li>Value</li>
    <li>Total Investment</li>
    </ul>
    I want to convert it into below format so that ContentHandler parse the HTML tages.The HTML elements are dynamic,
    contentHandler.startElement("", "ul", "ul", attrs);
    contentHandler.startElement("", "li", "li", attrs);
    contentHandler.characters(value.toCharArray(), 0, value.length());
    contentHandler.startElement("", "li", "li", attrs);
    contentHandler.startElement("", "li", "li", attrs);
    contentHandler.characters(value.toCharArray(), 0, value.length());
    contentHandler.startElement("", "li", "li", attrs);
    contentHandler.startElement("", "li", "li", attrs);
    contentHandler.characters(value.toCharArray(), 0, value.length());
    contentHandler.startElement("", "li", "li", attrs);
    contentHandler.startElement("", "li", "li", attrs);
    contentHandler.characters(value.toCharArray(), 0, value.length());
    contentHandler.startElement("", "li", "li", attrs);
    contentHandler.endElement("", "ul", "ul");
    Is their any library through which we can convert HTML tags into ContentHandler elements.
    Thanks in Advance
    Thanks
    Lakhi

    Actually i am parsing XML file,but i have HTML elements inside XML elements:
    <section id='2'><header><line>Agenda( Slide2 )</line></header>
    <line>
    <h3>Agenda</h3>
    <ol>
    <li>Overview of ABC Company inc.</li>
    <li>Defining and Measuring Employee Engagement</li>
    <li>Foresight's Survey Methodology</li>
    <li>Online Tools</li>
    <li>Standard and Custom Reporting Capabilities</li>
    <li>Action Planning and Best Practices</li>
    </ol></line></section>
    And i am using Contenthandler interface to parse,
              attrs.addCDATAAttribute("id",""+i);
                   contentHandler.startElement("", "section", "section", attrs);
                   attrs.clear();
                   contentHandler.startElement("", "header", "header", attrs);
                   contentHandler.startElement("", "line", "line", attrs);
                   contentHandler.characters(key.toCharArray(), 0, key.length());
                   contentHandler.endElement("", "line", "line");
                   contentHandler.endElement("", "header", "header");
                   contentHandler.startElement("", "line", "line", attrs);
    /*HERE I need to Generate java instruction for HTML elements as i mailed before.for elements like <li>Overview of ABC Company inc.</li>
    <li>Defining and Measuring Employee Engagement</li>...................</ol>
                   contentHandler.characters(value.toCharArray(), 0, value.length());
                   contentHandler.endElement("", "line", "line");
                   contentHandler.endElement("", "section", "section");

  • Getting attributes from a XML File, stored in Oracle

    Hello,
    my problem is the following
    I have a xml file that looks like that:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <root path="H:\musik">
    <directory name="Bj�rk - Homogenic" path="H:\musik\Bj�rk - Homogenic">
    <file album="Homogenic" artist="Bjoerk" comment=""
    completename="Bjoerk - Hunter" genre="Techno"
    name="01 - Hunter.mp3"
    path="H:\musik\Bj�rk - Homogenic\01 - Hunter.mp3"
    title="Hunter" year="1997"/>
    <file album="Homogenic" artist="Bjoerk" comment=""
    completename="Bjoerk - Joga" genre="" name="02 - Joga.mp3"
    path="H:\musik\Bj�rk - Homogenic\02 - Joga.mp3" title="Joga" year="1994"/>
    </directory>
    <directory name="Blank & Jones - In Da Mix" path="H:\musik\Blank & Jones - In Da Mix">
    <file album="In da Mix" artist="Blank & Jones" comment=""
    completename="Blank & Jones - On a journey (Intro)"
    genre="Dance" name="01 - On a journey (Intro).mp3"
    path="H:\musik\Blank & Jones - In Da Mix\01 - On a journey (Intro).mp3"
    title="On a journey (Intro)" year="1999"/>
    <file album="In da Mix" artist="Blank & Jones" comment=""
    completename="Blank & Jones - Cream" genre="Dance"
    name="02 - Cream.mp3"
    path="H:\musik\Blank & Jones - In Da Mix\02 - Cream.mp3"
    title="Cream" year="1999"/>
    </directory>
    </root>
    This file I have stored in Oracle as table of XML Type.
    Now I have build a little Java Programm, that displays the XML File like the File structure in the Windows Explorer.
    I want, when I choose a file in the File structure, that the ID3 Informations like album artist a.s.o. can be displayed. My problem is, I couldn't get these informations e.g. in an array from the database. Any suggestions how I could realize this in Java?
    Thx for any comments
    Max

    Try this:
    select extract(xmltypefieldname, '//xpath/field@attribute').getStringVal() from yourtable where yourwhereclause
    You can also select elements that match certain attributes by using a predicate such as field[@attr = myval][@attr2 = myval2]...
    Hope this helps.

  • Approach to parse large number of XML files into the relational table.

    We are exploring the option of XML DB for processing a large number of files coming same day.
    The objective is to parse the XML file and store in multiple relational tables. Once in relational table we do not care about the XML file.
    The file can not be stored on the file server and need to be stored in a table before parsing due to security issues. A third party system will send the file and will store it in the XML DB.
    File size can be between 1MB to 50MB and high performance is very much expected other wise the solution will be tossed.
    Although we do not have XSD, the XML file is well structured. We are on 11g Release 2.
    Based on the reading this is what my approach.
    1. CREATE TABLE XML_DATA
    (xml_col XMLTYPE)
    XMLTYPE xml_col STORE AS SECUREFILE BINARY XML;
    2. Third party will store the data in XML_DATA table.
    3. Create XMLINDEX on the unique XML element
    4. Create views on XMLTYPE
    CREATE OR REPLACE FORCE VIEW V_XML_DATA(
       Stype,
       Mtype,
       MNAME,
       OIDT
    AS
       SELECT x."Stype",
              x."Mtype",
              x."Mname",
              x."OIDT"
       FROM   data_table t,
              XMLTABLE (
                 '/SectionMain'
                 PASSING t.data
                 COLUMNS Stype VARCHAR2 (30) PATH 'Stype',
                         Mtype VARCHAR2 (3) PATH 'Mtype',
                         MNAME VARCHAR2 (30) PATH 'MNAME',
                         OIDT VARCHAR2 (30) PATH 'OID') x;
    5. Bulk load the parse data in the staging table based on the index column.
    Please comment on the above approach any suggestion that can improve the performance.
    Thanks
    AnuragT

    Thanks for your response. It givies more confidence.
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    Example XML
    <SectionMain>
    <SectionState>Closed</SectionState>
    <FunctionalState>CP FINISHED</FunctionalState>
    <CreatedTime>2012-08</CreatedTime>
    <Number>106</Number>
    <SectionType>Reel</SectionType>
    <MachineType>CP</MachineType>
    <MachineName>CP_225</MachineName>
    <OID>99dd48cf-fd1b-46cf-9983-0026c04963d2</OID>
    </SectionMain>
    <SectionEvent>
    <SectionOID>99dd48cf-2</SectionOID>
    <EventName>CP.CP_225.Shredder</EventName>
    <OID>b3dd48cf-532d-4126-92d2</OID>
    </SectionEvent>
    <SectionAddData>
    <SectionOID>99dd48cf2</SectionOID>
    <AttributeName>ReelVersion</AttributeName>
    <AttributeValue>4</AttributeValue>
    <OID>b3dd48cf</OID>
    </SectionAddData>
    - <SectionAddData>
    <SectionOID>99dd48cf-fd1b-46cf-9983</SectionOID>
    <AttributeName>ReelNr</AttributeName>
    <AttributeValue>38</AttributeValue>
    <OID>b3dd48cf</OID>
    <BNCounter>
    <SectionID>99dd48cf-fd1b-46cf-9983-0026c04963d2</SectionID>
    <Run>CPFirstRun</Run>
    <SortingClass>84</SortingClass>
    <OutputStacker>D2</OutputStacker>
    <BNCounter>54605</BNCounter>
    </BNCounter>
    I was not aware of Virtual column but looks like we can use it and avoid creating views by just inserting directly into
    the staging table using virtual column.
    Suppose OID id is the unique identifier of each XML FILE and I created virtual column
    CREATE TABLE po_Virtual OF XMLTYPE
    XMLTYPE STORE AS BINARY XML
    VIRTUAL COLUMNS
    (OID_1 AS (XMLCAST(XMLQUERY('/SectionMain/OID'
    PASSING OBJECT_VALUE RETURNING CONTENT)
    AS VARCHAR2(30))));
    1. My question is how then I will write this query by NOT USING COLMUN XML_COL
    SELECT x."SECTIONTYPE",
    x."MACHINETYPE",
    x."MACHINENAME",
    x."OIDT"
    FROM po_Virtual t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                          <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
    MachineType VARCHAR2 (3) PATH 'MachineType',
    MachineName VARCHAR2 (30) PATH 'MachineName',
    OIDT VARCHAR2 (30) PATH 'OID') x;
    2. Insetead of creating the view then Can I do
    insert into STAGING_table_yyy ( col1 ,col2,col3,col4,
    SELECT x."SECTIONTYPE",
    x."MACHINETYPE",
    x."MACHINENAME",
    x."OIDT"
    FROM xml_data t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                         <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
    MachineType VARCHAR2 (3) PATH 'MachineType',
    MachineName VARCHAR2 (30) PATH 'MachineName',
    OIDT VARCHAR2 (30) PATH 'OID') x
    where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
    insert into STAGING_table_yyy ( col1 ,col2,col3
    SELECT x."SectionOID",
    x."EventName",
    x."OIDT"
    FROM xml_data t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                         <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionOID PATH 'SectionOID',
    EventName VARCHAR2 (30) PATH 'EventName',
    OID VARCHAR2 (30) PATH 'OID',
    ) x
    where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
    Same insert for other tables usind the OID_1 virtual coulmn
    3. Finaly Once done how can I delete the XML document from XML.
    If I am using virtual column then I beleive it will be easy
    DELETE table po_Virtual where oid_1 = '99dd48cf-fd1b-46cf-9983';
    But in case we can not use the Virtual column how we can delete the data
    Thanks in advance
    AnuragT

  • Parsing Error is struts xml files org.xml.s

    Hello ,
    I am getting a peculiar error while starting the Tomcat , the struts xml files are not being parsed correctly (they used to be before) .I get a parse error when I shut/start the tomcat (at each deployment) and hence due to the error the application fails (I guess ...)
    The errors I get on the log file while starting the tomcat are ...(only part of the error stack)
    parsing error processing resource path /WEB-INF/struts-action.xml
    org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    Servlet /ProteinBank threw load() exception
    javax.servlet.UnavailableException: Parsing error processing resource path /WEB-INF/struts-action.xml

    Have you changed your struts-config or web.xml files?
    Back it up, and try starting with a 'minimal' version of struts-config to see if it succeeds.

  • When parsing a large size xml file , OutOfMemorry exception(attach code)

    Dear all ,
    I met a OutOfMemorry exception when I parse a xml file (20M) in my application(I extract data in xml file for building my application data), but I found that it take long time(for 2 more minutes) even just searching the xml file , because my application is viewed by web page , so it's too bad for waiting.
    what I used is org.jdom.input.SAXBuilder(jdom1.0beta8-dev) , and my xml file structure is like :
    <errors>
    <item1>content</item1>
    <item2>content</item2>
    </errors>
    and this is my source code of parsing xml file :
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import org.jdom.*;
    import org.jdom.input.*;
    import org.jdom.output.*;
    public class XMLProperties {
        private File file;
        private Document doc;
        private Map propertyCache = new HashMap();
        public XMLProperties(String filename) {
                SAXBuilder builder = new SAXBuilder();
                // Strip formatting
                DataUnformatFilter format = new DataUnformatFilter();
                builder.setXMLFilter(format);
                long time_start = System.currentTimeMillis();
                Runtime run = Runtime.getRuntime();
                doc = builder.build(new File(filename));
                System.out.println("Build doc memory ="+(run.totalMemory()-
                         run.freeMemory())/1024+"K");
                System.out.println("Build doc used time :"+(
                         System.currentTimeMillis()-time_start)/1000+" s");
            catch (Exception e) {
                System.err.println("Error creating XML parser in "
                    + "PropertyManager.java");
                e.printStackTrace();
         public String [] getChildrenProperties(String parent) {
            // Search for this property by traversing down the XML heirarchy.
            Element element = doc.getRootElement();
            element = element.getChild(parent);
            if (element == null) {
                // This node doesn't match this part of the property name which
                // indicates this property doesn't exist so return empty array.
                return new String [] { };
            // We found matching property, return names of children.
            List children = element.getChildren();
            int childCount = children.size();
            String [] childrenNames = new String[childCount];
            for (int i=0; i<childCount; i++) {
                childrenNames[i] = ((Element)children.get(i)).getName();
            return childrenNames;
        }the test main class:
    import java.util.Map;
    import java.util.HashMap;
    import org.jdom.*;
    import org.jdom.input.*;
    public class MyTest {
      public static void main(String[] args) {
        long time_start = System.currentTimeMillis();
        Runtime run = Runtime.getRuntime();
        Map childs = new HashMap();
        System.out.println("Used memory before="+(run.totalMemory()-run.freeMemory())/1024 + "K");
        XMLProperties parser = new XMLProperties("D:\\projects\\edr\\jsp\\status-data\\edr-status-2003-09-01.xml");
        String[] child = parser.getChildrenProperties("errors");
        for(int i=0;i<child.length;i++) {
    //      childs.put(new Integer(i), child);
    if(i%1000 == 0) {
    System.out.println("Used memory while="+(run.totalMemory()-run.freeMemory()/1024+"K"));
    System.out.println("child.length="+child.length);
    System.out.println("Used memory after="+(run.totalMemory()-run.freeMemory())/1024+"K");
    System.out.println("Time used: "+(System.currentTimeMillis()-time_start)/1000+"s");
    The result is : Used memory before=139K
    Used memory while=56963K
    Used memory after=51442K
    child.length=27343
    Time used: 146s
    is that some way to solve this problem ?
    Thanks for your help

    I met a OutOfMemorry exception when I parse a xml
    l file (20M) in my application(I extract data in xml
    file for building my application data)...Rule of thumb for parsing XML: the memory you need is about 10 times the size of the XML file. So in your case you need 200 MB of free memory.
    , but I found
    that it take long time(for 2 more minutes) even just
    searching the xml file , because my application is
    viewed by web page...Then you need to redesign your application. Parsing 20 megabytes of XML for every request is -- as you can see -- impractical. Sorry I can't suggest how, since I have no idea what your application is.

  • Does the parser work with large XML files?

    Is there a restriction on the XML file size that can be loaded into the parser?
    I am getting a out of memory exception reading in large XML file(10MB) using the commands
    DOMParser parser = new DOMParser();
    URL url = createURL(argv[0]);
    parser.setErrorStream(System.err);
    parser.setValidationMode(true);
    parser.showWarnings(true);
    parser.parse(url);
    Win NT 4.0 Server
    Sun JDK 1.2.2
    ===================================
    Error output
    ===================================
    Exception in thread "main" java.lang.OutOfMemoryError
    at oracle.xml.parser.v2.ElementDecl.getAttrDecls(ElementDecl.java, Compi
    led Code)
    at java.util.Hashtable.<init>(Unknown Source)
    at oracle.xml.parser.v2.DTDDecl.<init>(DTDDecl.java, Compiled Code)
    at oracle.xml.parser.v2.ElementDecl.getAttrDecls(ElementDecl.java, Compi
    led Code)
    at oracle.xml.parser.v2.ValidatingParser.checkDefaultAttributes(Validati
    ngParser.java, Compiled Code)
    at oracle.xml.parser.v2.NonValidatingParser.parseAttributes(NonValidatin
    gParser.java, Compiled Code)
    at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingPa
    rser.java, Compiled Code)
    at oracle.xml.parser.v2.ValidatingParser.parseRootElement(ValidatingPars
    er.java:97)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingP
    arser.java:199)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:146)
    at TestLF.main(TestLF.java:40)
    null

    We have a number of test files that are that size and it works without a problem. However using the DOMParser does require significantly more memory than your doc size.
    What is the memory configuration of the JVM that you are running with? Have you tried increasing it? Are you using our latest version 2.0.2.6?
    Oracle XML Team

Maybe you are looking for

  • Adobe XMP Files not deleted with Raw Files in ACR

    I am using Photoshop CS3 on a Windows XP platform. My camera raw files are mostly kept on a Windows 2003 file server, which has a gigabit connection to my workstation. However, I have the same problems when using PS CS3 on my Windows XP laptop. I tak

  • Cannot sync multiple iphones on 1 computer with multiple accounts

    I have had no problems until recently.  I have 2 iphones that I sync with two different users on 1 Windows 7 PC. I was always able to sync the respective iPhone with the iTunes on each individual account without any problem.  Now, it freezes up on 1

  • IPhone applications no longer work

    I have had my iPhone for over a year and never had the troubles I am having now. I have installed dozens of apps and have the same update problem as all of you in this discussion. Now, most of my apps will not work at all! The past week, I have had a

  • Connecting to Oracle lite via VB6

    Hello is there a better way to connect to Oracle 10g when using VB6? this is what I have: Under references I am using Microsoft DAO 3.6 Object library I do have a module where I defined the following public variables: Public wsOracle As DAO.Workspace

  • Problem with Microsoft SSRS connecting to Essbase

    Hello specialists, I'm having an issue when i try to connect SSRS to Essbase. My SSRS version is 2008 R2, Essbase version is 11.1.2.1 OS version is Windows server 2008R2 and I'm running SQL server 2008 R2. I'm using the XMLA connector from SSRS to co