How to handle unknown root node type when parsing?

Hello all, hoping someone knows how to accomplish this...
I'm trying to use XMLBeans to parse RIXML 2.0 documents. This schema allows for
multiple root node types, so I don't know when I'm trying to parse a file if the
root node is a Research node or a Product node, for example. If I try to invoke
parse and there is a type mismatch I get the following error:
com.bea.xml.XmlException: D:\RIXML\V2TestDoc.xml:0: error: The document is not
a Research@http://www.rixml.org/2002/6/RIXML: document element local name mismatch
expected Researchgot Product
     at com.bea.xbean.store.Root.verifyDocumentType(Root.java:472)
     at com.bea.xbean.store.Root.autoTypedDocument(Root.java:394)
     at com.bea.xbean.store.Root.loadXml(Root.java:763)
     at com.bea.xbean.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:286)
     at com.bea.xbean.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:224)
     at org.rixml.x2002.x6.rixml.ResearchDocument$Factory.parse(Unknown Source)
     at Test.main(Test.java:21)
Exception in thread "main"
So how do I generically handle parsing when I don't know what type of root node
I'm going to get?
Thanks,
Joe

Hello Joe -- You might try parsing the document as XmlObject (which your
schema-generated types extend). Then you could use an XmlCursor to discover
what the root element's local name is. Something like the following code
might be a way to do it. You could also simply re-parse the document after
discovering its root element name, but that would probably be more
expensive.
XmlObject xml = XmlObject.Factory.parse(mydoc.xml);
XmlCursor cursor = xml.newCursor();
cursor.toFirstContentToken();
if (cursor.getName().getLocalPart().equals("Research"))
// cast the XmlObject to your ResearchDocument type and use it.
else if (cursor.getName().getLocalPart().equals("Product"))
// cast the XmlObject to your ProductDocument type and use it.
cursor.dispose();
Steve
"Joe Celentano" <[email protected]> wrote in message
news:[email protected]..
>
Hello all, hoping someone knows how to accomplish this...
I'm trying to use XMLBeans to parse RIXML 2.0 documents. This schemaallows for
multiple root node types, so I don't know when I'm trying to parse a fileif the
root node is a Research node or a Product node, for example. If I try toinvoke
parse and there is a type mismatch I get the following error:
com.bea.xml.XmlException: D:\RIXML\V2TestDoc.xml:0: error: The document isnot
a Research@http://www.rixml.org/2002/6/RIXML: document element local name
mismatch
expected Researchgot Product
at com.bea.xbean.store.Root.verifyDocumentType(Root.java:472)
at com.bea.xbean.store.Root.autoTypedDocument(Root.java:394)
at com.bea.xbean.store.Root.loadXml(Root.java:763)
atcom.bea.xbean.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:28
6)
atcom.bea.xbean.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:22
4)
at org.rixml.x2002.x6.rixml.ResearchDocument$Factory.parse(Unknown Source)
at Test.main(Test.java:21)
Exception in thread "main"
So how do I generically handle parsing when I don't know what type of rootnode
I'm going to get?
Thanks,
Joe

