Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8025625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:13:32+00:00 2026-06-04T23:13:32+00:00

I have an xml schema (generated automatically using trang) which keeps changing. These changes

  • 0

I have an xml schema (generated automatically using trang) which keeps changing. These changes are not very elaborate. Only some elements are added or deleted from this schema. From this schema, I am generating java classes (using cxf) by which I will unmarshall the xml document.

As schema changes, my auto-generated java classes also change. Again, as with schema, changes in java classes are not very big. For instance, if an element say elemA is added to schema; some related functions say getElemA() and setElemA() are added to auto-generated java class.

Now how would I make sure that a particular function exists in these auto-generated classes? One solution is to hand-write the schema such that all possible elements of xml are covered. This is what I’ll ultimately do. But for now, I have not fixed the format of xml file.

UPDATE :

There is a possibility that a method getElemA() may be defined in auto-generated classes. I do not have control over the auto-generation of these classes. But in my main class, if have following code,

If method getElemA exists then 
     ElemA elemA = getElemA()

This code will always be there in my main class. If method getElemA() is generated in one of the auto-generated class then there is no problem. But if this method is not generated then compilers complain that this method does not exists in any of the class.

Is there any way that I can make compiler not to complain about this function at compile time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:13:35+00:00Added an answer on June 4, 2026 at 11:13 pm

    One method is mentioned by @missingfaktor and another is below (if you know the name and parameters of the api).

    Say you have one method which takes no args:

    Method methodToFind = null;
    try {
      methodToFind = YouClassName.class.getMethod("myMethodToFind", (Class<?>[]) null);
    } catch (NoSuchMethodException | SecurityException e) {
      // Your exception handling goes here
    }
    

    Invoke it if present:

    if(methodToFind == null) {
       // Method not found.
    } else {
       // Method found. You can invoke the method like
       methodToFind.invoke(<object_on_which_to_call_the_method>, (Object[]) null);
    }
    

    Say you have one method which takes native int args:

    Method methodToFind = null;
    methodToFind = YouClassName.class.getMethod("myMethodToFind", new Class[] { int.class });
    

    Invoke it if present:

    if(methodToFind == null) {
       // Method not found.
    } else {
       // Method found. You can invoke the method like
       methodToFind.invoke(<object_on_which_to_call_the_method>, invoke(this,
          Integer.valueOf(10)));
    }
    

    Say you have one method which takes boxed Integer args:

    Method methodToFind = null;
    methodToFind = YouClassName.class.getMethod("myMethodToFind", new Class[] { Integer.class });
    

    Invoke it if present:

    if(methodToFind == null) {
       // Method not found.
    } else {
       // Method found. You can invoke the method like
       methodToFind.invoke(<object_on_which_to_call_the_method>, invoke(this,
          Integer.valueOf(10)));
    }
    

    Using the above soln to invoke method won’t give you compilation errors.
    Updated as per @Foumpie

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application doing XML<->conversions using Jaxb and automatically generated classes with maven-jaxb2-plugin.
I have parametrized persistence.xml. I am trying to generate ddl schema using hbm2ddl. How
I have developed an application which can create Xml files from Xml schema with
I am using classes that were generated from an XML schema using the xsd.exe
I'm working with a complicated xml schema, for which I have created a class
I have an XML document generated by a 3rd party using BizTalk, and I
We have a generated XML schema that I am a bit confused on the
I have generated a class from XSD. The following [System.Xml.Serialization.XmlElementAttribute(mailer, Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public itemOrderMailer[] mailer
Using C# and .Net 4.0 I have a generated schema that looks like this:
I have an xml schema and csv data to generate corresponding xml files. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.