Re: Dynamic generation of XML object hierarchy using schema
look at the XmlCursor api. You can use it to create an xml document. On 5/6/2014 8:19 AM, jgagnon wrote: I am working on a project where we are trying to dynamically generate XML instances, using the information gleaned from a defining XML schema. The instances will represent test cases for a given message type. I've experimented with the XMLBeans schema type system to get useful information about the types defined in the schema, such as the structure (sequences, choices, etc.), min/max occurs and various restrictions (enumerations, patterns, etc.). This information will be used to determine what types of test cases will be generated for a given message element. I'm at the point where I'd like to use the XMLBeans Java API to programmatically generate XML document instances. Of course, I would need to compile the schema to generate a Java library of classes that represent the Java form of the message types (and supporting types). What I don't know is how to dynamically use the generated API to create an object hierarchy representing a test case. The hierarchy would represent a message instance (which may or may not be valid or complete based on the test case), with element content populated with test data. I cannot seem to find the information from the schema type system that would allow me to bridge between the schema information and the specific generated API classes that would need to be used to generate the object hierarchy. I assume if this information is available, I would then need to use reflection to create the objects and set their values and attributes. Does anyone have suggestions? -- View this message in context: http://xmlbeans.996285.n3.nabble.com/Dynamic-generation-of-XML-object-hierarchy-using-schema-tp7501.html Sent from the XMLBeans User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org
Re: Getting XMLBeans out of Attic
Yes I am still interested. Thanks Jerry On 10/23/2013 4:37 AM, Nick Burch wrote: Hi All Is there still interest in rebooting the XMLBeans project? If so, I think we have enough existing Apache PMC members to mentor the rebooted project. I'm happy to start the ball rolling on the proposal if there's still the interest? Nick PS The steps would be that I'd setup the proposal on the incubator wiki, people interested in helping with the rebooted project would sign up, then we'd have a vote and then begin working on the code and the community within the Apache Incubator - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org
Re: How to insert after using XmlCursor?
You need to go to the END of the parent cursor or to the nextToken of the END of the lastChild, then do the insert. XmlObject test1 = XmlObject.Factory.parse(parentchildfirst/child/parent); XmlCursor testcurs = test1.newCursor(); if (testcurs.isStartdoc()){ testcurs.toNextToken(); } boolean res = testcurs.toLastChild(); XmlCursor.TokenType tt = testcurs.toEndToken(); //this goes to END tag of the last child element tt = testcurs.toNextToken(); //we are now at the END tag of parent testcurs.insertElementWithText(child,second); or this XmlObject test1 = XmlObject.Factory.parse(parentchildfirst/child/parent); XmlCursor testcurs = test1.newCursor(); if (testcurs.isStartdoc()){ testcurs.toNextToken(); //now at parent element } XmlCursor.TokenType tt = testcurs.toEndToken(); //END tag of parent element testcurs.insertElementWithText(child,second); On 10/23/2013 11:51 AM, Michael Bishop wrote: Hello all, I'm a bit stuck in trying to achieve this with XmlObjects and XmlCursor. Imagine the following scenario: parent childSome text/child /parent I want to insert a new element AFTER the child element. parent childSome text/child !-- New element here! -- /parent I don't necessarily know anything about the child element. It might have child text like the example above. It might not. It might have child elements, it might not. It might have siblings, it might not. Here's where I'm stuck: // XmlObject representing parent. XmlObject parent = ...; XmlCursor parentCursor = parent.newCursor(); // Now I'm at the START token for the child element. parentCursor.toChild(child); From here, how do I reliably get the cursor past /child or child/? Basically I'm at the start of child and want to be right past the end of that element. Thanks, Michael - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org
Re: Getting XMLBeans out of Attic
Hi Daniel, Please count me in. Thanks Jerry On 7/23/2013 8:29 AM, Daniel Lübke wrote: Hi list, I am a long-time user of XMLBeans, most of the time as part of the BPELUnit project. There is no replacement to XMLBeans because in contrast to JAXB if preserves namespace declarations so you e.g. read and write XML document that contain XPath expressions (e.g. BPEL, BPMN2, ...). Although I know XMLBeans only from the user perspective, I would contribute to it, which includes learning more of its internals, apply the outstanding patches, test them and so on. As far as I understand the Apache rules a project needs to have a working PMC. This means at least 3 people (for substitution 4 or 5 would be better) which vote on releases. I also would join a new PMC if 3 other would be willing to join me and at least build regular maintainance releases to keep this project alive and reboot its PMC. I know that many other projects use XMLBeans, e.g. Apache Camel, Apache CXX Apache ODE, ... and many non-Apache projects, too. So I hope that we can find enough interested people to keep this project alive. If you are one of them, please reply to this list. If we are enough people, I would try to talk to the Apache Foundation. Regards, Daniel - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org
Re: [VOTE] XMLBeans v2.6.0-RC3 to become official release
[X] +1 - I am in favor of this release, and can help On 08/08/2012 05:33 PM, Cezar Andrei wrote: Because I didn't receive any votes, I'm extending the vote period until end of next Monday, August 13. Cezar On Wed, 2012-08-08 at 17:07 -0700, Cezar Andrei wrote: The files are now up at http://xmlbeans.apache.org/dist/ please do send your votes. Thanks, Cezar On Thu, 2012-08-02 at 11:04 -0700, Cezar Andrei wrote: The files are not here: http://xmlbeans.apache.org/dist/ yet, they should get sync-ed soon. I'll send an update when they're up. In the meantime, you can find the same files here: http://apache.org/~cezar/xmlbeans-2.6.0/ Cezar On Thu, 2012-08-02 at 10:46 -0700, Cezar Andrei wrote: Please cast your vote for the XMLBeans v2.6.0-RC3, as published at http://xmlbeans.apache.org/dist/ to become XMLBeans v2.6.0 official release. The vote will be open until end of day Monday, August 6. Anyone is allowed to show support or lack of it, but only XMLBeans committer votes are binding. [ ] +1 - I am in favor of this release, and can help [ ] +0 - I am in favor of this release, but cannot help [ ] -0 - I am not in favor of this release [ ] -1 - I am against this proposal (must include a reason) My vote is: [X] +1 - I am in favor of this release, and can help Cezar - To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: dev-h...@xmlbeans.apache.org - To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: dev-h...@xmlbeans.apache.org - To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: dev-h...@xmlbeans.apache.org - To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: dev-h...@xmlbeans.apache.org - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org
Re: CDATA saving problem
You also need to set setUseCDataBookmarks option to true as well. If your original xml contains CDATA, that option will ensure it is retained and will be present when you save the XML. As for setSaveCDataLengthThreshold and setSaveCDataEntityCountThreshold, both conditions must be satisfied for CDATA tag to be added. Jerry On 07/27/2012 02:05 AM, Jurica Krizanic wrote: Hello, I am uxing XMLBeans 2.5.0 and having an issue with saving XML to the file.. When the XML is saved to the file, CDATA section marks are removed, but content inside the CDATA remains in the file. I would like CDATA marks also remain in the file. I was trying to set XMLOptions with setSaveCDataLengthThreshold() and setSaveCDataEntityCountThreshold() methods, browsing through already asked questions on the mailing list, but I can't get it work correctly. Can someone provide any help? Thank you in advance! Best regards, Jurica Krizanic
Re: xmlsbeans 2.5 does not check sequence order ?
read about xmlbeans validation here http://xmlbeans.apache.org/docs/2.0.0/guide/conValidationWithXmlBeans.html I test using this code String testschema = "?xml version=\"1.0\" encoding=\"UTF-8\"?\n" + "xsd:schema\n" + " targetNamespace=\"http://www.colis-logistique.com/i-net/wsapi\"\n" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" + " elementFormDefault=\"qualified\"\n" + " xsd:element name=\"DeclareParcelsAndCustomsResponse\"\n" + " xsd:complexType\n" + " xsd:sequence\n" + " xsd:element name=\"Version\" type=\"xsd:string\" minOccurs=\"1\" maxOccurs=\"1\"/\n" + " xsd:element name=\"Timestamp\" type=\"xsd:string\" minOccurs=\"1\" maxOccurs=\"1\"/\n" + " xsd:element name=\"AckCode\" type=\"xsd:string\" minOccurs=\"1\" maxOccurs=\"1\"/\n" + " xsd:element name=\"HMacBase64Code\" type=\"xsd:string\" minOccurs=\"1\" maxOccurs=\"1\"/\n" + " /xsd:sequence\n" + " /xsd:complexType\n" + " /xsd:element\n" + "/xsd:schema "; String testxml = "wsap:DeclareParcelsAndCustomsResponse xmlns:wsap=\"http://www.colis-logistique.com/i-net/wsapi\"\n" + " wsap:Timestamp2011-05-02T16:57:33.136Z/wsap:Timestamp\n" + " wsap:AckCodeSUCCESS/wsap:AckCode\n" + " wsap:HMacBase64CodeZjY5MDdlYWI4MGQxMGQ3MjM5OTExZmVmNjQ1NjY3ZDY3NTVkYmQ5MGQ4YTViM2JlOTE1OWU3ODFjZGJlYjIxNg==/wsap:HMacBase64Code\n" + "/wsap:DeclareParcelsAndCustomsResponse "; SchemaTypeSystem sts1 = XmlBeans.compileXsd(new XmlObject[]{XmlObject.Factory.parse(testschema)}, XmlBeans.getBuiltinTypeSystem(),null); XmlObject x1 = sts1.parse(testxml,sts1.findDocumentType(new QName("http://www.colis-logistique.com/i-net/wsapi","DeclareParcelsAndCustomsResponse")),null); XmlOptions xo = new XmlOptions(); ArrayListXmlValidationError errorlist = new ArrayListXmlValidationError(); xo.setErrorListener(errorlist); if (!x1.validate(xo)) { for (XmlValidationError e:errorlist) { System.out.println(e.getMessage()); } } and get this output Expected element 'Version@http://www.colis-logistique.com/i-net/wsapi' instead of 'Timestamp@http://www.colis-logistique.com/i-net/wsapi' here in element DeclareParcelsAndCustomsResponse@http://www.colis-logistique.com/i-net/wsapi Expected element 'Version@http://www.colis-logistique.com/i-net/wsapi' instead of 'AckCode@http://www.colis-logistique.com/i-net/wsapi' here in element DeclareParcelsAndCustomsResponse@http://www.colis-logistique.com/i-net/wsapi Expected element 'Version@http://www.colis-logistique.com/i-net/wsapi' instead of 'HMacBase64Code@http://www.colis-logistique.com/i-net/wsapi' here in element DeclareParcelsAndCustomsResponse@http://www.colis-logistique.com/i-net/wsapi Expected element 'Version@http://www.colis-logistique.com/i-net/wsapi' before the end of the content in element DeclareParcelsAndCustomsResponse@http://www.colis-logistique.com/i-net/wsapi using your code, you can do ans.validate(xmloption) Jerry On 11/11/2011 11:46 AM, philippe.legay.exte...@telintrans.fr wrote: Hello, I parse a xml string, but wmlsbeans does not see that the version element is not present ! I am expecting an exception like I have one when there is a syntax error in the xml string. So my problems with xmlsbeans 2.5 are : - xmlsbeans does not throw an exception when an element of a sequence is not here ? - xmlsbeans does not throw an exception when an element of a sequence is not at the right position ? - xmlsbeans does not throw an exception when an element of a sequence is not declared in the XSD ? My java code is : DeclareParcelsAndCustomsResponseDocument ansDoc = DeclareParcelsAndCustomsResponseDocument.Factory.parse(answer); DeclareParcelsAndCustomsResponseDocument.DeclareParcelsAndCustomsResponse ans = ansDoc.getDeclareParcelsAndCustomsResponse() ; XSD Source === ?xml version="1.0" encoding="UTF-8"? xsd:schema targetNamespace="http://www.colis-logistique.com/i-net/wsapi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xsd:element name="DeclareParcelsAndCustomsResponse" xsd:complexType xsd:sequence xsd:element name="Version" type="xsd:string" minOccurs="1"
Re: Problem with xml files if length of file is exact 8193 bytes
This problem is fixed in revision 959082 http://svn.apache.org/viewvc?view=revisionrevision=959082 I tested using the schema and xml provided in JIRA XMLBEANS-428 using this code SchemaTypeSystem sts0 = XmlBeans.compileXsd(new XmlObject[]{XmlObject.Factory.parse(new File("test.xsd"))}, XmlBeans.getBuiltinTypeSystem(),null); XmlObject x0 = sts0.parse(new File("testf.xml"),sts0.findDocumentType(new QName("xmlbean","root")),null); I see the error using xbean 2.5 jar, but don't see the error anymore if I include fix from revision 959082. Jerry On 4/29/2011 6:29 AM, Jacob Danner wrote: Could you file a jira issue and attach one of the xml instances you are seeing this with? Thanks, -jacobd On Apr 29, 2011 2:32 AM, "Hugo de Oude" hdo...@allshare.nl wrote: Hello, We get the error 'Unexcpected element: CDATA' if the length of an xml file is exactly 8193. This can be reproduced using the xmlbeans 2.4.0 and 2.5.0 version. This can be reproduced by any xml file as long as the length of the file is exaclty 8193. Can this be fixed please? Thx. Hugo de Oude 06-21588438 - To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org