Similar Messages

  • How to get a Tree Node Value when a Tree is Expanded

    My reqiurement is when i Expand a Tree i need the Expanded tree Node Value. For Example Consider Parent as a Root Node of a Tree, and Consider its two Children Child1 and Child2.
    When + Parent Expanded
    I will Get the Output as --Parent
    - Child1
    - Child2
    so As when i expand the Tree i must Get the String Value Parent.

    duplicate
    How to get a Tree Node Value when a Tree is Expanded

  • How to handle blank root element in xml source file

    Hi There,
    I have a dataflow which using xml source file. The job keep failing and I guess it might be caused by one of the root element which is blank. Can anyone advise me how to handle it?
    The xml file look like this:
    -<orderinfo>
    --<orderdetail>
    ---<orderid>1</orderid>
    ---<orderdate>20110101</orderdate>
    --</orderdetail>
    --<abc />
    -</orderinfo>
    element <abc> is blank
    Thanks and Regards,
    BL

    Hi Suneer,
    The issue is DS cannot validate the source file at all. It returns error message when I try to preview the source file in the dataflow. Is there any work around I can implement other than request the source team to change the file layout?
    Thanks,
    BL

  • How to get the root node of a tree?

    I wanna get all the leaf node of a tree.But JTree have no method about how to get the root TreeNode of a tree.Then how should I do?

    try this:
    http://javaalmanac.com/egs/javax.swing.tree/GetNodes.html?l=rel

  • How to return to root node immediately

    Hi,
    In my repository manager, there're 2 kinds of navigation: folder-based and navigation-based. The user can change navigation type at runtime, while navigating inside a folder.
    I plan to add a command (
    extends AbstractCommand
    ) in the context menu for the user to choose navigation type. Now my question is, after changing the navigation type in code, how to show the root folder to the user immediately? I don't know its URL, or the URL of KM Content.
    Thanks,
    Ray

    Hi Fallon,
    Your answer is what I am looking for, but the URL doesn't work: /irj/go/km/docs shows the same page as /irj/portal. Am I missing some files on server, or the root URL for KM is another URL?
    In my machine the root URL for KM is http://vanpgsap02:50000/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fadministrator!2fcontent_admin!2fcontent_admin_role!2fcom.sap.portal.content_admin_ws!2fcom.sap.km.AdminContentExplorer!2fcom.sap.km.AdminExplorer. I guess it's not what I want.
    Waiting for reply.
    Thanks,
    Ray

  • How do I fix "Invalid node type: selectionbox" error?

    Ok I've got my document all made and nice and pretty, I use it to enter information and use the selection box to make visible the fields I need for each card. Then I save it and try to open it and get the following error popup message.
    Invalid node type: selectionbox
    Invalid node type: selectionbox
    Invalid node type: selectionbox
    Invalid node type: selectionbox
    Invalid node type: selectionbox
    Invalid node type: selectionbox
    Invalid node type: selectionbox
    Message limit exceeded. Remaining 10 errors not reported.
    So I click ok on the error box. It opens the file with adobe reader like it's supposed to and then immediately I get the "Adobe reader has stopped working, windows can check online for a solution to the problem" and I get the two choices that both involve closing the program.
    I got this once before and after about a half hour of fiddling with the original livecycle file it stopped doing it. I have no idea what I did to make it start or stop doing it and I'm not sure I even did do anything to cause it.
    Has anyone else come across this problem? Does anyone know what I need to do to fix it?
    I've included the file I'm having issues with.
    Thanks,
    Aaron

    Hi Aaron,
    I cant replicate your problem. What I did notice though, is when I make a selection on almost every selection box,  I get the following error:
    'cardtwo.TextField1 has no properties'. The error is coming from the following piece of code in the change event: 'cardtwo.TextField1.caption.text.value = (this.rawValue);'
    I dont see a TextField1 in the cardtwo subform so I suspect that this field has been renamed and / or moved since that bit of code was added. Perhaps that would be a good place to start and could very possibly be the cause of your problem.
    Dallas

  • Set root node expanded when the page is opened

    Hi,
    I have a tree in a page having 2 children.
    Currently when I come to the page, the parent node appears, when click on that, it will show the 2 children.
    My requirement is, when come to the page, the parent node should be expanded and show its children.
    Please suggest how can i do this....!
    Thanks,
    ViN

    Hi Arun,
    When initiallyExpanded property of the tree is set to true, all the child nodes also expanded.
    My requirement is to expand only parent node.
    Thanks,
    ViN

  • How to create multiple root node in a tree

    Hi Experts,
    As per my requirement I have two requirements for  tree creation:
    1) Create a Tree which can display multiple root node.
    2) Cretae a Tree which can display data directy without any folder.
    I am new in Tree development.
    Can any body help me out to get it done.
    If it is not possible then also i need a confirmation from experts.
    Regards,
    Madhu

    use method add_node of the class Cl_gui_alv_tree to add a node to the tree.
    In case of root node the parameter lv_relat_key is passed as blank.In order to create further child nodes pass the node key of the parent as the relat key of the child and use the method again.
    Regards,
    Abhi

  • How to handle xml CDATA string element when OSB calling a webservice

    Hi
    Right, I'm new to OSB so bear with me.
    The following is a response from am operation in a webservice.
    As you can see there is a CDATA string in "<m:return>" element. I want to transform the CDATA string to XML.
    I have searched the forum and found a couple of similar queries and tried following the answers and this is what I'm getting.
    Please advise as to where I have gone wrong and how I can correct it.
    <env:Body xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
         <m:ReservationCancelResponse xmlns:m="http://domain/jws">
              <m:return>
                   <![CDATA[<?xml version="1.0" encoding="UTF-8"?><ReservationCancelNegativeAck><MessageId>HGv2OWS6hq</MessageId><ReservationNum>1234</ReservationNum><CsrId></CsrId><ErrorCode>02</ErrorCode><ErrorMessage>Reservation '1234' does not exist.</ErrorMessage></ReservationCancelNegativeAck>]]>
              </m:return>
         </m:ReservationCancelResponse>
    </env:Body>
    In my response pipeline I have an Assign and Replace action.
    My Assign is:
    Expression: fn-bea:inlinedXML($body)
    Variable: reservationCancelReponse
    When I log $reservationCancelReponseI get... so this bit is OK.
    <ReservationCancelNegativeAck>
    <MessageId>HGv2OWS6hq</MessageId>
    <ReservationNum>1234</ReservationNum>
    <CsrId/>
    <ErrorCode>02</ErrorCode>
    <ErrorMessage>Reservation '1234' does not exist.</ErrorMessage>
    </ReservationCancelNegativeAck>
    My Replace
    XPath: executeResponse/executeReturn/text()
    In Variable: body
    Expression: responseTransform.xq (binding with $reservationCancelReponse)
    Replace Node Contents is checked
    When I test the operation using the proxy service I get the following:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Header/>
    <env:Body>
    <m:ReservationCancelResponse xmlns:m="http://com/ventyx/abws/jws">
    <m:return>
    &lt;?xml version="1.0" encoding="UTF-8"?>&lt;ReservationCancelNegativeAck>&lt;MessageId>HGv2OWS6hq&lt;/MessageId>&lt;ReservationNum>1234&lt;/ReservationNum>&lt;CsrId>&lt;/CsrId>&lt;ErrorCode>02&lt;/ErrorCode>&lt;ErrorMessage>Reservation &amp;apos;1234&amp;apos; does not exist.&lt;/ErrorMessage>&lt;/ReservationCancelNegativeAck>
    </m:return>
    </m:ReservationCancelResponse>
    </env:Body>
    </env:Envelope>
    The CDATA string hasn't been transformed.
    Please help. What I have I missed.
    Thanks in advance.
    MI

    OK
    I have made some amendments to the original process and made some progress but still isn't quite right.
    I have created a schema:
    <complexType name="ReservationCancelNegativeAckType">
         <sequence>
                   <element name="MessageId" minOccurs="0">
                        <annotation>
                             <documentation>
                             </documentation>
                        </annotation>
                        <simpleType>
                             <restriction base="string" />
                        </simpleType>
                   </element>
                   <element name="ReservationNum" minOccurs="0">
                        <annotation>
                             <documentation>
                             </documentation>
                        </annotation>
                        <simpleType>
                             <restriction base="string" />
                        </simpleType>
                   </element>
                   <element name="CsrID" minOccurs="0">
                        <annotation>
                             <documentation>
                             </documentation>
                        </annotation>
                        <simpleType>
                             <restriction base="string" />
                        </simpleType>
                   </element>
                   <element name="ErrorCode" minOccurs="0">
                        <annotation>
                             <documentation>
                             </documentation>
                        </annotation>
                        <simpleType>
                             <restriction base="string" />
                        </simpleType>
                   </element>
                   <element name="ErrorDescription" minOccurs="0">
                        <annotation>
                             <documentation>
                             </documentation>
                        </annotation>
                        <simpleType>
                             <restriction base="string" />
                        </simpleType>
                   </element>
         </sequence>
    </complexType>
    <element name="ReservationCancelNegativeAckType"
         type="tns:ReservationCancelNegativeAckType">
    </element>
    I have amended the earlier Assign action to use an XQ to extract the CDATA string into the schema
    My Assign is:
    Expression: responseToSchema.xq
    Variable: reservationCancelReponse
    When I log $reservationCancelReponse variable I get... so this bit is OK.
    <ReservationCancelNegativeAck>
    <MessageId>HGv2OWS6hq</MessageId>
    <ReservationNum>1234</ReservationNum>
    <CsrId/>
    <ErrorCode>02</ErrorCode>
    <ErrorMessage>Reservation '1234' does not exist.</ErrorMessage>
    </ReservationCancelNegativeAck>
    I have also changed my Replace, this time I am using an XQ which will map the schema to the XSD WSDL "ReservationCancelResponse"operation.
    XPath: .
    In Variable: body
    Expression: responseFromSchemaToService.xq (binding with $reservationCancelReponse)
    Replace Node Contents is checked
    XSD WSDL is:
    <xsd:element name="ReservationCancelResponse"
         type="tns:ReservationCancelResponseType">
    </xsd:element>
    <xsd:complexType name="ReservationCancelResponseType">
         <xsd:sequence>
              <xsd:element name="ResponseCode"
                   type="xsd:string">
              </xsd:element>
              <xsd:element name="ResponseDescription"
                   type="xsd:string">
              </xsd:element>
              <xsd:element name="MessageID" type="xsd:string">
              </xsd:element>
              <xsd:element name="ReservationNum" type="xsd:string">
              </xsd:element>
              <xsd:element name="CsrId" type="xsd:string">
              </xsd:element>
              <xsd:element name="ErrorCode" type="xsd:string"
                   minOccurs="0">
              </xsd:element>
              <xsd:element name="ErrorDescription" type="xsd:string" minOccurs="0"></xsd:element>
         </xsd:sequence>
    </xsd:complexType>
    This time the response is better but not right.
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Header xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"/>
    <env:Body xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <app:ReservationCancelResponse xmlns:app="http://www.example.org/AppointmentService/">
    <ResponseCode>0</ResponseCode>
    <ResponseDescription/>
    <MessageID/>
    <ReservationNum/>
    <CsrId/>
    </app:ReservationCancelResponse>
    </env:Body>
    </soapenv:Envelope>
    As you can see the tags are empty. (For info: The "ResponseCode" and "ResponseDescription" are constants)
    Where have I gone wrong?

  • How to see all image file types when saving images without selecting "all files"

    Hallo, and thank you fom reading.
    I am a person who saves a lot of images online in different folders with different names like G - 456 or F - 35.
    I have been using firefox 10.0.2 for a long time because of a bug (I guess) that made it easier to save images.
    When I saved an image it would always show me all the image files in any folder I wanted to save it, and that way making it easier for me to save files with the right names.
    Now with the newer firefox (currently 19.0) whenever I try to save a JPEG I only see the JPEG files in the folder and only way to see the others is by selecting "save as type" all files, but with this I also see all the files that are not images.
    This used to save me a lot of trouble and a bit of time but I dont see anything in the options menu that can help me. Is there a way to recreate this function?
    Thank you for your time.

    I suspect this is a Windows problem. I am surmising the FilePicker uses the Operating System or Desktop facilities. Does Windows 7 offer any other file categories like ''images'' ?
    I do not normally use Windows 7, but may the option depend upon the directory being an indexed one, I ask after finding this thread ''Bring File types tab back'' [http://www.windows7taskforce.com/view/819]
    This question is a duplicate of [/questions/951764]
    Normally I would lock the duplicate question, but in this instance I will leave it open as it is unanswered and someone may give a better reply.

  • How to handle gas cylinders material type

    HI Gurus OF MM,
           I want to create a material type as cylinder (ex.oxygene,acetlene cylinders for production ).
         Its is inwarded through stores and it is consumed by the Production activities(Cost center).After the utilisation( after cosuming
    ) he is returning it to stores as empty cylinders.
        Again frm stores its is returned to Vendor.
       How i could issue this material to the cost center and how i can get it back.
       How i could inward that material Through Purchase Order ???What is the procedure for PO also.
       Any movt type is their and if so suggest me in detailed way?
      Any one have faced this type of issues just share with me also.

    Rajesh
    Follow the below steps.
    01. Create Gas as Raw material
    02. Create Cylinder as RTP material ( LIEH)
    Create Purchase order for Vendor
    Post the GR with reference to Purchase order 101
    Click on Transport equipment icon (extreme right icon in the middle of screen) > enter material, qty, loc, vendor , for this movement type 501 M will trigger
    and Save the document
    You can see the returnable packaging cylinder in stock , and post reversals through movement type 502 M
    Hope this clarifies
    Thanks & Regards,
    Sridhar

  • How to change the internal order type when it has been created?

    There is an internal order, when it being created, the user chose the incorrect order type and save it. but the internal order number is useful. so we just want to change the order type or delete the order to release the number.  so can you give me some solutions to solve it. I can not find the way neither change the order type nor delete it.  thanks very much.

    You are unable to change the internal order type once an internal order has been created, however you can delete the IO if there haven't been any postings made.
    In change mode (tcode KO02), go into the internal order.  Go into the following menu:  Edit > Deletion Flag > Set.    Before you exit the IO, save the master record.
    Depending upon your archiving settings, you should then be able to select the menu path:  Edit > Set Deletion Indicator.
    If the IO isn't deleted, you can "clobber" it by going into the IMG and deleting the IO using the function "Delete Test Data".  This should only be done by a technical person to ensure that a mass-delete doesn't occur.
    Please note that if the IO was an internally assigned number, you might just want to block it and re-use it later.
    Hope this helps.
    Kylie

  • How to handle dynamically created row values when get upadted "please help"

    Hi,
    In my application I have requirement to display the data for specific date when user clicks on viewData. (it shows the entries for that specific days . There may be number of entries). For showing this I have created Value Object and I am setting all the entries for particular selection date to value object and (simply one day entry indicates one instance of my VO if there are 10 entries then I am creating 10 instances of VO and passing this to the actionfor)
    On my JSP page I am displaying that data by using <logic:iterate>
    <logic:iterate id=�myid� name =�nameofform� property =�Listproperty�>
    <tr>
    <td><input type=�text� property=�abc� value=<bean:write name=�myid� property=�propertyinVO�></td>
    // and same for other other values as well
    �.
    </logic:itearte>
    Now I have requirement that if user edit these entries and click on SAVEDATA the updated values should go to the DB.
    As I don�t have property mapped separately I am not able to take updated values of those as they are getting dynamically generated
    Is there is any way by which I can get these updated values.
    I am in badly need of that . Urgent help will highly appreciated.
    Thanks
    Sheena

    Hi, first off, no need to determine what has been checked or not. If the checkbox is checked, on the post, the value will be submitted as part of the request. If the checkbox is not checked, it will not be submitted (it's value will be null). Depending on what you need, I have approached this a number of different ways. One way is to name all checkboxes the same name. If you need to distinguish between two rows in the form, then in the value field for the checkbox, use some type of distinguishing factor, for example,
    <input type=checkbox name=chkName value="1:abc">
    <input type=checkbox name=chkName value="1:def">
    Now, you only have to make one call on the Servlet/JSP receiving the form post, request.getParameterValues("chkName") which will return an array of the non-null Strings that were checked.

  • How to get the root node for a child using connect by prior

    Hi,
    I searched at many places to do this but not able to get the exact o/p sp posting my question here.
    I have a table with parent_id and child_id columns. The levels of this parent_child can be many but my aim is to find the ultimate parent ( dont know the right term)
    like if I have a child_node= xyz and its parent= pqr and its parents=lmn which might be ultimate parent which doesnt have any further parent.
    So if i start with child_code= "xyz" then i should get the parent as "lmn" and not the immediate parent "pqr".
    Please help.
    Thanks,
    Aashish

    To find the Parent on emp table:
    select empno,ename,level
    from emp
    where level=3
    start with empno=7934
    connect by  empno= prior mgrTo find the Child on emp table:
    select empno,ename,level
    from emp
    where level=1
    start with empno=7934
    connect by prior empno=  mgrBut you need to know the level or position to specify the level of parent or child. But there are some other possible options available if we can know the requirement properly.
    Edited by: Vasista on Jan 11, 2011 2:27 AM
    Edited by: Vasista on Jan 11, 2011 2:30 AM

  • How to handle the unique primary key validation when is a multipart key !

    I dont know how to handle the primary key validation when the primary key is a multipart key.
    Besides would like to know how to catch the TooManyObjectsException in order to custom the default exception message.
    thank u.
    regards,
    Orlando Acosta

    Are you using EJB's, Toplink, or BC4J?
    Thanks,
    Rob
    Team JDev

Maybe you are looking for

  • Launching an external file from jsfl script

    I've written a jsfl script which exports the frames of a Flash movie as pngs. I've also written a Photoshop .jsx script which takes the pngs and processes them. I was wondering if there was a command available in jsfl that could launch the .jsx file

  • Photoshop elements organizer crashing

    ("Adobe Elements Organizer 12 Quit Unexpectedly" continuously while trying to tag pictures. MacBook Pro (OS X Ver 10.9.5) & Elements Organizer 12.0 - both purchase Aug 2014. Is there a fix for this?

  • Why does my Ipad change words as I type

    No matter what app/messaging service I am using whenever I type text on the Ipad it changes the words to pure gibberish as I type them. E.g. As I typed this it changed Ipad to 'lad' , word to 'ord' and type to 'ped'. I then have to go in and edit wor

  • System tablespace management in oracle 9i

    Hi, I would like to know whether system tablespace in oracle 9i by default is locally managed or dictionary managed

  • AA3 suddenly not working with RME Fireface 400

    I bought an RME Fireface about a month ago and have been using it with AA3 to edit some 6 to 12 track sessions. Everything was working fine until today when AA3 only displays the splash screen when I start the application -- "Initializing Required Co