What does this section of your schema look like? I'm wondering if this is a case of schema design styles as to why your get...[] method does not show up. Do you know if your xsd is using russian doll, venetian blind, salami slice, or a mix. Thanks, -jacobd
On Dec 9, 2007 6:37 PM, Zapo <[EMAIL PROTECTED]> wrote: > > Thanks Jacob, > > Yes it was more of approach I am struggling with. > > Thanks for bringing up the interesting question on > TestCasesDocument.getTestCase(). > > I tried something similar like this and didn't get an array of testcases, > infact I was hoping to do that as you have rightly suggested. > > On Map, i need these <Testcase> objects to be passed on a calling class > for > further processing and post to an exeternal API as HTTP post. > > Here is my sliced down code, for some reason I am not getting an array of > <TestCase>, I am not able to get an Item[] blah blah...... > > public class CursorHandler { > public static void main(String args[]) { > try { > String filePath = "AddCustomer.xml"; > java.io.File inputXMLFile = new java.io.File > (filePath); > TestcasesDocument testPolicyDoc = > TestcasesDocument.Factory.parse > (inputXMLFile); > > TestcasesDocument.Testcases testCase = > testPolicyDoc.getTestcases(); > > TestcasesDocument.Testcases.Testcase myTestcase = > testCase.getTestcase(); > > //How to get array of <TestCase>? > > //Set Cursor > XmlCursor cursor = testPolicyDoc.newCursor(); > > > //Processing -> Add to Map object > > //Dispose > cursor.dispose (); > > > } catch (Exception e) { > e.printStackTrace(); > } > > } > } > > Thanks Jacob. > > > Jacob Danner-2 wrote: > > > > Hey Zapo, > > I think this question has less to do with XmlBeans and more to do with > > algorithm implementation. > > I think it might be easiest to use a map<TestCase> if you want to go > that > > route, but it I think it might be easier to use one of the Cursor APIs > > with > > XPath and get an XmlObject[] of //TestCase values. > > I'm curious also, why you need a map to keep these values when there > > should > > be a method like TestCasesDocument.getTestCase() which will return an > > array > > of TestCase[] that you can iterate through. But like I mentioned, thats > > more > > of an algorithm implementation issue. > > Best of luck, > > -jacobd > > > > On Dec 9, 2007 5:36 PM, Zapo <[EMAIL PROTECTED]> wrote: > > > >> > >> Hi All, > >> > >> I read through the numerous post and example, before asking for help in > >> the > >> forum. Many where very helpful, however I still need some help on this > >> topic > >> > >> 1. Parse and XML using cursor ---> this is > >> fine > >> 2. Store the element name and value in Map object ---> Help? > >> > >> My XML is below > >> ---------------------------- > >> <?xml version="1.0" encoding="UTF-8"?> > >> <Testcases xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > >> xsi:noNamespaceSchemaLocation="AddCustomer.xsd"> > >> <Testcase> > >> <Security>https</Security> > >> <Server>staging</Server> > >> </Testcase> > >> <Testcase> > >> <Security>https</Security> > >> <Server>baijing</Server> > >> </Testcase> > >> </Testcases> > >> > >> 1. I need to iterate through <TestCase> and store <Security> and > <Server> > >> in > >> a Map. > >> > >> Since there are many nodes <Testcase> , what is the approach I should > >> use? > >> > >> I am thinking of using cursors, but how to navigate and get the element > >> name > >> and value and move on to the next testcase, should I have a Map<Map>? I > >> need > >> to get values for every test case node. > >> > >> Thanks in advance > >> > >> Regards > >> Zapo > >> > >> > >> > >> > >> > >> > >> > >> -- > >> View this message in context: > >> > http://www.nabble.com/Parsing-and-Storing-in-Map-tp14245948p14245948.html > >> Sent from the Xml Beans - User mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/Parsing-and-Storing-in-Map-tp14245948p14246382.html > Sent from the Xml Beans - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >