Ned help on JSP parsing XML

Hi all.
Im having problems on how to parse an xml by JSP
Can anyone teach me how to parse an the XML below by jsp, without using taglibs. Im using JDOM...
<Customer>
           <DetailsCustomer ID = 1>
           <Name>
                  John
           </Name>
           <DetailsCustomer ID = 2>
           <Name>
                 Michael
           </Name>
<Customer>Thankz :)
Hope for a kind reply :)

Hi,
Why would you like to parse the XML inside a JSP page? JSP are for rendering and not for parsing XML. The code to parse the XML should be put in an ordinary Java class instead.
Parsing XML can be done in a number of ways...it all depends on what you want to do with the XML. Are you looking for XML -> Java Object then maybe you should look at XStream or JAXB.
If you can tell me a little more about your use case maybe I can help you a little bit more.
/klejs

Similar Messages

  • Help: How to parse XML string into Node Context

    Hi Experts,
    I am trying to work with a web dynpro for java application which calls a Web Service. I can call the web service successfully, however I have a problem on interpreting the response result into table. The response result is in (XML) string format, like this:
    I followed this , but it resulted to an error:
    com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Name expected: 0x20(:main:, row:158, col:59)(:main:, row=158, col=59) -> com.sap.engine.lib.xml.parser.ParserException: Name expected: 0x20(:main:, row:158, col:59)
    do anyone of you had a similar experience and were able to resolve it, please post it here. it will be highly appreciated. thanks in advance.

    Try this :
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(new org.xml.sax.InputSource(new StringReader(strXml)));Hope this helps.

  • How to parse XML in server side javascript (XSJS)?

    Hi Experts,
    I can get the XML file content through this method:var xmlString = $.response.body.asString() and I need to parse XML. If there XML parser in server side javascript? thanks very much!

    Hi Wenwen Hou,
    There is a blog available at
    Parse XML in server side javascript (XSJS)
    This can help you achieve parsing xml in server side javascript.
    Regards,
    Anjali.

  • Parsing XML using SDO API.

    Hi
    I am looking to see if JDeveloper comes with necesssary SDO APIs to help
    a developer parse XML. I am looking at this as a replacement for JAXB.
    I have access to JDev 11g and 10g.
    If it is possible can you please tell me
    1) What are the libraries to include?
    2) Any tutorials available.
    Thanks
    Kartik

    Hello Kartik,
    Oracle TopLink will include an SDO 2.1 implementation as part of the AS 11R1 release. You can take a look at Technical Preview 2 here:
    http://www.oracle.com/technology/products/ias/toplink/preview/index.html
    There isn't much in the way of SDO documentation yet, but I can provide you with some samples if you wish.
    First though, you mention that you are looking for a replacement for JAXB. I have represented Oracle on both the JAXB 2.0 and SDO 2.1/3.0 specifications so if you care to provide details on what you're building, maybe I can offer an opinion. If you don't wish to post to the list, you can email me at [email protected]
    Oracles JAXB and SDO implementations are both build on top of TopLink's object-to-XML mapping technology. This may also be an appropriate technology choice for you.
    For more information on TopLink OXM see:
    http://www.oracle.com/technology/products/ias/toplink/oxm/index.html
    -Blaise

  • Parse XML in PL/SQL need help

    Hi All,
    I'm new to PL/SQL. I need to call a web service from within the PL/SQL and then need to parse the response XML. I was able to call the web service and now I have returned SOAP response XML in CLOB. I searched on google for way to parse this XML and create some kind of list or array or collection with all the values so that later on that collection or array can be used in displaying the data or storing the data, but I couldn't found the right information, rather I got very confused.
    Please help me in parsing this XML and creating some kind collection or array for later use.
    Thanks
    XML is
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
    <getMemberResponse effectiveDate="1970-10-01" endDate="2010-12-31" xmlns="http://abc.org/schema/Member/GetMember/V1">
    <responseHeader xmlns="http://abc.org/schema/common/v1">
    <serviceVersion>2.0.1</serviceVersion>
    <actionRequested AR="QUERY" xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/common/v1" xmlns:v12="http://abc.org/schema/common/v1">
    <v11:transactionName>GetMemberRequest</v11:transactionName>
    </actionRequested>
    <requestResults>
    <resultStatus>Success</resultStatus>
    <resultCodes>
    <resultCode TYPE="HIPAA">00000</resultCode>
    <resultCode TYPE="LEGACY">00000</resultCode>
    <resultCode TYPE="SDI">00000</resultCode>
    </resultCodes>
    <resultMessage>Success</resultMessage>
    </requestResults>
    <accounting xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/datatypes/v1" xmlns:v12="http://abc.org/schema/common/v1">
    <transactionId>ec3542e7-3191-430c-bd69-69dd5d18bf75</transactionId>
    <v12:timeStamp>2011-05-23T11:52:22</v12:timeStamp>
    </accounting>
    </responseHeader>
    <requestID>ec3542e7-3191-430c-bd69-69dd5d18bf75</requestID>
    <memberDetails xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/datatypes/v1" xmlns:v12="http://abc.org/schema/common/v1">
    <v1:ids>
    <v1:id memberIdType="SSN">00000000</v1:id>
    <v1:id memberIdType="PARTYID">111111</v1:id>
    <v1:id memberIdType="PARTYNUMBER">222222</v1:id>
    </v1:ids>
    <v1:demographics>
    <v1:memberDemographicType effDate="2010-05-09" maintType="UPDATE">
    <v1:name>
    <v1:nameDetails>
    <v11:firstName>Keith</v11:firstName>
    <v11:middleName>M</v11:middleName>
    <v11:lastNames>
    <v11:lastName>
    <v11:name>Thompson</v11:name>
    </v11:lastName>
    </v11:lastNames>
    <v11:formattedName>Keith M Thompson</v11:formattedName>
    </v1:nameDetails>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
    </v1:name>
    <v1:birthDate>1954-12-24</v1:birthDate>
    <v1:genderTypeCode>Male</v1:genderTypeCode>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
    </v1:memberDemographicType>
    </v1:demographics>
    <v1:originalContractEffDate>2010-04-01</v1:originalContractEffDate>
    <v1:addresses>
    <v1:address maintType="QUERY">
    <v1:location addresseeType="MEMBER" effDate="1901-01-01" endDate="9999-12-31" locationUseType="HOME" primaryPerType="Y">
    <v11:addressLines>
    <v11:addressLine>BAY VIEW AVENUE</v11:addressLine>
    </v11:addressLines>
    <v11:cityName>PLYMOUTH</v11:cityName>
    <v11:stateCode>TX</v11:stateCode>
    <v11:postalCode>58654</v11:postalCode>
    </v1:location>
    <v1:createDate>2011-05-23T11:52:22</v1:createDate>
    <v1:updateDate>2011-05-23T11:52:22</v1:updateDate>
    </v1:address>
    <v1:address maintType="QUERY">
    <v1:location addresseeType="SUBSCRIBER" effDate="1901-01-01" endDate="9999-12-31" locationUseType="HOME" primaryPerType="Y">
    <v11:addressLines>
    <v11:addressLine>AY VIEW AVENUE</v11:addressLine>
    </v11:addressLines>
    <v11:cityName>PLYMOUTH</v11:cityName>
    <v11:stateCode>TX</v11:stateCode>
    <v11:postalCode>58654</v11:postalCode>
    </v1:location>
    <v1:createDate>2011-05-23T11:52:22</v1:createDate>
    <v1:updateDate>2011-05-23T11:52:22</v1:updateDate>
    </v1:address>
    </v1:addresses>
    <v1:policies>
    <v1:policy effDate="2010-04-01" maintType="ADD" type="MEMBER">
    <v1:ids>
    <v1:id type="MEMBERID">CPIT000456</v1:id>
    <v1:id type="POLICY">CPIT</v1:id>
    </v1:ids>
    <v1:contractType>F</v1:contractType>
    <v1:dependentType>01</v1:dependentType>
    <v1:offerings>
    <v1:offering offeredBy="abc" offeringIdType="INSURANCE_TYPE" selected="Y">
    <v1:offeringId>IV</v1:offeringId>
    </v1:offering>
    <v1:offering effDate="2010-04-01" maintType="ADD" offeredBy="abc" offeringIdType="BOC" selected="Y">
    <v1:offeringId>GK</v1:offeringId>
    <v1:recordInfo>
    <v1:internalRecId>82326287</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-05-09T14:23:17</v1:updateDate>
    </v1:offering>
    </v1:offerings>
    <v1:customer>
    <v1:relation type="EMPLOYMENT">
    <v1:customer>
    <v1:id idType="ACCOUNTID">C11204</v1:id>
    <v1:id idType="DIVISION">0208290000</v1:id>
    <v1:customerName>BC Group</v1:customerName>
    </v1:customer>
    </v1:relation>
    </v1:customer>
    <v1:physicianRelations>
    <v1:physicianRelation effDate="2010-04-01" endDate="9999-12-31" type="PCP">
    <v1:ids>
    <v1:id type="NPI">0</v1:id>
    <v1:id type="AFFILIATIONID">1313 0025</v1:id>
    <v1:id type="PROVIDERID">1313</v1:id>
    <v1:id type="TIN">0</v1:id>
    </v1:ids>
    <v1:recordInfo>
    <v1:internalRecId>98151812</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-10-23T01:10:13</v1:createDate>
    <v1:updateDate>2010-10-23T01:10:13</v1:updateDate>
    </v1:physicianRelation>
    </v1:physicianRelations>
    <v1:maintainReasonCode>AC</v1:maintainReasonCode>
    <v1:recordInfo>
    <v1:internalRecId>82326286</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-05-09T14:23:17</v1:updateDate>
    </v1:policy>
    <v1:policy effDate="2010-04-01" maintType="QUERY" type="SUBSCRIBER">
    <v1:ids>
    <v1:id type="POLICY">CPIT</v1:id>
    </v1:ids>
    <v1:hashCode>82326284</v1:hashCode>
    <v1:contractType>F</v1:contractType>
    <v1:maritalStatus>UNKNOWN</v1:maritalStatus>
    <v1:offerings>
    <v1:offering effDate="2010-04-01" maintType="QUERY" offeredBy="abc" offeringIdType="INSURANCE_TYPE" selected="Y">
    <v1:offeringId>IV</v1:offeringId>
    <v1:recordInfo>
    <v1:internalRecId>82326285</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2011-01-20T04:53:52</v1:updateDate>
    </v1:offering>
    </v1:offerings>
    <v1:customer>
    <v1:relation type="EMPLOYMENT">
    <v1:customer>
    <v1:id idType="ACCOUNTID">C11204</v1:id>
    <v1:id idType="DIVISION">0208290000</v1:id>
    <v1:customerName>BC Group</v1:customerName>
    </v1:customer>
    </v1:relation>
    </v1:customer>
    <v1:maintainReasonCode>AC</v1:maintainReasonCode>
    <v1:recordInfo>
    <v1:internalRecId>82326284</v1:internalRecId>
    </v1:recordInfo>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2011-01-20T04:53:52</v1:updateDate>
    </v1:policy>
    </v1:policies>
    <v1:recordInfo>
    <v1:internalRecId>8364745</v1:internalRecId>
    <v1:objectVersionNo>1</v1:objectVersionNo>
    </v1:recordInfo>
    <v1:restrictedMemberIndicator>N</v1:restrictedMemberIndicator>
    <v1:createDate>2010-05-09T14:23:17</v1:createDate>
    <v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
    </memberDetails>
    </getMemberResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    Hi A_Non,
    Thanks so much for giving me the hint about that "text()" in XPath.
    I have new question for you with same XML I'm parsing right now.
    I have extracted a part(Policies) of whole XML and put it in one XMLTYPE variable. Below is that part XML.
    My question is I need to look only into that policy which is active right now. In the <policy> tag there are two attributes "effDate" and "endDate". "effDate" tag will always be there for every policy and for all inactive policies also "endDate" will be there always. Problem is with the active ones, "endDate" may or may not be there. If "endDate" is there so it will be greater than or equal to sysdate and if it is not there that means it is open ended. I need to fetch only that policy which is active right now and if there is no tag as such that means member is not active as of today.
    If "endDate" attribute is there then I think below XPath will work, but I'm not sure about how to handle when "endDate" attribute is not there.
    /d:policies/d:policy[@type="MEMBER" and number(translate(@effDate,"-",""))<=number(translate("'||l_currDate||'","-","")) and number(translate(@endDate,"-",""))>=number(translate("'||l_currDate||'","-",""))]I have Oracle 10.1.0.4, in this in XPath comparison operators are not working so I'm using XPath functions.
    Here is the XML
    <v1:policies>
       <v1:policy effDate="1999-05-01" endDate="1999-12-31" maintType="ADD" type="MEMBER">
           <v1:ids>
               <v1:id type="MEMBERID">SDF000414600</v1:id>
               <v1:id type="POLICY">SDF0004146</v1:id>
           </v1:ids>
           <v1:contractType>F</v1:contractType>
           <v1:dependentType>01</v1:dependentType>
           <v1:offerings>
               <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
                   <v1:offeringId>IH</v1:offeringId>
               </v1:offering>
               <v1:offering effDate="1999-05-01" endDate="1999-12-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
                   <v1:offeringId>HA</v1:offeringId>
                   <v1:recordInfo>
                      <v1:internalRecId>39077481</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-05-01T01:27:04</v1:createDate>
                   <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
               </v1:offering>
           </v1:offerings>
           <v1:customer>
               <v1:relation type="EMPLOYMENT">
                   <v1:customer>
                      <v1:id idType="ACCOUNTID">AS35423</v1:id>
                      <v1:id idType="DIVISION">0621730000</v1:id>
                      <v1:customerName>Medical Associates</v1:customerName>
                   </v1:customer>
               </v1:relation>
           </v1:customer>
           <v1:physicianRelations>
               <v1:physicianRelation effDate="1999-05-01" endDate="1999-12-31" type="PCP">
                   <v1:ids>
                      <v1:id type="NPI">0</v1:id>
                      <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                      <v1:id type="PROVIDERID">231231</v1:id>
                      <v1:id type="TIN">0</v1:id>
                   </v1:ids>
                   <v1:recordInfo>
                      <v1:internalRecId>87796651</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-10-22T21:56:44</v1:createDate>
                   <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
               </v1:physicianRelation>
           </v1:physicianRelations>
           <v1:maintainReasonCode>MD</v1:maintainReasonCode>
           <v1:recordInfo>
               <v1:internalRecId>39077480</v1:internalRecId>
           </v1:recordInfo>
           <v1:createDate>2010-05-01T01:27:04</v1:createDate>
           <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
       </v1:policy>
       <v1:policy effDate="2000-01-01" endDate="2000-12-31" maintType="ADD" type="MEMBER">
           <v1:ids>
               <v1:id type="MEMBERID">SDF000414600</v1:id>
               <v1:id type="POLICY">SDF0004146</v1:id>
           </v1:ids>
           <v1:contractType>F</v1:contractType>
           <v1:dependentType>01</v1:dependentType>
           <v1:offerings>
               <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
                   <v1:offeringId>IH</v1:offeringId>
               </v1:offering>
               <v1:offering effDate="2000-01-01" endDate="2000-12-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
                   <v1:offeringId>HA</v1:offeringId>
                   <v1:recordInfo>
                      <v1:internalRecId>39077483</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-05-01T01:27:04</v1:createDate>
                   <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
               </v1:offering>
           </v1:offerings>
           <v1:customer>
               <v1:relation type="EMPLOYMENT">
                   <v1:customer>
                      <v1:id idType="ACCOUNTID">C35423</v1:id>
                      <v1:id idType="DIVISION">0621730000</v1:id>
                      <v1:customerName>Medical Associates</v1:customerName>
                   </v1:customer>
               </v1:relation>
           </v1:customer>
           <v1:physicianRelations>
               <v1:physicianRelation effDate="2000-01-01" endDate="2000-12-31" type="PCP">
                   <v1:ids>
                      <v1:id type="NPI">0</v1:id>
                      <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                      <v1:id type="PROVIDERID">3213213</v1:id>
                      <v1:id type="TIN">0</v1:id>
                   </v1:ids>
                   <v1:recordInfo>
                      <v1:internalRecId>87796652</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-10-22T21:56:44</v1:createDate>
                   <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
               </v1:physicianRelation>
           </v1:physicianRelations>
           <v1:maintainReasonCode>MD</v1:maintainReasonCode>
           <v1:recordInfo>
               <v1:internalRecId>39077482</v1:internalRecId>
           </v1:recordInfo>
           <v1:createDate>2010-05-01T01:27:04</v1:createDate>
           <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
       </v1:policy>
       <v1:policy effDate="2001-01-01" maintType="ADD" type="MEMBER">
           <v1:ids>
               <v1:id type="MEMBERID">SDF000414600</v1:id>
               <v1:id type="POLICY">SDF0004146</v1:id>
           </v1:ids>
           <v1:contractType>F</v1:contractType>
           <v1:dependentType>01</v1:dependentType>
           <v1:offerings>
               <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
                   <v1:offeringId>IH</v1:offeringId>
               </v1:offering>
               <v1:offering effDate="2001-01-01" endDate="2001-03-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
                   <v1:offeringId>HC</v1:offeringId>
                   <v1:recordInfo>
                      <v1:internalRecId>39077485</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-05-01T01:27:04</v1:createDate>
                   <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
               </v1:offering>
           </v1:offerings>
           <v1:customer>
               <v1:relation type="EMPLOYMENT">
                   <v1:customer>
                      <v1:id idType="ACCOUNTID">C35423</v1:id>
                      <v1:id idType="DIVISION">0621730000</v1:id>
                      <v1:customerName>Medical Associates</v1:customerName>
                   </v1:customer>
               </v1:relation>
           </v1:customer>
           <v1:physicianRelations>
               <v1:physicianRelation effDate="2001-01-01" endDate="2001-03-31" type="PCP">
                   <v1:ids>
                      <v1:id type="NPI">0</v1:id>
                      <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                      <v1:id type="PROVIDERID">61232132</v1:id>
                      <v1:id type="TIN">0</v1:id>
                   </v1:ids>
                   <v1:recordInfo>
                      <v1:internalRecId>87796653</v1:internalRecId>
                   </v1:recordInfo>
                   <v1:createDate>2010-10-22T21:56:44</v1:createDate>
                   <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
               </v1:physicianRelation>
           </v1:physicianRelations>
           <v1:maintainReasonCode>LE</v1:maintainReasonCode>
           <v1:recordInfo>
               <v1:internalRecId>39077484</v1:internalRecId>
           </v1:recordInfo>
           <v1:createDate>2010-05-01T01:27:04</v1:createDate>
           <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
       </v1:policy>
    </v1:policies>Thanks

  • How to parse XML to Java object... please help really stuck

    Thank you for reading this email...
    If I have a **DTD** like:
    <!ELEMENT person (name, age)>
    <!ATTLIST person
         id ID #REQUIRED
    >
    <!ELEMENT name ((family, given) | (given, family))>
    <!ELEMENT age (#PCDATA)>
    <!ELEMENT family (#PCDATA)>
    <!ELEMENT given (#PCDATA)>
    the **XML** like:
    <person id="a1">
    <name>
         <family> Yoshi </family>
         <given> Samurai </given>
    </name>
    <age> 21 </age>
    </person>
    **** Could you help me to write a simple parser to parse my DTD and XML to Java object, and how can I use those objects... sorry if the problem is too basic, I am a beginner and very stuck... I am very confuse with SAXParserFactory, SAXParser, ParserAdapter and DOM has its own Factory and Parser, so confuse...
    Thank you for your help, Yo

    Hi, Yo,
    Thank you very much for your help. And I Wish you are there...I'm. And I plan to stay - It's sunny and warm here in Honolulu and the waves are up :)
    A bit more question for dear people:
    In the notes, it's mainly focus on JAXB,
    1. Is that mean JAXB is most popular parser for
    parsing XML into Java object? With me, definitely. There are essentially 3 technologies that allow you to parse XML documents:
    1) "Callbacks" (e.g. SAX in JAXP): You write a class that overrides 3 methods that will be called i) whenever the parser encounters a start tag, ii) an end tag, or iii) PCDATA. Drawback: You have to figure out where the heck in the document hierarchy you are when such a callback happens, because the same method is called on EACH start tag and similarly for the end tag and the PCDATA. You have to create the objects and put them into your own data structure - it's very tedious, but you have complete control. (Well, more or less.)
    2) "Tree" (e.g. DOM in JAXP, or it's better cousin JDOM): You call a parser that in one swoop creates an entire hierarchy that corresponds to the XML document. You don't get called on each tag as with SAX, you just get the root of the resulting tree. Drawback: All the nodes in the tree have the same type! You probably want to know which tags are in the document, don't you? Well, you'll have to traverse the tree and ask each node: What tag do you represent? And what are your attributes? (You get only strings in response even though your attributes often represent numbers.) Unless you want to display the tree - that's a nice application, you can do it as a tree model for JTree -, or otherwise don't care about the individual tags, DOM is not of much help, because you have to keep track where in the tree you are while you traverse it.
    3) Enter JAXB (or Castor, or ...): You give it a grammar of the XML documents you want to parse, or "unmarshall" as the fashion dictates to call it. (Actually the name isn't that bad, because "parsing" focuses on the input text while "unmarshalling" focuses on the objects you get, even though I'd reason that it should be marshalling that converts into objects and unmarshalling that converts objects to something else, and not vice versa but that's just my opinion.) The JAXB compiler creates a bunch of source files each with one (or now more) class(es) (and now interfaces) that correspond to the elements/tags of your grammar. (Now "compiler" is a true jevel of a misnomer, try to explain to students that after they run the "compiler", they still need to compile the sources the "compiler" generated with the real Java compiler!). Ok, you've got these sources compiled. Now you call one single method, unmarshall() and as a result you get the root node of the hierarchy that corresponds to the XML document. Sounds like DOM, but it's much better - the objects in the resulting tree don't have all the same type, but their type depends on the tag they represent. E.g if there is the tag <ball-game> then there will be an object of type myPackage.BallGame in your data structure. It gets better, if there is <score> inside <ball-game> and you have an object ballGame (of type BallGame) that you can simply call ballGame.getScore() and you get an object of type myPackage.Score. In other words, the child tags become properties of the parent object. Even better, the attributes become properties, too, so as far as your program is concerned there is no difference whether the property value was originally a tag or an attribute. On top of that, you can tell in your schema that the property has an int value - or another primitive type (that's like that in 1.0, in the early release you'll have to do it in the additional xjs file). So this is a very natural way to explore the data structure of the XML document. Of course there are drawbacks, but they are minor: daunting complexity and, as a consequence, very steep learning curve, documentation that leaves much to reader's phantasy - read trial and error - (the user's guide is too simplicistic and the examples too primitive, e.g. they don't even tell you how to make a schema where a tag has only attributes) and reference manual that has ~200 pages full of technicalities and you have to look with magnifying glas for the really usefull stuff, huge number of generated classes, some of which you may not need at all (and in 1.0 the number has doubled because each class has an accompanying interface), etc., etc. But overall, all that pales compared to the drastically improved efficiency of the programmer's efforts, i.e. your time. The time you'll spend learning the intricacies is well spent, you'll learn it once and then it will shorten your programming time all the time you use it. It's like C and Java, Java is order of magnitude more complex, but you'd probably never be sorry you gave up C.
    Of course the above essay leaves out lots and lots of detail, but I think that it touches the most important points.
    A word about JAXB 1.0 vs. Early Release (EA) version. If you have time, definitively learn 1.0, they are quite different and the main advantage is that the schema combines all the info that you had to formulate in the DTD and in the xjs file when using the EA version. I suggested EA was because you had a DTD already, but in retrospect, you better start from scratch with 1.0. The concepts in 1.0 are here to stay and once your surmounted the learning curve, you'll be glad that you don't have to switch concepts.
    When parser job is done,
    what kind of Java Object we will get? (String,
    InputStream or ...)See above, typically it's an object whose type is defined as a class (and interface in 1.0) within the sources that JABX generates. Or it can be a String or one of the primitive types - you tell the "compiler" in the schema (xjs file in EA) what you want!
    2. If we want to use JAXB, we have to contain a
    XJS-file? Something like:In EA, yes. In 1.0 no - it's all in the schema.
    I am very new to XML, is there any simpler way to get
    around them? It has already take me 4 days to find a
    simple parser which give it XML and DTD, then return
    to me Java objects ... I mean if that kind of parser
    exists....It'll take you probably magnitude longer that that to get really familiar with JAXB, but believe me it's worth it. You'll save countless days if not weeks once you'll start developing serious software with it. How long did it take you to learn Java and it's main APIs? You'll either invest the time learning how to use the software others have written, or you invest it writing it yourself. I'll take the former any time. But it's only my opinion...
    Jan

  • Need help in Parsing XML Document in Oracle

    Hello Experts,
    I urgently need your help. We have xml document on the Web but not on the File System. How can I parse the xml document on the web in Oracle.
    Any link, blog or sample code would be appreciated.
    Your help would be appreciated.
    Kind Regards,
    Bhavin
    London, UK

    This breaks down to two issues
    1) Getting the XML into Oracle
    2) Parsing the XML inside Oracle
    For #1, the first two options that come to my mind are httpuirtype and utl_http. Both can be used to get information from a URL that understands HTTP requests.
    For #2, you can treat the XML as a DOMDocument or XMLType to parse it. You also could parse it via a SQL statement using XQuery or XMLTable as well.
    Many of those examples can be found on the {forum:id=34} forum or [Marco&apos;s blog|http://www.liberidu.com/blog/]. A few parsing examples that I've done can be seen at {message:id=3610259}, make sure to also follow the link I put in there to a previous example before that.

  • Need help on parsing xml file...

    Hi all,
    I need to collect some data from an Xml file using java. I have the following code with me but I am unable to get the required result. I am unable to get the data from the tags belonging to the header and footer elements. Please find the code and the sample xml file below.
    Program to parse XML:
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class JobLogDetails3{
         //No generics
         List myJobs;
         Document dom;
         public JobLogDetails3(){
              //create a list to hold the job objects
              myJobs = new ArrayList();
         public void runJobDetails() {
              //parse the xml file and get the dom object
              parseXmlFile();
              //get each joblog element and create a job object
              parseDocument();
              //Iterate through the list and print the data
              printData();
         private void parseXmlFile(){
              //get the factory
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              try {
                   //Using factory get an instance of document builder
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   //parse using builder to get DOM representation of the XML file
                   dom = db.parse("test.xml");
              }catch(ParserConfigurationException pce) {
                   pce.printStackTrace();
              }catch(SAXException se) {
                   se.printStackTrace();
              }catch(IOException ioe) {
                   ioe.printStackTrace();
         private void parseDocument(){
              //get the root elememt
              Element docEle = dom.getDocumentElement();
              //get a nodelist of <joblog> elements
              NodeList nl = dom.getElementsByTagName("*");
              if(nl != null && nl.getLength() > 0) {
                   for(int i = 0 ; i < nl.getLength();i++) {
                        //get the joblog element
                        Element el = (Element)nl.item(i);
                        //get the joblog object
                        Job J = getJob(el);
                        //add it to list
                        myJobs.add(J);
         * I take an joblog element and read the values in, create
         * an joblog object and return it
         * @param JobEl
         * @return
         private Job getJob(Element JobEl) {
              //for each <joblog> element get text or int values of
              //name ,id, age and name
              String jobServer = getTextValue(JobEl,"server");
              String jobName = getTextValue(JobEl,"name");
              String jobClient = getTextValue(JobEl,"machine_name");
              String jobStart = getTextValue(JobEl,"start_time");
              String jobType = getTextValue(JobEl,"type");
              String jobEnd = getTextValue(JobEl,"end_time");
              String jobSize = getTextValue(JobEl,"new_processed_bytes");
              //Create a new Job with the value read from the xml nodes
              Job J = new Job(jobServer,jobName,jobClient,jobStart,jobType,jobEnd,jobSize);
              return J;
         * I take a xml element and the tag name, look for the tag and get
         * the text content
         * i.e for <employee><name>John</name></employee> xml snippet if
         * the Element points to employee node and tagName is name I will return John
         * @param ele
         * @param tagName
         * @return
         private String getTextValue(Element ele, String tagName) {
              String textVal = null;
              NodeList nl = ele.getElementsByTagName(tagName);
              if(nl != null && nl.getLength() > 0) {
                   Element el = (Element)nl.item(0);
                   textVal = el.getFirstChild().getNodeValue();
              return textVal;
         * Calls getTextValue and returns a int value
         * @param ele
         * @param tagName
         * @return
         private int getIntValue(Element ele, String tagName) {
              //in production application you would catch the exception
              return Integer.parseInt(getTextValue(ele,tagName));
         * Iterate through the list and print the
         * content to console
         private void printData(){
              System.out.println("No of Jobs '" + myJobs.size() + "'.");
              Iterator it = myJobs.iterator();
              while(it.hasNext()) {
                   System.out.println(it.next().toString());
         public static void main(String[] args){
              //create an instance
              JobLogDetails JLD = new JobLogDetails();
              //call run example
              JLD.runJobDetails();
    Job Class
    public class Job {
         private String jobServer;
    private String jobName;
    private String jobClient;
    private String jobStart;
    private String jobType;
    private String jobEnd;
    private String jobSize;
         public Job(){
         public Job(String jobServer,String jobName,String jobClient,String jobStart,String jobType,String jobEnd,String jobSize ) {
              this.jobServer = jobServer;
              this.jobName = jobName;
              this.jobClient = jobClient;
    this.jobStart = jobStart;
              this.jobType = jobType;
    this.jobEnd = jobEnd;
    this.jobSize = jobSize;
         public String getjobServer() {
              return jobServer;
         public void setjobServer(String jobServer) {
              this.jobServer = jobServer;
         public String getjobName() {
              return jobName;
         public void setjobname(String jobName) {
              this.jobName = jobName;
         public String getjobClient() {
              return jobClient;
         public void setjobClient(String jobClient) {
              this.jobClient = jobClient;
    public String getjobStart() {
              return jobStart;
         public void setjobStart(String jobStart) {
              this.jobStart = jobStart;
    public String getjobType() {
              return jobType;
         public void setjobType(String jobType) {
              this.jobType = jobType;
    public String getjobEnd() {
              return jobEnd;
         public void setjobEnd(String jobEnd) {
              this.jobEnd = jobEnd;
    public String getjobSize() {
              return jobSize;
         public void setjobSize(String jobSize) {
              this.jobSize = jobSize;
         public String toString() {
              StringBuffer sb = new StringBuffer();
    sb.append(getjobServer());
              sb.append(",");
    sb.append(getjobName());
              sb.append(",");
              sb.append(getjobClient());
              sb.append(",");
              sb.append(getjobType());
              sb.append(",");
              sb.append(getjobStart());
              sb.append(",");
              sb.append(getjobEnd());
              sb.append(",");
              sb.append(getjobSize());
              sb.append(",");
              return sb.toString();
    Sample XML File:
    <?xml version="1.0" encoding="UTF-16" ?>
    - <joblog>
    <job_log_version version="2.0" />
    - <header>
    <filler>======================================================================</filler>
    <server>Job server: TGBBAK</server>
    <name>Job name: TGBSAP4-SQL-SQL DB Servers S2T - High-Weekly Full Backup</name>
    <start_time>Job started: 26 September 2011 at 01:00:04</start_time>
    <type>Job type: Backup</type>
    <log_name>Job Log: GFD_TGBBAK_71887.xml</log_name>
    <filler>======================================================================</filler>
    </header>
    <media_mount_date>Drive and media mount requested: 26/09/2011 01:00:04</media_mount_date>
    - <media_drive_and_media_info>
    <media_mount_date>Drive and media information from media mount: 26/09/2011 01:00:39</media_mount_date>
    <robotic_library_name>Robotic Library Name: HP 1</robotic_library_name>
    <drive_name>Drive Name: LTO4_2</drive_name>
    <slot>Slot: 43</slot>
    <media_label>Media Label: 000059L</media_label>
    <media_guid>Media GUID: {a6ca0062-7a6f-4b4b-8144-732ca25f2f9d}</media_guid>
    <media_overwrite_date>Overwrite Protected Until: 25/10/2011 19:24:58</media_overwrite_date>
    <media_append_date>Appendable Until: 02/10/2011 14:00:30</media_append_date>
    <media_set_target>Targeted Media Set Name: Weekly Tape</media_set_target>
    </media_drive_and_media_info>
    - <backup>
    <filler>======================================================================</filler>
    <title>Job Operation - Backup</title>
    <append_or_overwrite>Media operation - append.</append_or_overwrite>
    <compression>Compression Type: Hardware [if available, otherwise none]</compression>
    <verify_option>WARNING: The option 'Verify after backup completes' was not selected. Performing a verify operation to make sure that media can be read after the backup has completed is recommended.</verify_option>
    <filler>======================================================================</filler>
    - <machine>
    <machine_name>TGBSAP4.Tetley.Grp</machine_name>
    <info>Network control connection is established between 10.22.2.18:3271 <--> 10.22.2.4:10000</info>
    <info>Network data connection is established between 10.22.2.18:3301 <--> 10.22.2.4:3094</info>
    - <set>
    <set_resource_name>TGBSAP4.Tetley.Grp</set_resource_name>
    <tape_name>Family Name: "Media created 25/09/2011 13:59:55"</tape_name>
    - <volume>
    <display_volume>Backup of "TGBSAP4.Tetley.Grp "</display_volume>
    </volume>
    <description>Backup set #45 on storage media #1 Backup set description: "Weekly Full Backup"</description>
    <backup_type>Backup Method: Full - Back up entire database or filegroup</backup_type>
    <agent_started>Microsoft SQL Server Agent: Started</agent_started>
    <start_time>Backup started on 26/09/2011 at 01:01:45.</start_time>
    - <database>
    <database>Database PRD</database>
    </database>
    - <database>
    <database>Database master</database>
    </database>
    - <database>
    <database>Database model</database>
    </database>
    - <database>
    <database>Database msdb</database>
    </database>
    <end_time>Backup completed on 26/09/2011 at 02:42:25.</end_time>
    - <summary>
    <backed_up_database>Backed up 4 databases</backed_up_database>
    <new_processed_bytes>Processed 573363576542 bytes in 1 hour, 40 minutes, and 40 seconds.</new_processed_bytes>
    <vlm_hist_rateformat2>Throughput rate: 5432 MB/min</vlm_hist_rateformat2>
    </summary>
    <filler>----------------------------------------------------------------------</filler>
    </set>
    </machine>
    </backup>
    - <footer>
    <filler>======================================================================</filler>
    <end_time>Job ended: 26 September 2011 at 02:43:12</end_time>
    <engine_completion_status>Job completion status: Successful</engine_completion_status>
    <filler>======================================================================</filler>
    <completeStatus>19</completeStatus>
    </footer>
    </joblog>

    1. your code does not compile (in your main method you try to create an instance of a class which does not exist).
    2. your XML document is not well formed.
    +[Fatal Error] test.xml:34:74: The content of elements must consist of well-formed character data or markup.+
    org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    Maybe there are other problems but you can start by fixing these.

  • Server Error 500: Cant find taglibs  oracle.jsp.parse.JspParseException

    I dont know what iam doing wrong. My project runs under tomcat, but not under oc4j.
    Here is my stacktrace:
    500 Internal Server Error
    OracleJSP: oracle.jsp.parse.JspParseException: Zeilennummer 3, <%@ taglib uri="/tags/fn" prefix="fn" %>
    Fehler:oracle.xml.parser.v2.XMLParseException ( /WEB-INF/jsp-fragments/taglibs.jsp ):
    Zeile #:3 Spalte #:48 : FIXED type Attribute value not equal to the default value 'http://java.sun.com/xml/ns/j2ee'.
    Zeile #:4 Spalte #:56 : Attribute 'xmlns:xsi' used but not declared.
    Zeile #:5 Spalte #:81 : Attribute 'xsi:schemaLocation' used but not declared.
    Zeile #:6 Spalte #:16 : Attribute 'version' used but not declared.
    Zeile #:8 Spalte #:15 : Invalid element 'description' in content of 'taglib', expected elements '[tlibversion]'.
    Zeile #:8 Spalte #:15 : Element 'description' used but not declared.
    Zeile #:9 Spalte #:16 : Invalid element 'display-name' in content of 'taglib', expected elements '[tlibversion]'.
    Zeile #:9 Spalte #:16 : Element 'display-name' used but not declared.
    Zeile #:10 Spalte #:16 : Invalid element 'tlib-version' in content of 'taglib', expected elements '[tlibversion]'.
    Zeile #:10 Spalte #:16 : Element 'tlib-version' used but not declared.
    Zeile #:11 Spalte #:14 : Invalid element 'short-name' in content of 'taglib', expected elements '[tlibversion]'.
    Zeile #:11 Spalte #:14 : Element 'short-name' used but not declared.
    Zeile #:12 Spalte #:7 : Invalid element 'uri' in content of 'taglib', expected elements '[tlibversion]'.
    Zeile #:14 Spalte #:12 : Invalid element 'function' in content of 'taglib', expected elements '[tlibversion]'.
    Zeile #:14 Spalte #:12 : Element 'function' used but not declared.
    Zeile #:15 Spalte #:17 : Element 'description' used but not declared.
    Zeile #:19 Spalte #:20 : Element 'function-class' used but not declared.
    Zeile #:20 Spalte #:24 : Element 'function-signature' used but not declared.
    Zeile #:21 Spalte #:13 : Element 'example' used but not declared.
    Zeile #:26 Spalte #:12 : Invalid element 'function' in content of 'taglib', expected elements '[tlibversion]'.
    hope that someone can help me out.
    thanks

    Which oc4j version are you using? You can get the version by
       java -jar oc4j.jar -version

  • Oracle.jsp.parse.JspParseException

    After making minor changes to my jsp's, i deployed the war and now the jsp's cant find the tld's, even though they exist.
    I get the following error:
    500 Internal Server Error
    OracleJSP: oracle.jsp.parse.JspParseException: Line # 1, <%@ taglib uri="/tld/c" prefix="c"%>
    Error: java.io.IOException: Referenced TLD does not exist or is invalid
    Any say...please:-|?

    Does making change in the global-web-application.xml help (jsp-cache-tlds="false")?I do not see any relevance of gloabl-web-application.xml here.
    They exist in WEB-INF/tld folder.
    OracleJSP: oracle.jsp.parse.JspParseException: Line # 3, <%@ taglib
    uri="/tld/extremecomponents" prefix="ec" %>
    Error: java.io.IOException: Referenced TLD does not exist or is invalidIf it is in WEB-INF/tld, then you can write
      <%@ taglib uri="/WEB-INF/tld/extremecomponents.tld" prefix="ec" %>
    The "/WEB-INF" is missing in your version.
    Of course, there are other ways to provide the uri attribute. However, the above is most direct way. As a sanity test, let us get it working first by the above way.

  • JSP/JSTL & XML

    I am trying to have JSP pages parse and read an XML file and then return some data in an HTML table. I'm using the JSTL libraries and have a basic understanding of them, but I apparently need help.
    My first page just gets the value and passes it to the second page. The second page handles all of the processing. Here is my JSP page:
    <%@page contentType="text/html" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <%@include file="index.jsp" %>
    <% String clientID = request.getParameter("enteredID"); %>
    <c:import url="npiXMLTest5.xml" var="doc" />
    <x:parse varDom="dom" doc="${doc}"/>
    <x:set var="srcCID" select="string($dom/npiNumbers/client/clientNum)" />
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>NPI XJTL Test</title></head>
    <body>
    <c:set var="CID" value="<%= clientID %>" />
    <h2>NPI XJTL Test Page</h2>
    <table border="1">
    <tr><th>NPI Number</th><th>Description</th></tr>
    <c:choose>
    <c:when test="${CID}=${srcCID}">
    <x:forEach select="$dom/npiNumbers/client/npiNum" var="$n">
    <tr><td><x:out select="$n/npi" /></td><td><x:out select="$n/desc" /></td></tr>
    </x:forEach>
    </c:when>
    <c:otherwise>
    There is an error with your coding
    </c:otherwise>
    </c:choose>
    </table></body></html>My XML structure is as follows:
    <npiNumbers xsi:schemaLocation="http://localhost/namespace NPI_XSD5.xsd" xmlns="http://localhost/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <client>
    <clientNum/>
    <clientName/>
    <npiNum>
    <npi/>
    <desc/>
    </npiNum>
    </client>
    </npiNumbers>I am trying to return the results of the <npiNum> element (which can have multiple values) - <npi> and <desc> - in a table based on the <clientNum> element. I try to evaluate the page variable with the xml element. If it matches, I will return a table. A client can have multiple <npiNum> elements, so the construction of the table is in the x:forEach loop.
    I think my problem is getting the variable from JSP to compare against the <clientNum> element in the XML file.
    Any ideas?

    I think your problem is less JSP/JSTL and more querying the XML.
    You are trying to "select all <npinum> elements from a client based on clientnum"
    I am far from an expert on XPath, but I think the following query is what you are after: "/npinumbers/client[clientNum=????]/npiNum"
    To do that with JSTL you would replace ???? with $param:enteredId or $CID (equivalent in your example)
    Here is the resulting JSP page.
    <%@page contentType="text/html" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <c:import url="npiXMLTest5.xml" var="doc" />
    <x:parse varDom="dom" doc="${doc}"/>
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>NPI XJTL Test</title></head>
    <body>
    <c:set var="CID" value="${param.enteredId}" />
    <h2>NPI XJTL Test Page</h2>
    <table border="1">
    <tr><th>NPI Number</th><th>Description</th></tr>
    <x:forEach select="$dom/npiNumbers/client[clientNum=$CID]/npiNum" var="n">
      <tr><td><x:out select="npi" /></td><td><x:out select="desc" /></td></tr>
    </x:forEach>
    </table>
    <hr>
    <form>
    <input type="text" name="enteredId"/>
    <input type="submit">
    </form>
    </body></html>I made up the following test file to use with it. I don't know if it was exactly what your requirements are, but it was a best guess based on your info.
    <npiNumbers>
         <client>
              <clientNum>42</clientNum>
              <clientName>Ford Prefect</clientName>
              <npiNum>
                   <npi>123</npi>
                   <desc>life</desc>
              </npiNum>
              <npiNum>
                   <npi>234</npi>
                   <desc>universe</desc>
              </npiNum>
              <npiNum>
                   <npi>456</npi>
                   <desc>everything</desc>
              </npiNum>          
         </client>
         <client>
              <clientNum>666</clientNum>
              <clientName>Satan</clientName>
              <npiNum>
                   <npi>333</npi>
                   <desc>Baby Devil</desc>
              </npiNum>
         </client>
    </npiNumbers>Cheers,
    evnafets

  • LO Error 26005 Failed to parse XML

    Good Afternoon,
    I currently have an Xcelsius document that is attached to a Crystal Report that is in Infoview.  I have it connected by using Live Office.  The Crystal report basically contains a cross tab of data and is run nightly in our system.  I bring back the data into Excel in order to build an Xcelsius document off of it.  I havent' been using the Live Office piece all that much until recently therefore please excuse my ignorance.  I setup my data connection as a Live Office connection.  My server connection seems to be correct:
    http://WHGCRYSTAL3:8080/dswsbobje/services/session
    However, when I try to refresh the document, I get the following error:
    soapenv:Server.generalException: Failed to parse XML. (LO 26005)
    Any ideas as to what this could be?  I have Crystal Xcelsius Enterprise 2008.  The version is 5.0.0.99 and the build number is 12,0,0,121.  I think I am all updated on service packs but I could  be wrong.  Any help is appreciated.

    I downloaded all of the service packs and fixes and now I am up to date.  I am still getting the error with an additional error.   This is what is says:
    Failed to parse XML. (LO 26005) (LO 26000)
    Any other ideas as to why this is happening?

  • Error while accessing OIM UI - OracleJSP error: oracle.jsp.parse.JspParseException

    We have 3 nodes of OIM servers in our clustered production environment. While accessing OIM server on first node, following error is coming in the browser window -
    OracleJSP error: oracle.jsp.parse.JspParseException:
    /oracle/iam/ui/main/signin.jspx: Line # 5, &amp;amp;amp;lt;af:document id="d1" initialFocusId="pt1:_pt_it1" theme="light" title="#{uiBundle['IDENTITY_SELF_SERVICE_TITLE']}"&amp;amp;amp;gt;
    Error: Encountered deferred syntax #{ in template text. If intended as a literal, escape it or set directive deferredSyntaxAllowedAsLiteral
    The OIM UI is accessible on the other 2 nodes. There are no changes made in the environment. I have also attached the OIM diagnostic logs for your analysis.
    Please let us know the steps to resolve this issue in production environment.

    No..
    I have followed the way to add JSF libray,
    1)Right click the projet->project properties->javadoc->JSP taglibraries
    2)Inside the Distributed Library i have selected the JSTL core 1.2 and click on add.
    3) Then a new dialogue box of Choose tablibraries came.inside that only struts bean,struts Html etc are seeing.
    What i need to select?..Do i am following the right way?
    Please help..

  • Parse XML in a java stored proc

    I am trying to parse an xml document in a java stored procedure. Just following my nose, I have developed a stored proc that works fine in development (outside the database using JRE 1.4.1) using the Xerces 2.5 parser. But, after having transferred the xerces xercesImpl.jar, xmlapis.jar, and my implementation class into oracle using loadjava when I call my stored proc the code throws an exception trying to build the document with an error like:
    NoClassDef exception org.apache.xerces.jaxp.DocumentFactoryBuilderImpl
    My Code looks like this:
    import java.io.IOException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.xml.sax.SAXException;
    InputStream is = getXMLAsInputStream(xml);
    try {
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse( is );
    ... parse the document ....
    catch (FactoryConfigurationError e) {
    // unable to get a document builder factory
    The exception caught is a FactoryConfigurtionError.
    I'm not particularly attached to xerces, I'm really just looking for a way to parse XML inside my java stored proc, so any help to solve my problem, or an alternative suggestion will be greatly appreciated.
    thanks
    Dale

    I looked again and sure enough the xerces implementation classes were missing. I had run a .cmd file containing these two lines, but it looks like only the first one ran...
    loadjava -u ncc/xyz@usd -v -r M:\Database\JavaGeocode\Xerces2_5_0\xml-apis.jar
    loadjava -u ncc/xyz@usd -v -r M:\Database\JavaGeocode\Xerces2_5_0\xercesImpl.jar
    Now I've got everything working fine with Xerces!
    Dale

  • How do you store parsed XML data in an array

    Hi, i am trying to complete a small program which implements the SAX parser to parse an XML file. My problem is that i am writing a custom class to store the parsed data into an array, and then make the array available to the main program via a simple method which returns the array. I know this must be very simple to do, but i seem to have developed a mental block with this part of the program. I can parse the data and print all the elements to the screen, but i just cant figure out how to store all the data elements into the array. I will post the class which is supposed to do this, and ask anyone out there if they know what i'm doing wrong, and also, if there is a more effeicient way of achieving this ( i expect there definitely is!! but i have never used the SAX parser before and am getting confused by the API docs on it!!) Any help very much appreciated.
    Here is my attempt at coding the class to handle the parsed XML data
    class Sink extends org.xml.sax.helpers.DefaultHandler
         implements org.xml.sax.ContentHandler{
    Customer[] customers = new Customer[20];
         int count = 1;
         int x = 0;
         int tagCount = 0;
         String name;
    String custID;
         String username;
         String address;
         String phoneNum;
    public void startElement(String uri, String localName, String rawName, final org.xml.sax.Attributes attributes)throws org.xml.sax.SAXException{
    //count the number of <name> tags in the XML file
         if(rawName.equals("name")){
              tagCount++;
    public void characters(char[] ch, int start, int len){
    //get the current string
         String text = new String(ch, start, len);
         String text1 = text.trim();
    //there are 5 elements for each customer found in the XML file so when the count reaches 6
    // i reset this to 1
         if(count == 6){
         count = count - 5;
         if(text1.length()>0 && count == 1){
              name = text1;
              System.out.println(name);
              }else{
         if(text1.length()>0 && count == 2){
              custID = text1;
              System.out.println(custID);
                   }else{
                   if(text1.length()>0 && count == 3){
                   username = text1;
                   System.out.println(username);
                   }else{
                        if(text1.length()>0 && count == 4){
                        address = text1;
                        System.out.println(address);
                        }else{
                        if(text1.length()>0 && count == 5){
                             phoneNum = text1;
                             System.out.println(phoneNum);
                             //add data to the customer array
                             customers[x] = new Customer(name, custID, username, address, phoneNum);
    // increment the array index counter
                        x = x+1;
                        }//end of if
                        }//end else
                        }//end else
                   }//end else
              }//end else
    }//end of characters method
    public void endDocument(){
         System.out.println("There are " + tagCount +
         " <name> elements.");
    }//end of class Sink
    Before the end of this class i also need to make the array available to the calling program!!
    Any help would be much appreciated
    Thanks
    Iain

    Ok, yer going about this all the wrong way. You shouldn't have to maintain a count of all the elements. Basically you are locking yourself into the XML tags not only all being there but are assuming they are all in the same order. What you should do is in your characters() method, put all of the characters into a string buffer. Then, in endElement() (which you dont use btw, you should) you grab the information that is in the string buffer and store it into your Customer object depending on what the tagName is.
    Also, you should probably use a List to store all the Customer objects and not an single array, it's more dynamic and you arent locked into a set number of Customers.
    I wont do it all for you, but I'll give you a good outline to use.
    public class CustomerHandler extends DefaultHandler {
        private java.util.List customerList;  // List of Customer objects
        private java.util.StringBuffer buf;   // StringBuffer to store the string of characters between the start and end tags
        private Customer customer;  // Customer object that is initialized with each entry.
        public CustomerHandler() {
            customerList = new java.util.ArrayList();   // Initialize the List
            buf = new java.util.StringBuffer();   // Initialize the string buffer
        //  Make your customer list available to other classes
        public java.util.List getCustomerList() {
            return customerList;
        public void startElement(String nsURI, String sName, String tagName, Attributes attributes) throws SAXException {
            // Clear the String Buffer
            //  If the tagName is "Customer" then create a new Customer object
        public void characters(char[] ch, int start, int length) {
            //  append the characters into the string buffer
        public void endElement(String nsURI, String sName, String tagName) throws SAXException {
            // If the tagName is "Customer" add your customer object to the List
            // Place the data from the String Buffer into a String
            //  Depending on the tagName, call the appropriate set method on your customer object
    }

Maybe you are looking for