JAXB:How to get the type of an element

Hi
I am working with JAXB 2and i am using a custom ValidationEventHandler to validate my xml document:The issue I have is that when my document isn't valid,i would like to get the error node and its type(string,date...)
I tryed node.getNodeType() but it return if the node is ATTRIBUTE_NODE,TEXT_NODE....
public boolean handleEvent(ValidationEvent ve) {           
        if (ve.getSeverity()==ValidationEvent.FATAL_ERROR || 
                               ve .getSeverity()==ValidationEvent.ERROR){
            ValidationEventLocator  locator = ve.getLocator();
            org.w3c.dom.Node node=locator.getNode();
          System.out.println("ERROR element type:"+node.getNodeType());
         return true;
       }How could i get the type(String,Date,Integer...) of the node in error?
Edited by: riadhhwajdii on Aug 14, 2010 4:20 AM

As you already mention that is not resolved before the annotation processing stage
[ http://openjdk.java.net/groups/compiler/doc/compilation-overview/index.html]
So, you probably need to produce your own analysis code or better reuse the compiler's own code if that turns out to be easy (no clue). I reckon it is better if you avoid modifying the compiler itself as it will make much more difficult to maintain and deploy your (more than a) processor.
Sorry if you already tough about this.
Edited by: discretoboy on Apr 7, 2009 3:20 PM

Similar Messages

  • How to get the values of all elements and sub elements from  following xml

    how to get the values of all elements and sub elements from following xml...
    <?xml version="1.0" encoding="UTF-8" ?>
    <List_AML_Finacle xmlns="http://3i-infotech.com/Cust_AML_Finacle.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://3i-infotech.com/Cust_AML_Finacle.xsd List_AML_Finacle.xsd">
    <TransactionID>TransactionID</TransactionID>
    <Match>
    <Src_Matched_Field>Src_Matched_Field</Src_Matched_Field>
    <List_Matched_Field>
    <FSFM_Matches>
    <NUMBER>NUMBER</NUMBER>
    <TERROR>TERROR</TERROR>
    <TU>TU</TU>
    <NAMEU>NAMEU</NAMEU>
    <DESCRIPT>DESCRIPT</DESCRIPT>
    <KODCR>KODCR</KODCR>
    <KODCN>KODCN</KODCN>
    <AMR>AMR</AMR>
    <ADDRESS>ADDRESS</ADDRESS>
    <SD>SD</SD>
    <RG>RG</RG>
    <ND>ND</ND>
    <VD>VD</VD>
    <GR>GR</GR>
    <YR>YR</YR>
    <MR>MR</MR>
    <CB_DATE>CB_DATE</CB_DATE>
    <CE_DATE>CE_DATE</CE_DATE>
    <DIRECTOR>DIRECTOR</DIRECTOR>
    <FOUNDER>FOUNDER</FOUNDER>
    <TERRTYPE>TERRTYPE</TERRTYPE>
    </FSFM_Matches>
    <OfacMatchDetails>
    <UID>UID</UID>
    <TITLE>TITLE</TITLE>
    <SDNTYPE>SDNTYPE</SDNTYPE>
    <REMARKS>REMARKS</REMARKS>
    <ID_UID>ID_UID</ID_UID>
    <IDTYPE>IDTYPE</IDTYPE>
    <IDNUMBER>IDNUMBER</IDNUMBER>
    <IDCOUNTRY>IDCOUNTRY</IDCOUNTRY>
    <ISSUEDATE>ISSUEDATE</ISSUEDATE>
    <EXPIRATIONDATE>EXPIRATIONDATE</EXPIRATIONDATE>
    <ADDRESS1>ADDRESS1</ADDRESS1>
    <ADDRESS2>ADDRESS2</ADDRESS2>
    <ADDRESS3>ADDRESS3</ADDRESS3>
    <CITY>CITY</CITY>
    <STATEORPROVINCE>STATEORPROVINCE</STATEORPROVINCE>
    <POSTALCODE>POSTALCODE</POSTALCODE>
    <COUNTRY>COUNTRY</COUNTRY>
    </OfacMatchDetails>
    </List_Matched_Field>
    </Match>
    </List_AML_Finacle>

    avoid multi post
    http://forum.java.sun.com/thread.jspa?threadID=5249519

  • How to get the count of repeating elements in a xml doc.

    In many xml documents, in is common to have repeating child elements and what I would like to know is how do I determine exactly how many of these child elements exist in a particular document. There is probably a correct XPath string to determine this, but I cannot figure out what it is. Here is an example
    <a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>
    The above 'c' element is what varies in number from document to document and I need to know how to get the number of 'c' elements for the document, which would be 3 in the above case.

    create table test_xml(data xmltype)
    insert into test_xml values(
    xmltype('<a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>')
    select extract(data, '/a/b/c').getclobval() from test_xml
    select count(*) from test_xml
    where existsnode(data, '/a/b/c')=1
    good luck.

  • How to get the type of answer in a workitem?

    Hi Experts,
    I am building a report to get the users responsible for the approval of SCs and POs, in this report I need to get the type of answer given by the approver, if they have rejected, approved or partial rejected / approved the object.
    When I look at the container of the workitem I can get the agent responsible for the action and the dates, but I need your help to determine the type of answer. I believe I can get this information from the approval state, no? But I am getting a lot of different approval states: 0, 1, 3, 4, 10, 11 and 15. Can you provide me some guidance? I am new to workflows and I am stuck in this point.
    I am using SRM 5.0 and n-step approval workflow.
    Thanks in advance,
    Francisco

    I'm not an SRM expert, but from a pure workflow point you can read the output of a workitem. So, check how your workflow is built and then see what values are returned in the corresponding return fields. Explore the workitem structure in the log.

  • How to get the type of numeric

    Hi,
    I would like to know how getting the type of a numeric data programmatically. (DBL, SDL, I16, I32,etc.)
    This property is defined by selecting "Type of data" in the property's window of a numeric data; then by clicking on "representing".
    I tried to find the solution by using a property node then accessing to the property called 'representing".
    Without success, it seems this function is not available.
    Is anyone would know the solution.
    Thanks by advance,
    pr93

    There are several solutions.
    The 7.x version of the Flatten To String function had an additional output called "type string" which was actually an array of numbers. This array would tell you that information. OpenG has a VI that will tell you the datatype from this array. It's called "Get TDEnum From TD" and is in the LabVIEW Data Tools library. You can use VI Package Manager to easily install OpenG libraries.
    If you have a control you could use a reference and then use the "Get Type of Control" VI from the <vi.lib>\Utility\GetType.llb library.
    You could convert th"e numeric value to a variant and then use the "Get Type of Variant" VI from the <vi.lib>\Utility\GetType.llb library.

  • How to get the type of org.omg.CORBA.Any ?

    Hi there
    My q is: how can I get the type of an Any object?
    Please have a look at the following code:
    ORB orb = ORB.init();
    org.omg.CORBA.Any anytest = orb.create_any();
    anytest.insert_string("mystring");
    TypeCode tc = anytest.type();
    Now how can I get back that the type is String??
    Regards
    Brian

    Hi,
    Try using anytest.type().kind().value() -> should yield TCKind._tk_string. See the javadoc for more info.
    I think that the only way to check types is by comparing the codes; as far as I know there is no easy way to get the equivalent Java Class object or so. But I could be wrong on that one.
    Best,
    Guy

  • How to get the type of user role in ISF?

    We have functionality to hide all the buttons on Monitor task, which was successfully achieved by javascript. But we need to enable these buttons for only Site Administrators, so that they only can do necessary modifications upon request from end users. Can someone point me to correct direction how to get the user role when a user is not a Site Administrator. Thanks in advance.

    What about having your custom ISF onload script first run a db query (on older version called a rcFetch) which would evaluate if the person loading form is a member of the site admin ou.
    Here's a rough example:
    ISF_onLoad()
     rcFetch('Q1','Q1PL=' + UserID);
    This will then run a query to validate if the person is a member of the admin ou.
    SELECT * FROM DirOrganizationUnitPeople WHERE PersonID = #P1# AND OrganizationalUnitID = 1 (this should be the id of the site admin ou or the ou which you are referring to as an admin)
    then have a call back to determine if any records where return, which indicate the person is a member of the site admin ou.  
    function Q81_DataCallback(retArray, queryList)
    if (retArray['Q8500._COUNT_'] == 1)
     {  *Show the fields*  }
    Hope this helps.

  • Get the type of collecion elements

    Hi,
    I would like to get the type of the elements of a collection when I give the name the collection. Does anybody suggest anything about the SQL code?
    For example
    CREATE OR REPLACE TYPE CourseList AS TABLE OF VARCHAR2(64);
    CREATE TABLE department (
    name VARCHAR2(20),
    director VARCHAR2(20),
    office VARCHAR2(20),
    courses CourseList)
    NESTED TABLE courses STORE AS courses_tab;
    How it is possible to get the type of elements of CourseList (in the example it is VARCHAR2(64)) if I give the name of the nested table courses?
    Thank you

    > I would like to get the type of the elements of a collection when I give the name the collection.
    sniff sniff
    Smells like some kind of dynamic SQL or dynamic PL/SQL thing. It usually stinks.
    If the dynamic part comes into play at rendering time (like in APEX for example that executes a SQL and then needs to dynamically render the projection) - use DBMS_SQL cursors (or ref cursors when rendering in an external client). Use the describe interface to dynamically determine the structure of the SQL projection.
    Anything more than that - think carefully. Especially at it seems you want to deal with actual relational data structure dynamically. 99% of the time it is flawed and the remaining 1% of the time the person usually have no idea what he (or she) is really doing... ;-)

  • How to get the member of cost element group from Profit center group

    Hi Guys,
                  I need to get the member of cost element group from Profit center group like in Tcode KCH3 and the same from Account Group like in Tcode KDH3.
    Any Function Module available to get this data.
    Thank U for Ur time.
    Cheers
    Senthil

    I am closing this thread.

  • How to get the type of the object poped from a stack

    Hi,
    I have a stack which contains Boolean, Integer, MyBean objects.
    Now depending on the type of object pop from stack i want to perform the different operations. Right now i m doing it like this:
    Object a = stk.pop(); // stk is my stack
    if ( a instanceof Object)
    else if( a instanceof Boolean)
    else
    .}but it is not working...........
    when i do like this
    if(stk.pop() instanceof Boolean)
    else
    }it works but by this i lost the poped element............ what is the standard way to do such operations.
    manish

    Are you sure there isn't a cleaner way of doing what you are trying to achieve? You may want to take the opportunity to slightly re-think your design.
    However, if you want to proceed down this route, just hold on to the object you popped, and then do the explicit case analysis on that:
    Object obj = stack.pop();
    if (obj instance of Boolean) {
    } else if (obj instance of Integer) {
    }Oh yeah, do not have the "instanceof Object" as your first check!
    This will return true for any non-null reference (have a look at some java tutorials if you dont know why this is).

  • How to get the Max value of elements of type datetime

    Hi All ,
    I wanted to get the latest timestamp value ( datatype as datetime) from node list. I have following xml. In this xml, i want to get the modifydate element which has latest timestamp through xquery/xpath, it should return me following result 2011-09-29T17:21:17+10:00
    <CustomerList>
    <CustomerDetails>
    <name> Test 1</name>
    <status>active</status>
    <modifyDate>2011-08-20T17:21:17+10:00</modifyDate>
    </CustomerDetails>
    <CustomerDetails>
    <name> Test 2</name>
    <status>cancel</status>
    <modifyDate>2011-08-29T17:21:17+10:00</modifyDate>
    </CustomerDetails>
    <CustomerDetails>
    <name> Test 3</name>
    <status>active</status>
    <modifyDate>2011-09-29T17:21:17+10:00</modifyDate>
    </CustomerDetails>
    </CustomerList>
    i tried to use the
    //CustomerList/CustomerDetails/modifyDate[not(. <=../preceding-sibling::CustomerList/CustomerDetails/modifyDate) and not(. <=../following-sibling::CustomerList/CustomerDetails/modifyDate)]
    But it is not working on datetime datatype.
    Any help in this regard is much appreciated.
    Regards
    Edited by: user6736659 on Sep 5, 2011 6:15 AM

    Hi,
    The following XQuery should give you what you want :
    max(
    for $i in /CustomerList/CustomerDetails/modifyDate
    return xs:dateTime($i)
    )For instance, using Oracle SQL :
    SQL> var xmldoc varchar2(4000)
    SQL> begin
      2   :xmldoc := '<CustomerList>
      3  <CustomerDetails>
      4  <name> Test 1</name>
      5  <status>active</status>
      6  <modifyDate>2011-08-20T17:21:17+10:00</modifyDate>
      7  </CustomerDetails>
      8 
      9  <CustomerDetails>
    10  <name> Test 2</name>
    11  <status>cancel</status>
    12  <modifyDate>2011-08-29T17:21:17+10:00</modifyDate>
    13  </CustomerDetails>
    14 
    15  <CustomerDetails>
    16  <name> Test 3</name>
    17  <status>active</status>
    18  <modifyDate>2011-09-29T17:21:17+10:00</modifyDate>
    19  </CustomerDetails>
    20  </CustomerList>';
    21  end;
    22  /
    PL/SQL procedure successfully completed
    SQL> select xmlquery('max(
      2   for $i in /CustomerList/CustomerDetails/modifyDate
      3   return xs:dateTime($i)
      4  )'
      5  passing xmltype(:xmldoc)
      6  returning content
      7  )
      8  from dual
      9  ;
    XMLQUERY('MAX(FOR$IIN/CUSTOMER
    2011-09-29T17:21:17.000000+10:00

  • How to get the table of cost elements data?

    Dear friends,
    I want ot get the Chart_of_Accounts, Cost_Element, Short_Text into an internal table, but how can I find the related tables in SAP system?
    Thanks a lot!

    Hi,
    The table for cost element is  CSKA.
    Alternately you can use the bapi BAPI_COSTELEM_GETDETAIL for getting the details also.
    Regards,
    Ankur Parab

  • How to know the type of mobile?

    how to get the type of mobile model mean under nokia asha 308(rm 352/ rm 838) which model i have when i am buying this mobile .no option to check the *#0000# option then how to get this..

    Check the label on the box or under the battery.

  • How to get the values from struct data type using java code..?

    Hi ,
    I am newer to java.
    we are using oracle database.
    How to get the data from struct data type using java code.
    Thanks in Advance.
    Regards,
    kumar

    Hi Rajeev,
    To retrieve a FilterContainer you will need to traverse the report structure:
    ReportStructure boReportStructure = boDocumentInstance.getStructure();
    ReportContainer boReportContainer = (ReportContainer) boReportStructure.getReportElement(0);
    FilterContainer boFilterContainer = null;
    if (boReportContainer.hasFilter()) {
         boFilterContainer = boReportContainer.getFilter();
    } else {
         boFilterContainer = boReportContainer.createFilter(LogicalOperator.AND);
    Calling boDocumentInstance.getStructure() will retrieve the entire structure for the document.
    Calling boReportStructure.getReportElement(0) will retrieve the structure for the first report of the document.
    Hope this helps.
    Regards,
    Dan

  • Get the Type of a generic field at runtime, How to?

    Hello,
    As the topic already says, i need to get the Type of a particular field of a class. This field is declared private and generic. In C# there is a method
    Type Object.getTypeIs there any specific way to do this in Java 1.5?
    Please excuse my poor english.
    Thanks in advance.
    Markus

    McNepp wrote:
    endasil wrote:
    McNepp wrote:
    If you want to know the parametrized type (String in the example), I think there is no way of knowing this in Java 1.5 or Java 1.6, since the parametrized type is erased and not available at run time.The type of a parameterized field is not erased.For most intents and purposes, it is. Type erasure refers to the fact that at runtime, there are not actually multiple class binaries depending on the generic arguments to a class. Therefore, an ArrayList<T> is actually just an ArrayList with no generics.
    Frankly, I don't understand why you insist that the information on generic fields that the OP was asking about is lost at runtime.I wasn't trying to insist that. At the time, I was replying more to Saish and trying to reaffirm that most information about generics is lost at run-time. I mistakenly ignored how you qualified it with "field."
    What you write about instances of generic classes losing their type information is of course correct, albeit not to the point of the original question.Nope, you're right. I was just trying to reconcile the fact that many people get confused that there's any information available at run-time, and so start down the path of thinking that type erasure doesn't exist. But it very much does.
    The original question was about how to obtain the type of a generic field.And I did show in my example that even that is fairly limited, given that if the type is provided by the parameter of the class, it doesn't give you anything useful (I'm not trying to say you said it would!).
    The compiler preservers this information in the class file, so it can be obtained at runtime. Frameworks like JPA put this to use extensively, proving that it is of real value.Definitely. However I don't see this having as much to do with generics as basic reflection functionality. If you can get the type of a field at run-time, you should be able to get the parameters as well! That should in no way belittle its value, though. But I would have guessed (knowing little about) that JPA wouldn't put that to use so much as the type parameters of an accessor return type or mutator argument type. Especially since I thought we'd shown that you would need your fields to be non-private for JPA to be able to gain information about their type.
    Edit: getDeclaredField works fine with private members, and returns the expected "java.lang.String" from jschell's example above
    Edited by: endasil on 28-Apr-2009 10:39 AM

Maybe you are looking for

  • Itunes/Iphone 4s replaced - Music, voice memos and playlist missing and or deleted

    Backed up old phone, had phone replaced from Apple Store.  they told me to restore from back up at home computer.  My playlists are gone, my voice memos are all gone, losing memos and pictures on the phone.  Can't play any music on the computer eithe

  • How to connect an external HD to a 2007 Mac Mini with FireWire

    I have a 2007 Mac Mini with a 1.83 GHz Intel Core Duo processor, 1 GB of RAM, and an 80 GB HD. I recently migrated to Snow Leopard (OS X 10.6.5) from Tiger (OS X 10.4.11). I purchased a 500 GB external HD from Seagate which I want to use to back up b

  • How do you change default page size in pdf?

    I purchased CREATE solely to create a pdf file from a scanned document. I created the PDF but the default page size is 30.15 x 20.83 INCHES. I cannot seem to change the page size. I called support services 4 times (talking with Sakthivel, Shashank, M

  • Product selection advise please.

    I have a client that has just installed a T1 line. They wish to retain DSL as backup. I'm looking for a Router with VPN capability, multiple (2) IP input, and 16 port switch. at least 4 need to be 1000 bps. Does Cisco have such a product?

  • Redirect from client provision to origin url

    hello Does anyone know if there is a way to redirect a user to home page from client provision portal? we using wired solution. the client PC have web browser automatically opens to home page when employees log in. and since we have posture configure