SelectNodes method in XMLNode class...

Can anyone provide me a small code that shows how to use the
selectNodes method in the XMLNode class? I don't know how to
define the NSResolver that should be pass as an argument to this
method.
Thanks,
Renilton
null

The selectNodes function is used in XMLElement and XMLDocument
nodes. This function is used to extract contents from the
tree/subtree based on the select patterns allowed by XSL.
The second parameter of selectNodes, is used to resolve namespace
prefixes (give the expanded namespace URL given a prefix).
XMLElement implements NSResolver, so it can be sent as the
second parameter. XMLElement resolves the prefixes based on the
input document. You can implement the NSReolver interface, if
you need to overide the namespace definitions.
The sample code to use selectNodes
public class SelectNodesTest {
public static void main(String[] args) throws Exception {
String pattern = "/family/member/text()";
String file = args[0];
if (args.length == 2)
pattern = args[1];
DOMParser dp = new DOMParser();
dp.parse(createURL(file)); // Include createURL from
DOMSample
XMLDocument xd = dp.getDocument();
XMLElement e = (XMLElement) xd.getDocumentElement();
NodeList nl = e.selectNodes(pattern, e);
for (int i = 0; i < nl.getLength(); i++) {
System.out.println(nl.item(i).getNodeValue());
java SelectNodesTest family.xmlSarah
Bob
Joanne
Jim
java SelectNodesTest family.xml //member/@memberidm1
m2
m3
m4
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Renilton Oliveira (guest) wrote:
: Can anyone provide me a small code that shows how to use the
: selectNodes method in the XMLNode class? I don't know how to
: define the NSResolver that should be pass as an argument to
this
: method.
: Thanks,
: Renilton
null

Similar Messages

  • Problem using XMLNode class with schema registered XML

    Hello,
    I'm working on an XML document management system that currently uses CLOB storage of XML data. I'm trying to switch over to a schema registered/object-relational approach to increase performance.
    However, the code (which I didn't write) uses the XMLNode class and its methods such as selectSingleNode which work when used against unregisterd xml, but breaks when used against registered xml. I don't know if this is a namespace issue or what.
    Here's a sample.
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true); // don't know if this is neccessary
    newICD = (XMLDocument) dbf.newDocumentBuilder().parse(icdFile);
    docNode = (XMLNode) newICD.getDocumentElement();
    //this works with CLOB storage, but returns null with registered schema/O-R storage
    tempNode = docNode.selectSingleNode("/sw_icd/TITLEPAGE/DocNum");
    Any ideas would be greatly appreciated.
    Thanks

    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <!--W3C Schema generated by XMLSpy v2006 sp2 U (http://www.altova.com)-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
         <xs:element name="AffectedComponents">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="COMPONENT" maxOccurs="unbounded" />
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="CHANGE" type="xs:string" />
         <xs:element name="COMPONENT">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="SectionString" />
                        <xs:element ref="RevisionType" />
                        <xs:element ref="SectionType" />
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="Change">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="CHANGE" />
                        <xs:element ref="SSCN" />
                        <xs:element ref="PIRNS" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="DESCRIPTION" type="xs:string" />
         <xs:element name="PIRN">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="PIRN_NUMBER" />
                        <xs:element ref="AffectedComponents" />
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="PIRNS">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="PIRN" maxOccurs="unbounded" />
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="PIRN_NUMBER" type="xs:string" />
         <xs:element name="PUBDATE" type="xs:string" />
         <xs:element name="REV" type="xs:string" />
         <xs:element name="RevItem">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="REV" />
                        <xs:element ref="DESCRIPTION" />
                        <xs:element ref="PUBDATE" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="RevisionType" type="xs:string" />
         <xs:element name="SSCN" type="xs:string" />
         <xs:element name="SectNum">
              <xs:complexType>
                   <xs:choice maxOccurs="unbounded">
                        <xs:element ref="SectNumTitle" />
                        <xs:element ref="t" />
                        <xs:element ref="list" />
                        <xs:element ref="figure" />
                        <xs:element ref="tbl" />
                   </xs:choice>
                   <xs:attribute name="id" type="xs:string" use="required" />
                   <xs:attribute name="val" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="SectNumTitle" type="xs:string" />
         <xs:element name="SectionString" type="xs:string" />
         <xs:element name="SectionType" type="xs:string" />
         <xs:element name="SigDate" type="xs:string" />
         <xs:element name="SigElectronic" type="xs:string" />
         <xs:element name="SigName" type="xs:string" />
         <xs:element name="SigOrganization" type="xs:string" />
         <xs:element name="SigType" type="xs:string" />
         <xs:element name="Signature">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="SigType" />
                        <xs:element ref="SigName" />
                        <xs:element ref="SigElectronic" minOccurs="0" />
                        <xs:element ref="SigOrganization" />
                        <xs:element ref="SigDate" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" />
              </xs:complexType>
         </xs:element>
         <xs:element name="Signatures">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="colspec" maxOccurs="unbounded" />
                        <xs:element ref="Signature" maxOccurs="unbounded" />
                   </xs:sequence>
                   <xs:attribute name="type" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="TblHdg">
              <xs:complexType mixed="true">
                   <xs:attribute name="num" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="bindata">
              <xs:complexType>
                   <xs:attribute name="src" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="caption" type="xs:string" />
         <xs:element name="cell">
              <xs:complexType mixed="true">
                   <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="colspec">
              <xs:complexType>
                   <xs:attribute name="id" type="xs:string" use="required" />
                   <xs:attribute name="name" type="xs:string" use="required" />
                   <xs:attribute name="width" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="figure">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="width" />
                        <xs:element ref="height" />
                        <xs:element ref="caption" />
                        <xs:element ref="bindata" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
                   <xs:attribute name="val" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="height" type="xs:string" />
         <xs:element name="list">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="list1" maxOccurs="unbounded" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="list1">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="t" />
                        <xs:element ref="list2" minOccurs="0" maxOccurs="unbounded" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
                   <xs:attribute name="val" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="list2">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="t" />
                        <xs:element name="list3" minOccurs="0">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element ref="t" />
                                  </xs:sequence>
                                  <xs:attribute name="id" type="xs:string" use="required" />
                                  <xs:attribute name="val" type="xs:string" use="required" />
                             </xs:complexType>
                        </xs:element>
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
                   <xs:attribute name="val" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="pui" type="xs:string" />
         <xs:element name="sect">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="SectNum" maxOccurs="unbounded" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="sw_icd">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="TITLEPAGE">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element name="Title1" type="xs:string" />
                                       <xs:element name="Title2" type="xs:string" />
                                       <xs:element name="Group" type="xs:string" />
                                       <xs:element name="Rev" type="xs:string" />
                                       <xs:element name="DrafDate" type="xs:string" />
                                       <xs:element name="DocumentType" type="xs:string" />
                                       <xs:element name="Org1" type="xs:string" />
                                       <xs:element name="Org2" type="xs:string" />
                                       <xs:element name="Org3" type="xs:string" />
                                       <xs:element name="Location" type="xs:string" />
                                       <xs:element name="ContractNo" type="xs:string" />
                                       <xs:element name="DocNum" type="xs:string" />
                                  </xs:sequence>
                             </xs:complexType>
                        </xs:element>
                        <xs:element name="REVHISTPAGE">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element name="RevItems">
                                            <xs:complexType>
                                                 <xs:sequence>
                                                      <xs:element ref="colspec" maxOccurs="unbounded" />
                                                      <xs:element ref="RevItem" maxOccurs="unbounded" />
                                                 </xs:sequence>
                                            </xs:complexType>
                                       </xs:element>
                                       <xs:element ref="t" />
                                       <xs:element name="ERU" type="xs:string" />
                                  </xs:sequence>
                             </xs:complexType>
                        </xs:element>
                        <xs:element name="PREFACE">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element ref="t" />
                                       <xs:element ref="Signature" />
                                  </xs:sequence>
                             </xs:complexType>
                        </xs:element>
                        <xs:element name="CONCURRENCE">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element ref="Signatures" maxOccurs="unbounded" />
                                  </xs:sequence>
                             </xs:complexType>
                        </xs:element>
                        <xs:element name="CHANGES">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element name="ChangeItems">
                                            <xs:complexType>
                                                 <xs:sequence>
                                                      <xs:element ref="colspec" maxOccurs="unbounded" />
                                                      <xs:element ref="Change" maxOccurs="unbounded" />
                                                 </xs:sequence>
                                            </xs:complexType>
                                       </xs:element>
                                  </xs:sequence>
                                  <xs:attribute name="id" type="xs:string" use="required" />
                             </xs:complexType>
                        </xs:element>
                        <xs:element ref="sect" maxOccurs="unbounded" />
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="t">
              <xs:complexType mixed="true">
                   <xs:attribute name="id" type="xs:string" />
              </xs:complexType>
         </xs:element>
         <xs:element name="tbl">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="pui" minOccurs="0" />
                        <xs:element ref="TblHdg" maxOccurs="unbounded" />
                        <xs:element ref="colspec" maxOccurs="unbounded" />
                        <xs:element ref="tr" maxOccurs="unbounded" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
                   <xs:attribute name="val" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="tr">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="cell" maxOccurs="unbounded" />
                   </xs:sequence>
                   <xs:attribute name="id" type="xs:string" use="required" />
              </xs:complexType>
         </xs:element>
         <xs:element name="width" type="xs:string" />
    </xs:schema>

  • When will the setNodeValue() method of XMLNode be implemented?

    It seems the setNodeValue() method along with all the other methods of XMLNode are not implemented yet. When will it be available? Also what can I do if I want to build an XMLDocument in Java (but not using Java classes)? Does creating indivdual nodes and later append them together work?
    Thanks.

    For example, the following code
    XMLElement element = new XMLElement("A");
    element.setNodeValue("abc");
    will cause the following exception:
    oracle.xml.parser.v2.XMLDOMException: Node cannot be modified.
    void oracle.xml.parser.v2.XMLNode.setNodeValue(java.lang.String)
    Why is this? And how to get around it? Basically all I want to do is creating a valid XML by creating individual elements first and then use appendChild() operation to put them together in a hierarchy... can this work?
    Thanks!

  • Returning a HashMap K, M from a method of a class typed M

    So, this is what I have. I have a class parameterized for a bean type of a collection it receives, and in a method of the class, I need (would like) to return a HashMap typed as <K, M> as in:
    public class MyClass<M> {
       private Collection<M> beanList;
       public HashMap<K, M> getMap(  /* what do I do here */ );
    }I tried to cheat from looking at the Collections.sort method, knowing it uses the List type in its return type as in:
    public static <T extends Comparable<? super T>> void sort(List<T> list)So, I am trying:
    public HashMap<K, M> getMap(Class<K> keyType)But, it is telling me I need to create class K.
    So... how does the Collections.sort method get away with it and I can't????
    I suppose I could write the method as:
    public HashMap<Object, M> getMap()but became somewhat challenged by my first guess.
    Any ideas... or just go with the HashMap with the untyped key?

    ejp wrote:
    provided K is inferable from the arguments.Or from the assignment context:
    Set<String> empty = Collections.emptySet();
    Otherwise you have to parameterise the class on <K, M>.You may also specifically provide K when you use the method if the context doesn't give the compiler enough information or if you want to override it.
    Example:
    Set<Object> singleton1 = Collections.singleton("Hello"); //error
    Set<Object> singleton2 = Collections.<Object>singleton("Hello"); //fineEdited by: endasil on 14-May-2010 4:13 PM

  • Function Module to open a new session displaying a method of a class

    Hello All,
    I have a method A of class B.
    Now, in my current session, I have a button. When the user clicks on this button, what I expect is that a new session be opened and in the new session method A of class B be displayed.
    This is similar to the debugger, wherein, in the debugging mode, we can bring up the context menu in the Source Code (Edit Control) tool, and then select "Go To Source Code".
    So basically, I am looking for a Function Module which does the same.
    I came across Function Module CC_CALL_TRANSACTION_NEW_TASK, however, this will only create a new session.
    I could specify the transaction as SE24, but it then opens a new session with this transaction. That is it.
    My objective is to display the method of a class in a new session.
    Is there any Function Module in this case?
    Regards,
    Mithun
    Edited by: Mithun Kamath on Aug 9, 2011 5:35 PM

    Hello Sandra,
    Thank you very much. That was exactly what I was looking for.
    However, instead of calling EDITOR_PROGRAM directly, what I instea did was the following:
    1) Created a RFC enabled Function module.
    2) Inside this function module, I wrote the following code:
      SUBMIT tpda_editor_start AND RETURN
       WITH prgm  = is_alert_det-program_name
       WITH incl = is_alert_det-include_name
       WITH dynp = space
       WITH line = is_alert_det-line_no.
    The parameters above were similar to the one proposed by you.
    Borrowed the above from the class CL_TPDA_SERVICES_TOOLS, method NAVIGATE_TO_SOURCE.
    The above is basically called in the debugger, when we use the context menu in the editor tool and invoke the "Goto Source Code" functionality. This eventually calls the EDITOR_PROGRAM FM.
    The reason why I did this is because when I was testing the FM, it did not allow me to specify the include as CL_TEST=====CM01. I do not know why, probably I was doing it wrong. But it gave me a message saying that the object does not exist in table TADIR.
    Anyway, I did the above steps and it worked exactly as I wanted it to.
    I would like to thank you again.
    Best Regards,
    Mithun
    P.S. Forgot to add, I called the above RFC enabled FM as a new task.
    Edited by: Mithun Kamath on Aug 10, 2011 4:19 PM

  • How do i call the method in a class using servlet

    i am doing a project which need to use servlet to call a few methods in a class and display those method on the broswer. i tried to write the servlet myself but there are still some errors .. can anyone help:
    The servlet i wrote :
    package qm.minipas;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class test extends HttpServlet {
    Database database;
    /** Initializes the servlet.
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    database = FlatfileDatabase.getInstance();
    /** Destroys the servlet.
    public void destroy() {
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("this is my class wossname"+FlatfileDatabase.getInstance()); // this is calling the toString() method in the instance of myJavaClass
    out.println("this is my method"+FlatfileDatabase.getAll());
    out.println("</body>");
    out.println("</html>");
    out.close();
    /** Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    my methods which i need to call are shown below:
    public Collection getAll() {
    return Collections.unmodifiableCollection(patientRecords);
    public Collection getInpatients() {
    Collection selection=new ArrayList();
    synchronized(patientRecords) {
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(next.isInpatient())
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByAdmissionDate(Date dateOfAdmission) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(dateOfAdmission.equals(next.getDateOfAdmission()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByAdmissionDates(Date from,Date to)
    throws IllegalArgumentException {
    if(to.before(from))
    throw new IllegalArgumentException("End date must not be before start date");
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    Date nextAD=next.getDateOfAdmission();
    if((nextAD.after(from)||nextAD.equals(from))
    &&(nextAD.before(to)||nextAD.equals(to)))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByDischargeDates(Date from,Date to)
    throws IllegalArgumentException {
    if(to.before(from))
    throw new IllegalArgumentException("End date must not be before start date");
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    Date nextAD=next.getDateOfDischarge();
    if(nextAD==null)
    continue;
    if((nextAD.after(from)||nextAD.equals(from))
    &&(nextAD.before(to)||nextAD.equals(to)))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByConsultant(String consultant) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(consultant.equalsIgnoreCase(next.getConsultant()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByDischargeDate(Date dateOfDischarge) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(dateOfDischarge.equals(next.getDateOfDischarge()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getBySurname(String surname) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(surname.equalsIgnoreCase(next.getSurname()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);
    public Collection getByWard(String ward) {
    List selection=new ArrayList();
    for(Iterator i=patientRecords.iterator(); i.hasNext();) {
    PatientRecord next=(PatientRecord) i.next();
    if(ward.equalsIgnoreCase(next.getWard()))
    selection.add(next);
    return Collections.unmodifiableCollection(selection);

    please provide a detail description of your errors.

  • "Open method of Workbooks class failed" when opening Excel file via Internet Explorer

    (apologies, I posted this first to the general Office 2010 forum, but then realized this was probably a better spot to post)
    We have an Excel COM add-in installed on users' PCs.  This add-in responds to workbook open events by opening a particular XLA file (also deployed to the PC) to make certain features available.  This process works flawlessly when Excel files are
    opened locally - but when a user attempts to open an Excel file from an IE link, we get the following error: "Open method of Workbooks class failed".  This is happening on the line that is trying to open the XLA file.  This only happens
    when launching an Excel link from IE - works fine in Chrome or Firefox.
    I have found several posts on this topic, but no solutions:
    1. This post (https://social.msdn.microsoft.com/forums/office/en-US/73c96005-84af-4648-b103-32b677205be3/open-method-of-workbooks-class-failed)
    is the closest to our problem.  In this case, the "answer" was that the user may not have access to the 2nd workbook being opened.  But in our case, we're opening an XLA that is on the local machine, and I've confirmed that it is not
    corrupt and accessible (read & write, just in case!) to Everyone.
    2. This (very old) post (http://www.pcreview.co.uk/forums/open-method-workbooks-fails-excel-hosted-ie-t965608.html)
    seems similar, but is talking about opening Excel inside of IE.  This is not what we're doing - the link is supposed to (and does) open Excel outside of IE.  Interestingly, Excel.exe is being launched with the "-embedded" flag, even
    though it isn't running in the IE window.  When launching Excel by opening the file locally, Excel.exe is run with the "/dde" flag instead.  Clearly the "-embedded" mode is what is causing the problem.  I could change the
    links on the web page to use some JavaScript to open Excel differently... unfortunately, the links are actually generated by SharePoint (the Excel files are in a SP repository), so this is not really an option.
    3. This Microsoft KB article (http://support.microsoft.com/kb/268016) talks about problems opening an XLA directly from IE... but this is the case of a link pointing
    directly to an XLA file, not opening a regular workbook that in turn opens an XLA, as is my case.  In fact, this article specifically points out in the "More Information" section that "End users do not normally open XLAs; instead they open
    an XLS that (if needed) loads one or more XLAs during startup." ==> precisely what I'm trying to do that is giving me the error!
    I've replicated the situation with a very simple COM add-in (created in VS2010 using VB.Net) and a very simple XLA file (does nothing, just pops up a message in auto_open).  For anyone wanting to try it out, here is the exact test case:
    1. In Excel, create a simple XLA file containing only the following code, and save it in C:\TEMP\dummy.xla:
    Sub Auto_Open()
    MsgBox "Auto Open fired"
    End Sub
    2. In Visual Studio, create a new Excel 2010 Add-In.  I created mine via Visual Basic, but I doubt the choice of language matters.  Place the following code in ThisAddin.vb:
    Public Class ThisAddIn
    Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
    AddHandler Me.Application.WorkbookOpen, AddressOf Application_WorkbookOpen
    End Sub
    Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
    End Sub
    Sub Application_WorkbookOpen(ByVal workbook As Excel.Workbook)
    On Error GoTo ErrHandler
    If (Not workbook.Name.Contains("dummy.xla")) Then
    MsgBox("Workbook open")
    Application.Workbooks.Open("C:\temp\dummy.xla")
    Application.Workbooks("dummy.xla").RunAutoMacros(Excel.XlRunAutoMacro.xlAutoOpen)
    End If
    Exit Sub
    ErrHandler:
    MsgBox(Err.Description)
    End Sub
    End Class
    3. Build & publish this add-in and install it on the same machine as the XLA created in step 1.
    4. Create and save an empty Excel workbook (I called mine WayneTest1.xlsx) - save it locally (on your desktop), and put a copy somewhere on your web server (I put mine directly in c:\inetpub).
    5. Create an HTML file with a link to that workbook, saving it to the same web server location - here is mine:
    <html>
    <body>
    <a href="WayneTest1.xlsx">Link to Excel file</a>
    </body>
    </html>
    6. Double click the workbook on your desktop (from step 4) - opens fine, I get the "workbook open" message, following by the "Auto Open fired" message.
    7. In Internet Explorer, navigate to the HTML file specified in step 5 and click on the link - when prompted, select "Open" - I get the "workbook open" message, following by the error message "Open method of Workbooks class failed".
    Here are a few things I've ruled out / tried so far:
    - Unchecked all the "Protected View" settings in Excel, made no difference
    - Unchecked all the "File block settings" in Excel, made no difference
    - Made sure dummy.xla was open for read & write to Everyone
    - Made sure the web page was in Trusted sites and set the security level to Low for those sites in IE
    - Tried making the local desktop file (step 6) readonly, made no difference (i.e. launching it locally still worked fine)
    - Tried using Excel 2013 - made no difference
    Any ideas / suggestions?

    Hello Wayne,
    Apologies for the delay.
    I went through your post and tried to reproduce the issue. I was able to reproduce it. Based
    on its complexity and as it requires more in-depth analysis, your question falls into the paid support category which requires a more in-depth level of support.
    Please visit the below link to see the various paid support options that are
    available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone
    Thanks,
    Anush

  • How to call a static method in a class if I have just the object?

    Hello. I have an abstract class A where I have a static method blah(). I have 2 classes that extend class A called B and C. In both classes I override method blah(). I have an array with objects of type B and C.
    For every instance object of the array, I'm trying to call the static method in the corresponding class. For objects of type B I want to call blah() method in B class and for objects of type C I want to call blah() method in C class. I know it's possible to call a static method with the name of the object, too, but for some reason (?) it calls blah() method in class A if I try this.
    So my question is: how do I code this? I guess I need to cast to the class name and then call the method with the class name, but I couldn't do it. I tried to use getClass() method to get the class name and it works, but I didn't know what to do from here...
    So any help would be appreciated. Thank you.

    As somebody already said, to get the behavior you
    want, make the methods non-static.You all asked me why I need that method to be
    static... I'm not surprised to hear this question
    because I asked all my friends before posting here,
    and all of them asked me this... It's because some
    complicated reasons, I doubt it.
    the application I'm writing is
    quite big...Irrelevant.
    Umm... So what you're saying is there is no way to do
    this with that method being static? The behavior you describe cannot be obtained with only static methods in Java. You'd have to explicitly determine the class and then explicitly call the correct class' method.

  • Error in using method get_event of class cl_htmlb_manager.

    Hi All,
    i am trying to get the event details in a particular method as follows;
    data: event type ref to cl_htmlb_event .
    event = cl_htmlb_manager=>get_event( runtime->              server-  >request ).
    i am getting an error
    field RUNTIME is unknown , it is neither in one of the specified tables nor defined by DATA statement. DATA statement. DATA statement.
    Where am i going wrong?
    plz help.
    BR,
    Annu.

    Hi Jorge,
    I am trying to use it in the method GET_LIST of class CL_SUS_M_ORDER_LIST .
    If i use
    event = cl_htmlb_manager=>get_event_ex( request ).
    again i get the error  Field REQUEST is unknown .
    and if i dont declare event using data statement
    data: event type ref to cl_htmlb_event .
    then i get the error that Field EVENT is unknown.
    My application is MVC pattern.
    So is there anyother way of geting the EVENT details when RUNTIME / REQUEST are not available ?
    Thaknks for the reply.

  • Moving a method from one class to another issues

    Hi, im new. Let me explain what i am trying to achieve. I am basically trying to move a method from one class to another in order to refactor the code. However every time i do, the program stops working and i am struggling. I have literally tried 30 times these last two days. Can some one help please? If shown once i should be ok, i pick up quickly.
    Help would seriously be appreciated.
    Class trying to move from, given that this is an extraction:
    class GACanvas extends Panel implements ActionListener, Runnable {
    private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
         private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
         private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
         private WorldMenuItems designMenuItemsCrossoverProbability;
    MenuBar getMenuBar() {
              menuBar = new MenuBar();
              addControlItemsToMenuBar();
              addSpeedItemsToMenuBar();
              addWorldDesignItemsToMenuBar();
              return menuBar;
    This is the method i am trying to move (below)
    public void itemsInsideWorldDesignMenu() {
              designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                        new String[] { "In Rows", "In Clumps", "At Random",
                                  "Along the Bottom", "Along the Edges" }, 1);
              designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                        new String[] { "50", "100", "150", "250", "500" }, 3);
              designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                        new String[] { "It grows back somewhere",
                                  "It grows back nearby", "It's Gone" }, 0);
              designMenuItemsApproximatePopulation = new WorldMenuItems(
                        "Approximate Population", new String[] { "10", "20", "25",
                                  "30", "40", "50", "75", "100" }, 2);
              designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                        new String[] { "At the Center", "In a Corner",
                                  "At Random Location", "At Parent's Location" }, 2);
              designMenuItemsMutationProbability = new WorldMenuItems(
                        "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                                  "1%", "2%", "3%", "5%", "10%" }, 3);
              designMenuItemsCrossoverProbability = new WorldMenuItems(
                        "Crossover Probability", new String[] { "Zero", "10%", "25%",
                                  "50%", "75%", "100%" }, 4);
    Class Trying to move to:
    class WorldMenuItems extends Menu implements ItemListener {
       private CheckboxMenuItem[] items;
       private int selectedIndex = -1;
       WorldMenuItems(String menuName, String[] itemNames) {
          this(menuName, itemNames, -1);
       WorldMenuItems(String menuName, String[] itemNames, int selected) {
          super(menuName);
          items = new CheckboxMenuItem[itemNames.length];
          for (int i = 0; i < itemNames.length; i++) {
             items[i] = new CheckboxMenuItem(itemNames);
    add(items[i]);
    items[i].addItemListener(this);
    selectedIndex = selected;
    if (selectedIndex < 0 || selectedIndex >= items.length)
    selectedIndex = 1;
    items[selectedIndex].setState(true);
         public int getSelectedIndex() {
              return selectedIndex;
    public void itemStateChanged(ItemEvent evt) {  // This works on other systems
    CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
    for (int i = 0; i < items.length; i++) {
    if (newSelection == items[i]) {
    items[selectedIndex].setState(false);
    selectedIndex = i;
    newSelection.setState(true);
    return;

    Ok i've done this. I am getting an error on the line specified. Can someone help me out and tell me what i need to do?
    GACanvas
    //IM GETTING AN ERROR ON THIS LINE UNDER NAME, SAYING IT IS NOT VISIBLE
    WorldMenuItems worldmenuitems = new WorldMenuItems(name, null);
    public MenuBar getMenuBar() {
              menuBar = new MenuBar();
              addControlItemsToMenuBar();
              addSpeedItemsToMenuBar();
              worldmenuitems.addWorldDesignItemsToMenuBar();
              return menuBar;
    class WorldMenuItems extends Menu implements ItemListener {
         private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
         private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
         private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
         private WorldMenuItems designMenuItemsCrossoverProbability;
         GACanvas gacanvas = new GACanvas(null);
       private CheckboxMenuItem[] items;
       private int selectedIndex = -1;
       WorldMenuItems(String menuName, String[] itemNames) {
          this(menuName, itemNames, -1);
       WorldMenuItems(String menuName, String[] itemNames, int selected) {
          super(menuName);
          items = new CheckboxMenuItem[itemNames.length];
          for (int i = 0; i < itemNames.length; i++) {
             items[i] = new CheckboxMenuItem(itemNames);
    add(items[i]);
    items[i].addItemListener(this);
    selectedIndex = selected;
    if (selectedIndex < 0 || selectedIndex >= items.length)
    selectedIndex = 1;
    items[selectedIndex].setState(true);
         public int getSelectedIndex() {
              return selectedIndex;
    public void itemStateChanged(ItemEvent evt) {  // This works on other systems
    CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
    for (int i = 0; i < items.length; i++) {
    if (newSelection == items[i]) {
    items[selectedIndex].setState(false);
    selectedIndex = i;
    newSelection.setState(true);
    return;
    public void itemsInsideWorldDesignMenu() {
         designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                   new String[] { "In Rows", "In Clumps", "At Random",
                             "Along the Bottom", "Along the Edges" }, 1);
         designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                   new String[] { "50", "100", "150", "250", "500" }, 3);
         designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                   new String[] { "It grows back somewhere",
                             "It grows back nearby", "It's Gone" }, 0);
         designMenuItemsApproximatePopulation = new WorldMenuItems(
                   "Approximate Population", new String[] { "10", "20", "25",
                             "30", "40", "50", "75", "100" }, 2);
         designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                   new String[] { "At the Center", "In a Corner",
                             "At Random Location", "At Parent's Location" }, 2);
         designMenuItemsMutationProbability = new WorldMenuItems(
                   "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                             "1%", "2%", "3%", "5%", "10%" }, 3);
         designMenuItemsCrossoverProbability = new WorldMenuItems(
                   "Crossover Probability", new String[] { "Zero", "10%", "25%",
                             "50%", "75%", "100%" }, 4);
    public void addWorldDesignItemsToMenuBar() {
         gacanvas = new GACanvas(null);
         itemsInsideWorldDesignMenu();
         Menu designMenuItems = new Menu("WorldDesign");
         designMenuItems.add(designMenuItemsPlantGrowth);
         designMenuItems.add(designMenuItemsPlantCount);
         designMenuItems.add(designMenuItemsPlantEaten);
         designMenuItems.add(designMenuItemsApproximatePopulation);
         designMenuItems.add(designMenuItemsEatersBorn);
         designMenuItems.add(designMenuItemsMutationProbability);
         designMenuItems.add(designMenuItemsCrossoverProbability);
         gacanvas.menuBar.add(designMenuItems);

  • Calling a method from different class

    Hey peeps,
    say i have a method in another class and i wish to call it, what would the code be for that?
    say for example the method was called createNewShoeBox and i was in another class?
    hope that makes sence

    jermaindefoe wrote:
    lol! id love to have one, and in which case would love to have the money for one as id definatley take it up,In the following part, you're saying you're a student. So there are peers you can ask, if not your professor. There are certainly also some who actualy know some programming and would teach you if you just asked them.
    im a first year student bear in mind though lol!!! and ma struggling, I see that, and the way you handle your problems, that won't change for the next few years.
    i may not be as good at java as you, but i can do other things better than you can, and thats life, we all have to start somewhereWhat you also can't do as well as I do is "realizing that using an internet forum is one of the worse ways to have people helping you to learn programming". You're lacking a lot of understanding for concepts where the label "basic" is almost exaggerating. I'm sure you can get that understanding, but being spoon-fed through a forum with no visible effort to figure things out is not the way to do it.

  • Calling a Method in other Class

    I want to call a method in another class when an action is preformed can anyone suggest how I might do this??
         addSquare.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
         

    I want to call a method in another class when an
    action is preformed can anyone suggest how I might do
    this??
            addSquare.addActionListener(new ActionListener()
                 public void actionPerformed(ActionEvent e)
                 {               OtherClass oc = //getrefererncetootherclass
                   oc.methodtocall(params, to, pass);

  • Calling a method of one class from another withing the same package

    hi,
    i've some problem in calling a method of one class from another class within the same package.
    for eg. if in Package mypack. i'm having 2 files, f1 and f2. i would like to call a method of f2 from f1(f1 is a servlet) . i donno exactly how to instantiate the object for f2. can anybody please help me in this regard.
    Thank u in advance.
    Regards,
    Fazli

    This is what my exact problem.
    i've created a bean (DataBean) to access the database. i'm having a servlet program (ShopBook). now to check some details over there in the database from the servlet i'm in need to use a method in the DataBean.
    both ShopBook.java and DataBean.java lies in the package shoppack.
    in ShopBook i tried to instantiate the object to DataBean as
    DataBean db = new DataBean();
    it shows the compiler error, unable to resolve symbol DataBean.
    note:
    first i compiled DataBean.java, it got compiled perfectly and the class file resides inside the shoppack.
    when i'm trying to compile the ShopBook its telling this error.
    hope i'm clear in explaining my problem. can u please help me?
    thank u in advance.
    regards,
    Fazli

  • Calling a method from another class... that requires variables?

    I'm calling a method from another class to change the date (its a date object) in another class.
    I keep getting the error 'setDate(int,int,int) in Date cannot be applied to ()'
    My code is:
    public int changeDate()
         cycleDate.setDate();
    }I'm guessing I need to pass 3 parameters (day, month, year), but I'm not sure how! I have tried, but then I get errors such as ')' expected?
    Any ideas! :D

    f1d wrote:
    I'm calling a method from another class to change the date (its a date object) in another class.
    I keep getting the error 'setDate(int,int,int) in Date cannot be applied to ()'
    My code is:
    public int changeDate()
    cycleDate.setDate();
    }I'm guessing I need to pass 3 parameters (day, month, year), seems that way from the error you posted
    but I'm not sure how!
    setDate(16, 6, 2008);
    I have tried, but then I get errors such as ')' expected?
    Any ideas! :Dyou need to post your code if you're getting specific errors like that.
    but typically ')' expected means just that, you have too many or not enough parenthesis (or in the wrong place, etc.)
    i.e. syntax error

  • Calling a method from abstarct class

    Hi Experts,
    Am working on ABAP Objects.
    I have created an Abstract class - with method m1.
    I have implemented m1.
    As we can not instantiate an abstract class, i tried to call the method m1 directly with class name.
    But it it giving error.
    Please find the code below.
    CLASS c1 DEFINITION ABSTRACT.
      PUBLIC SECTION.
        DATA: v1 TYPE i.
        METHODS: m1.
    ENDCLASS.                    "c1 DEFINITION
    CLASS c1 IMPLEMENTATION.
      METHOD m1.
        WRITE: 'You called method m1 in class c1'.
      ENDMETHOD. "m1
    ENDCLASS.                    "c1 IMPLEMENTATION
    CALL METHOD c1=>m1.
    Please tell me what is wrong and how to solve this problem.
    Thanks in Advance.

    Micky is right, abstract means not to be instantiated. It is just a "template" which you can use for all subsequent classes. I.e you have general abstract class vehicle . For all vehicles you will have the same attributes like speed , engine type ,  strearing , gears etc and methods like start , move etc.
    In all subsequent classes (which inherit from vehicle) you will have more specific attributes for each. But all of these classes have some common things (like the ones mentioned above), so they use abstract class to define these things for all of them.
    Moreover there is no sense in creating instance (real object) of class vehicle . What kind of physical object would vehicle be? there is no such object in real world, right? For this we need to be more precise, so we create classes which use this "plan" for real vehicles. So the abstract class here is only to have this common properties and behaviour defined in one place for all objects which will have these. Abstract object however cannot be created per se. You can only create objects which are lower in hierarchy (which are specific like car , ship, bike etc).
    Hope this claryfies what we need abstract classes for.
    Regards
    Marcin

Maybe you are looking for

  • ESS Claim Application Behaviour

    Hi ESS Experts, I have configured Claims Functionality. Now when I am trying to raise new claim request, system is not displaying Dropdown LOV's. It was properly and i was able to update records in R/3. We have not done any changes in Configuration .

  • How can I install Win XP instead of Win 7 on mac?

    I bought a MacBook Pro 2.3GHz dual-core Intel i5 (Mac OS X 10.6 Snow Leopard) and found out the Boot Camp requires windows 7. I don't have windows 7 but windows XP (SP3). I have already finished the partition by bootcamp and succeed in windows XP ins

  • Problem with a SMS-signature, or a message got stuck

    Have an iPhone 4s running iOS 6.0.1 It seems like a textmessage got stuck like an signature in the message program. Every time i open up a new message an old, previous message shows already prewritten i the text-field. It also appear when I try to fo

  • About main function

    When I write the main function,I'm always puzzled by the parameter which is send to the main function. For example: main(String args[]) and main(String[] args),What kind of difference is between the "String args[]" and "String[] args"?

  • Subform - XML:  LiveCycle Designer 7.x

    I have a problem populating part of my dynamic/interactive sub forms in to a XML-message. The sub form uses setInstances and is based on a XSD schema. When I bind the different elements to the 'data view' elements it seems to reject the [*] occurrenc