Help with Deserializer XML to Java Object
Hello,
I need Deserializer a xml to Object using SAX or another technology
My code is the follow:
* java.io.Writer stringWriter = new StringWriter();*
* org.apache.axis.encoding.SerializationContext context0 = new SerializationContext(stringWriter,*
* null);*
* javax.xml.namespace.QName qname = new javax.xml.namespace.QName(*
* "http://xxxxxx", "WSUpdateDocumentResponse");*
* org.apache.axis.encoding.ser.BeanSerializer serializer = new BeanSerializer(WSUpdateDocumentResponse.class,*
* qname);*
* serializer.serialize(qname, null, resp, context0);*
* String deserializaXML = stringWriter.toString();*
The variable deserializaXML contains el XML as String.
+<ns1:WSUpdateDocumentResponse xmlns:ns1="http://xxxxxxx">+
+<documentCode xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">+
+43723+
+</documentCode>+
+<updateMessageList xsi:type="ns1:ArrayOfWSUpdateMessage" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>+
+</ns1:WSUpdateDocumentResponse>+
That's is ok, but the problem is when, I try The reverse engineering.
The code is the following:
* org.apache.axis.encoding.Deserializer bean = WSUpdateDocumentResponse.getDeserializer(deserializaXML,*
* WSUpdateDocumentResponse.class,*
* new javax.xml.namespace.QName("http://xxxxxx, "WSUpdateDocumentResponse"));*
* WSUpdateDocumentResponse resp2 = (WSUpdateDocumentResponse)bean.getValue();*
The object not load correctly, all variables are null.
Any idea?
Thanks.
Regards
P.D.: The bean WSUpdateDocumentResponse was generated with Axis 1.2RC2, i haven't another option by the dependences project
Hi,
Check the methods like getElementById() and getElementByTagName and the corresponding Namespace aware equivalents. Once you have your orders, you can iterate over them and build your target xml.
Personally, I think your teacher sold you a lemon. This is a job that is best done using XSLT and doing this using dom is like using your bicycle to get to saturn when you have a starship available.
cheers,
vidyut
Similar Messages
-
How to parse XML to Java object... please help really stuck
Thank you for reading this email...
If I have a **DTD** like:
<!ELEMENT person (name, age)>
<!ATTLIST person
id ID #REQUIRED
>
<!ELEMENT name ((family, given) | (given, family))>
<!ELEMENT age (#PCDATA)>
<!ELEMENT family (#PCDATA)>
<!ELEMENT given (#PCDATA)>
the **XML** like:
<person id="a1">
<name>
<family> Yoshi </family>
<given> Samurai </given>
</name>
<age> 21 </age>
</person>
**** Could you help me to write a simple parser to parse my DTD and XML to Java object, and how can I use those objects... sorry if the problem is too basic, I am a beginner and very stuck... I am very confuse with SAXParserFactory, SAXParser, ParserAdapter and DOM has its own Factory and Parser, so confuse...
Thank you for your help, YoHi, Yo,
Thank you very much for your help. And I Wish you are there...I'm. And I plan to stay - It's sunny and warm here in Honolulu and the waves are up :)
A bit more question for dear people:
In the notes, it's mainly focus on JAXB,
1. Is that mean JAXB is most popular parser for
parsing XML into Java object? With me, definitely. There are essentially 3 technologies that allow you to parse XML documents:
1) "Callbacks" (e.g. SAX in JAXP): You write a class that overrides 3 methods that will be called i) whenever the parser encounters a start tag, ii) an end tag, or iii) PCDATA. Drawback: You have to figure out where the heck in the document hierarchy you are when such a callback happens, because the same method is called on EACH start tag and similarly for the end tag and the PCDATA. You have to create the objects and put them into your own data structure - it's very tedious, but you have complete control. (Well, more or less.)
2) "Tree" (e.g. DOM in JAXP, or it's better cousin JDOM): You call a parser that in one swoop creates an entire hierarchy that corresponds to the XML document. You don't get called on each tag as with SAX, you just get the root of the resulting tree. Drawback: All the nodes in the tree have the same type! You probably want to know which tags are in the document, don't you? Well, you'll have to traverse the tree and ask each node: What tag do you represent? And what are your attributes? (You get only strings in response even though your attributes often represent numbers.) Unless you want to display the tree - that's a nice application, you can do it as a tree model for JTree -, or otherwise don't care about the individual tags, DOM is not of much help, because you have to keep track where in the tree you are while you traverse it.
3) Enter JAXB (or Castor, or ...): You give it a grammar of the XML documents you want to parse, or "unmarshall" as the fashion dictates to call it. (Actually the name isn't that bad, because "parsing" focuses on the input text while "unmarshalling" focuses on the objects you get, even though I'd reason that it should be marshalling that converts into objects and unmarshalling that converts objects to something else, and not vice versa but that's just my opinion.) The JAXB compiler creates a bunch of source files each with one (or now more) class(es) (and now interfaces) that correspond to the elements/tags of your grammar. (Now "compiler" is a true jevel of a misnomer, try to explain to students that after they run the "compiler", they still need to compile the sources the "compiler" generated with the real Java compiler!). Ok, you've got these sources compiled. Now you call one single method, unmarshall() and as a result you get the root node of the hierarchy that corresponds to the XML document. Sounds like DOM, but it's much better - the objects in the resulting tree don't have all the same type, but their type depends on the tag they represent. E.g if there is the tag <ball-game> then there will be an object of type myPackage.BallGame in your data structure. It gets better, if there is <score> inside <ball-game> and you have an object ballGame (of type BallGame) that you can simply call ballGame.getScore() and you get an object of type myPackage.Score. In other words, the child tags become properties of the parent object. Even better, the attributes become properties, too, so as far as your program is concerned there is no difference whether the property value was originally a tag or an attribute. On top of that, you can tell in your schema that the property has an int value - or another primitive type (that's like that in 1.0, in the early release you'll have to do it in the additional xjs file). So this is a very natural way to explore the data structure of the XML document. Of course there are drawbacks, but they are minor: daunting complexity and, as a consequence, very steep learning curve, documentation that leaves much to reader's phantasy - read trial and error - (the user's guide is too simplicistic and the examples too primitive, e.g. they don't even tell you how to make a schema where a tag has only attributes) and reference manual that has ~200 pages full of technicalities and you have to look with magnifying glas for the really usefull stuff, huge number of generated classes, some of which you may not need at all (and in 1.0 the number has doubled because each class has an accompanying interface), etc., etc. But overall, all that pales compared to the drastically improved efficiency of the programmer's efforts, i.e. your time. The time you'll spend learning the intricacies is well spent, you'll learn it once and then it will shorten your programming time all the time you use it. It's like C and Java, Java is order of magnitude more complex, but you'd probably never be sorry you gave up C.
Of course the above essay leaves out lots and lots of detail, but I think that it touches the most important points.
A word about JAXB 1.0 vs. Early Release (EA) version. If you have time, definitively learn 1.0, they are quite different and the main advantage is that the schema combines all the info that you had to formulate in the DTD and in the xjs file when using the EA version. I suggested EA was because you had a DTD already, but in retrospect, you better start from scratch with 1.0. The concepts in 1.0 are here to stay and once your surmounted the learning curve, you'll be glad that you don't have to switch concepts.
When parser job is done,
what kind of Java Object we will get? (String,
InputStream or ...)See above, typically it's an object whose type is defined as a class (and interface in 1.0) within the sources that JABX generates. Or it can be a String or one of the primitive types - you tell the "compiler" in the schema (xjs file in EA) what you want!
2. If we want to use JAXB, we have to contain a
XJS-file? Something like:In EA, yes. In 1.0 no - it's all in the schema.
I am very new to XML, is there any simpler way to get
around them? It has already take me 4 days to find a
simple parser which give it XML and DTD, then return
to me Java objects ... I mean if that kind of parser
exists....It'll take you probably magnitude longer that that to get really familiar with JAXB, but believe me it's worth it. You'll save countless days if not weeks once you'll start developing serious software with it. How long did it take you to learn Java and it's main APIs? You'll either invest the time learning how to use the software others have written, or you invest it writing it yourself. I'll take the former any time. But it's only my opinion...
Jan -
JAXB and inheritance. Converting xml to java object
I have a schema "FreeStyle.xsd" i used JAXB to generate POJO's . I get around 15 classes. I have a config.xml which is compliant to this schema . Now i want to write a java program which takes the config.xml and converts it into a java object . Please anybody help me with this . Thanks in advance
Freestyle.xsd
<?xml version="1.0" encoding="windows-1252"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="FreeStyleProject" type="hudson.model.FreeStyleProject"/>
<xsd:complexType name="hudson.model.FreeStyleProject">
<xsd:complexContent>
<xsd:extension base="hudson.model.Project">
<xsd:sequence/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="hudson.model.Project">
<xsd:complexContent>
<xsd:extension base="hudson.model.BaseBuildableProject">
<xsd:sequence/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="hudson.model.BaseBuildableProject">
<xsd:complexContent>
<xsd:extension base="hudson.model.AbstractProject">
<xsd:sequence/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="hudson.model.AbstractProject">
<xsd:complexContent>
<xsd:extension base="hudson.model.Job">
<xsd:sequence>
<xsd:element name="concurrentBuild" type="xsd:boolean"/>
<xsd:element name="downstreamProject" type="hudson.model.AbstractProject"
minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="scm" type="hudson.scm.SCM" minOccurs="0"/>
<xsd:element name="upstreamProject" type="hudson.model.AbstractProject"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="hudson.scm.SCM">
<xsd:sequence>
<xsd:element name="browser" type="hudson.scm.RepositoryBrowser"
minOccurs="0"/>
<xsd:element name="type" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="hudson.scm.RepositoryBrowser">
<xsd:sequence/>
</xsd:complexType>
<xsd:complexType name="hudson.model.Job">
<xsd:complexContent>
<xsd:extension base="hudson.model.AbstractItem">
<xsd:sequence>
<xsd:element name="buildable" type="xsd:boolean"/>
<xsd:element name="build" type="hudson.model.Run" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="cascadingChildrenName" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="color" type="hudson.model.BallColor" minOccurs="0"/>
<xsd:element name="firstBuild" type="hudson.model.Run" minOccurs="0"/>
<xsd:element name="healthReport" type="hudson.model.HealthReport"
minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="inQueue" type="xsd:boolean"/>
<xsd:element name="keepDependencies" type="xsd:boolean"/>
<xsd:element name="lastBuild" type="hudson.model.Run" minOccurs="0"/>
<xsd:element name="lastCompletedBuild" type="hudson.model.Run"
minOccurs="0"/>
<xsd:element name="lastFailedBuild" type="hudson.model.Run" minOccurs="0"/>
<xsd:element name="lastStableBuild" type="hudson.model.Run" minOccurs="0"/>
<xsd:element name="lastSuccessfulBuild" type="hudson.model.Run"
minOccurs="0"/>
<xsd:element name="lastUnstableBuild" type="hudson.model.Run"
minOccurs="0"/>
<xsd:element name="lastUnsuccessfulBuild" type="hudson.model.Run"
minOccurs="0"/>
<xsd:element name="nextBuildNumber" type="xsd:int"/>
<xsd:element name="property" type="hudson.model.JobProperty" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="queueItem" type="hudson.model.Queue-Item"
minOccurs="0"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="hudson.model.Queue-Item">
<xsd:complexContent>
<xsd:extension base="hudson.model.Actionable">
<xsd:sequence>
<xsd:element name="blocked" type="xsd:boolean"/>
<xsd:element name="buildable" type="xsd:boolean"/>
<xsd:element name="id" type="xsd:int">
<xsd:annotation>
<xsd:documentation>VM-wide unique ID that tracks the {@link Task} as it
moves through different stages in the queue (each
represented by different subtypes of {@link Item}.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="inQueueSince" type="xsd:long"/>
<xsd:element name="params" type="xsd:string" minOccurs="0"/>
<xsd:element name="stuck" type="xsd:boolean"/>
<xsd:element name="task" type="xsd:anyType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Project to be built.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="why" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="hudson.model.Actionable">
<xsd:sequence>
<xsd:element name="action" type="xsd:anyType" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="hudson.model.JobProperty">
<xsd:sequence/>
</xsd:complexType>
<xsd:complexType name="hudson.model.HealthReport">
<xsd:sequence>
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
<xsd:element name="iconUrl" type="xsd:string" minOccurs="0"/>
<xsd:element name="score" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="hudson.model.Run">
<xsd:complexContent>
<xsd:extension base="hudson.model.Actionable">
<xsd:sequence>
<xsd:element name="artifact" type="hudson.model.Run-Artifact" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="building" type="xsd:boolean"/>
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
<xsd:element name="duration" type="xsd:long"/>
<xsd:element name="fullDisplayName" type="xsd:string" minOccurs="0"/>
<xsd:element name="id" type="xsd:string" minOccurs="0"/>
<xsd:element name="keepLog" type="xsd:boolean"/>
<xsd:element name="number" type="xsd:int"/>
<xsd:element name="result" type="xsd:anyType" minOccurs="0"/>
<xsd:element name="timestamp" type="xsd:long" minOccurs="0"/>
<xsd:element name="url" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="hudson.model.Run-Artifact">
<xsd:sequence>
<xsd:element name="displayPath" type="xsd:string" minOccurs="0"/>
<xsd:element name="fileName" type="xsd:string" minOccurs="0"/>
<xsd:element name="relativePath" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Relative path name from {@link Run#getArtifactsDir()}</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="hudson.model.AbstractItem">
<xsd:complexContent>
<xsd:extension base="hudson.model.Actionable">
<xsd:sequence>
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
<xsd:element name="displayName" type="xsd:string" minOccurs="0"/>
<xsd:element name="name" type="xsd:string" minOccurs="0"/>
<xsd:element name="url" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:simpleType name="hudson.model.BallColor">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="red"/>
<xsd:enumeration value="red_anime"/>
<xsd:enumeration value="yellow"/>
<xsd:enumeration value="yellow_anime"/>
<xsd:enumeration value="green"/>
<xsd:enumeration value="green_anime"/>
<xsd:enumeration value="blue"/>
<xsd:enumeration value="blue_anime"/>
<xsd:enumeration value="grey"/>
<xsd:enumeration value="grey_anime"/>
<xsd:enumeration value="disabled"/>
<xsd:enumeration value="disabled_anime"/>
<xsd:enumeration value="aborted"/>
<xsd:enumeration value="aborted_anime"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Config.xml
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description>Sample job ..</description>
<project-properties class="java.util.concurrent.ConcurrentHashMap">
<entry>
<string>hudson-plugins-disk_usage-DiskUsageProperty</string>
<base-property>
<originalValue class="hudson.plugins.disk_usage.DiskUsageProperty"/>
<propertyOverridden>false</propertyOverridden>
</base-property>
</entry>
<entry>
<string>jdk</string>
<string-property>
<originalValue class="string">(Inherit From Job)</originalValue>
<propertyOverridden>false</propertyOverridden>
</string-property>
</entry>
<entry>
<string>scm</string>
<scm-property>
<originalValue class="hudson.scm.NullSCM"/>
<propertyOverridden>false</propertyOverridden>
</scm-property>
</entry>
</project-properties>
<keepDependencies>false</keepDependencies>
<creationTime>1402648240275</creationTime>
<properties/>
<cascadingChildrenNames class="java.util.concurrent.CopyOnWriteArraySet"/>
<cascading-job-properties class="java.util.concurrent.CopyOnWriteArraySet">
<string>hudson-plugins-batch_task-BatchTaskProperty</string>
<string>hudson-plugins-disk_usage-DiskUsageProperty</string>
<string>hudson-plugins-jira-JiraProjectProperty</string>
<string>org-hudsonci-plugins-snapshotmonitor-WatchedDependenciesProperty</string>
<string>hudson-plugins-promoted_builds-JobPropertyImpl</string>
</cascading-job-properties>
<scm class="hudson.scm.NullSCM"/>
<canRoam>false</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<cleanWorkspaceRequired>false</cleanWorkspaceRequired>
</project>
the file generated by JAXB are
com\model\HudsonModelAbstractItem.java
com\model\HudsonModelAbstractProject.java
com\model\HudsonModelActionable.java
com\model\HudsonModelBallColor.java
com\model\HudsonModelBaseBuildableProject.java
com\model\HudsonModelFreeStyleProject.java
com\model\HudsonModelHealthReport.java
com\model\HudsonModelJob.java
com\model\HudsonModelJobProperty.java
com\model\HudsonModelProject.java
com\model\HudsonModelQueueItem.java
com\model\HudsonModelRun.java
com\model\HudsonModelRunArtifact.java
com\model\HudsonScmRepositoryBrowser.java
com\model\HudsonScmSCM.java
com\model\ObjectFactory.java
Any help will be appreciated .
Thanks in advanceUnmarshal the config.xml to Java object.
Basic JAXB Examples - The Java EE 5 Tutorial -
XML to java object AND Performance
Hi,
I read some article about marshalling a XML file to Java Object (like Castor, XML Beans projects...)
To resume: I would like to marshal a XML doc (from XML to Java object. Later I would like to put these objects on a SGBD...). Unfortenaly I suppose that approach is to expensive on term of performance? Supposing that my xml doc contain 100 data's occurances, XML bean woulkd create 100 objects corresponding. My problem is that I don't want that the all 100 objects live in the same time on memory. For example, my code will read sequential, the xml occurances (like a Sax parser), create 10 datas objects (standby), put these in the data base, and destroy these objects before...iteratively create the next 10 objects...
It is possible ? Can anybody help me?
ThankOn the article: Java Architecture for XML Binding (JAXB)
(http://java.sun.com/developer/technicalArticles/WebServices/jaxb/)
I found maybe a response?
"...in other words, you can do a SAX parse of a document and then pass the events to JAXB for unmarshalling. "
But somebody could help me to write the code to do that? -
Convert MBox into XML into Java Objects
Hello all,
this is a general question, i dont know weather there is such libs or not.
However, please tell me what you know.
i want to program a java application for searching purpose in Mbox.
i thought its possible and easier to try to convert the emails from the MBox into XML files, and from these create java objects when i need or even convert the XML into html for viewing.
Any suggestions are welcome.
Also antoher solutions are greate.
thanks in advance!
Sako.I don't know what this MBox you speak of is - I assume it's not the thing I use to hook upa guitar to GarageBand. Maybe you mean it as a generic term for mailbox? The easiest solution (to my mind) would be to use a Java API provided by whatever MBox is. If there is no such thing, then if you get XML-formatted version of the messages I suppose writing code to parse the XML into Java Objects would be a good option if you wanted to do further manipulation of them, but if all you want to do is display them as HTML in a browser then just use XSLT to transform them.
Good Luck
Lee -
Hi
What is an easy way to generate an java object from xml
Thanks very muchUsing DOM or JDOM (http://xml.apache.org/xerces-j/, http://www.jdom.org/)
It is equaly as easy to create a dom or a jdom obj, but most java programmers find JDOM more intuative to work with.
Hope this helps! -
Problem with XMLEncoder for complex java object i
Hi All.
My problem with XMLEncoder is it doesnt transfrom java objects without default no arguement constructor. I was able to resolve this in my main java object class, by setting a new persistence delegate, but for other classes that are contained in the main class, they are not being encoded.
Thanks in advance for your answersBetter to put this in java forum :-)
Just check, if this helps.
http://forum.java.sun.com/thread.jspa?threadID=379614&messageID=1623434 -
Need help with Berkeley XML DB Performance
We need help with maximizing performance of our use of Berkeley XML DB. I am filling most of the 29 part question as listed by Oracle's BDB team.
Berkeley DB XML Performance Questionnaire
1. Describe the Performance area that you are measuring? What is the
current performance? What are your performance goals you hope to
achieve?
We are measuring the performance while loading a document during
web application startup. It is currently taking 10-12 seconds when
only one user is on the system. We are trying to do some testing to
get the load time when several users are on the system.
We would like the load time to be 5 seconds or less.
2. What Berkeley DB XML Version? Any optional configuration flags
specified? Are you running with any special patches? Please specify?
dbxml 2.4.13. No special patches.
3. What Berkeley DB Version? Any optional configuration flags
specified? Are you running with any special patches? Please Specify.
bdb 4.6.21. No special patches.
4. Processor name, speed and chipset?
Intel Xeon CPU 5150 2.66GHz
5. Operating System and Version?
Red Hat Enterprise Linux Relase 4 Update 6
6. Disk Drive Type and speed?
Don't have that information
7. File System Type? (such as EXT2, NTFS, Reiser)
EXT3
8. Physical Memory Available?
4GB
9. Are you using Replication (HA) with Berkeley DB XML? If so, please
describe the network you are using, and the number of Replica’s.
No
10. Are you using a Remote Filesystem (NFS) ? If so, for which
Berkeley DB XML/DB files?
No
11. What type of mutexes do you have configured? Did you specify
–with-mutex=? Specify what you find inn your config.log, search
for db_cv_mutex?
None. Did not specify -with-mutex during bdb compilation
12. Which API are you using (C++, Java, Perl, PHP, Python, other) ?
Which compiler and version?
Java 1.5
13. If you are using an Application Server or Web Server, please
provide the name and version?
Oracle Appication Server 10.1.3.4.0
14. Please provide your exact Environment Configuration Flags (include
anything specified in you DB_CONFIG file)
Default.
15. Please provide your Container Configuration Flags?
final EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setAllowCreate(true); // If the environment does not
// exist, create it.
envConf.setInitializeCache(true); // Turn on the shared memory
// region.
envConf.setInitializeLocking(true); // Turn on the locking subsystem.
envConf.setInitializeLogging(true); // Turn on the logging subsystem.
envConf.setTransactional(true); // Turn on the transactional
// subsystem.
envConf.setLockDetectMode(LockDetectMode.MINWRITE);
envConf.setThreaded(true);
envConf.setErrorStream(System.err);
envConf.setCacheSize(1024*1024*64);
envConf.setMaxLockers(2000);
envConf.setMaxLocks(2000);
envConf.setMaxLockObjects(2000);
envConf.setTxnMaxActive(200);
envConf.setTxnWriteNoSync(true);
envConf.setMaxMutexes(40000);
16. How many XML Containers do you have? For each one please specify:
One.
1. The Container Configuration Flags
XmlContainerConfig xmlContainerConfig = new XmlContainerConfig();
xmlContainerConfig.setTransactional(true);
xmlContainerConfig.setIndexNodes(true);
xmlContainerConfig.setReadUncommitted(true);
2. How many documents?
Everytime the user logs in, the current xml document is loaded from
a oracle database table and put it in the Berkeley XML DB.
The documents get deleted from XML DB when the Oracle application
server container is stopped.
The number of documents should start with zero initially and it
will grow with every login.
3. What type (node or wholedoc)?
Node
4. Please indicate the minimum, maximum and average size of
documents?
The minimum is about 2MB and the maximum could 20MB. The average
mostly about 5MB.
5. Are you using document data? If so please describe how?
We are using document data only to save changes made
to the application data in a web application. The final save goes
to the relational database. Berkeley XML DB is just used to store
temporary data since going to the relational database for each change
will cause severe performance issues.
17. Please describe the shape of one of your typical documents? Please
do this by sending us a skeleton XML document.
Due to the sensitive nature of the data, I can provide XML schema instead.
18. What is the rate of document insertion/update required or
expected? Are you doing partial node updates (via XmlModify) or
replacing the document?
The document is inserted during user login. Any change made to the application
data grid or other data components gets saved in Berkeley DB. We also have
an automatic save every two minutes. The final save from the application
gets saved in a relational database.
19. What is the query rate required/expected?
Users will not be entering data rapidly. There will be lot of think time
before the users enter/modify data in the web application. This is a pilot
project but when we go live with this application, we will expect 25 users
at the same time.
20. XQuery -- supply some sample queries
1. Please provide the Query Plan
2. Are you using DBXML_INDEX_NODES?
Yes.
3. Display the indices you have defined for the specific query.
XmlIndexSpecification spec = container.getIndexSpecification();
// ids
spec.addIndex("", "id", XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
spec.addIndex("", "idref", XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// index to cover AttributeValue/Description
spec.addIndex("", "Description", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_SUBSTRING, XmlValue.STRING);
// cover AttributeValue/@value
spec.addIndex("", "value", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// item attribute values
spec.addIndex("", "type", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// default index
spec.addDefaultIndex(XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
spec.addDefaultIndex(XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// save the spec to the container
XmlUpdateContext uc = xmlManager.createUpdateContext();
container.setIndexSpecification(spec, uc);
4. If this is a large query, please consider sending a smaller
query (and query plan) that demonstrates the problem.
21. Are you running with Transactions? If so please provide any
transactions flags you specify with any API calls.
Yes. READ_UNCOMMITED in some and READ_COMMITTED in other transactions.
22. If your application is transactional, are your log files stored on
the same disk as your containers/databases?
Yes.
23. Do you use AUTO_COMMIT?
No.
24. Please list any non-transactional operations performed?
No.
25. How many threads of control are running? How many threads in read
only mode? How many threads are updating?
We use Berkeley XML DB within the context of a struts web application.
Each user logged into the web application will be running a bdb transactoin
within the context of a struts action thread.
26. Please include a paragraph describing the performance measurements
you have made. Please specifically list any Berkeley DB operations
where the performance is currently insufficient.
We are clocking 10-12 seconds of loading a document from dbd when
five users are on the system.
getContainer().getDocument(documentName);
27. What performance level do you hope to achieve?
We would like to get less than 5 seconds when 25 users are on the system.
28. Please send us the output of the following db_stat utility commands
after your application has been running under "normal" load for some
period of time:
% db_stat -h database environment -c
% db_stat -h database environment -l
% db_stat -h database environment -m
% db_stat -h database environment -r
% db_stat -h database environment -t
(These commands require the db_stat utility access a shared database
environment. If your application has a private environment, please
remove the DB_PRIVATE flag used when the environment is created, so
you can obtain these measurements. If removing the DB_PRIVATE flag
is not possible, let us know and we can discuss alternatives with
you.)
If your application has periods of "good" and "bad" performance,
please run the above list of commands several times, during both
good and bad periods, and additionally specify the -Z flags (so
the output of each command isn't cumulative).
When possible, please run basic system performance reporting tools
during the time you are measuring the application's performance.
For example, on UNIX systems, the vmstat and iostat utilities are
good choices.
Will give this information soon.
29. Are there any other significant applications running on this
system? Are you using Berkeley DB outside of Berkeley DB XML?
Please describe the application?
No to the first two questions.
The web application is an online review of test questions. The users
login and then review the items one by one. The relational database
holds the data in xml. During application load, the application
retrieves the xml and then saves it to bdb. While the user
is making changes to the data in the application, it writes those
changes to bdb. Finally when the user hits the SAVE button, the data
gets saved to the relational database. We also have an automatic save
every two minues, which saves bdb xml data and saves it to relational
database.
Thanks,
Madhav
[email protected]Could it be that you simply do not have set up indexes to support your query? If so, you could do some basic testing using the dbxml shell:
milu@colinux:~/xpg > dbxml -h ~/dbenv
Joined existing environment
dbxml> setverbose 7 2
dbxml> open tv.dbxml
dbxml> listIndexes
dbxml> query { collection()[//@date-tip]/*[@chID = ('ard','zdf')] (: example :) }
dbxml> queryplan { collection()[//@date-tip]/*[@chID = ('ard','zdf')] (: example :) }Verbosity will make the engine display some (rather cryptic) information on index usage. I can't remember where the output is explained; my feeling is that "V(...)" means the index is being used (which is good), but that observation may not be accurate. Note that some details in the setVerbose command could differ, as I'm using 2.4.16 while you're using 2.4.13.
Also, take a look at the query plan. You can post it here and some people will be able to diagnose it.
Michael Ludwig -
Converting XML to Java Objects...possible?
Hi, Am a newbie to JAXB. As far as I read, JAXB has facility to convert "XSD" (not XML) to Java "classes" (not objects). This can be done using xjc compiler. Can XML files (i.e. ones with data) be converted to Java objects (retaining the data from XML files)? If yes, please throw some light on how it can be done. If no, then is there some java technology to do such a thing?
Thanks.http://xmlbeans.apache.org/
-
Hi,
In our existing project we are using JDK / JRE 1.3.
We need to add a module wherein we need to pick up an XML object (from MQ) and convert it into a Java Object.
I was initially planning to use JAXP, but it appears that it needs Java 1.4 (or above). Is it ? So what is the other option available ?
Is JDOM a worthwhile alternative ? Would it be supported on Java 1.3?or any other suitable alternative.
Kindly advice as need to finalize on this as soon as possible.
Thanks,
MDYou may have to roll your own - last time I was working with 1.3 there wasn't anything out there for it, but that was a couple of years ago.
If the schema is fixed, you can pull parse, otherwise use SAX, a LinkedList as a stack and a map of element name -> content handler to populate the objects. If it's not a performance bottleneck*, you can get a long way just using reflection rather than having to write specific handling code for each attribute.
Pete
*most of what I do is aerospace simulation, so our messages might say 'run 100,000 simulations that cover all of the flight envelope', which then spawns a 15,000 cpu hour process, so it's at the opposite extreme to something like a SMS service hub, where there's almost no processing and it's all parsing, so optimising the XML for performance for us is irrelevent. -
I need to map java objects with XMl Node or XML Elements.
My java objets get some attributes, for instance name,color ...
and i need an output like:
<OBJECT_OF_TYPE_XXX>
<NAME>scott</NAME>
<COLOR>red</COLOR>
</OBJECT_OF_TYPE_XXX>
Any idea?
Thanks
MauriceYou can try JAXB which includes a compiler that generates classes based on the XML Schema for your xml structure. It also features the possibility to convert between xml and the generated objects.
Take a look at chapter 9 and 10 at http://java.sun.com/webservices/docs/1.1/tutorial/doc/index.html -
Begging for help with podcast xml file
Hey All,
I have a podcast on iTunes. I am hosting the xml file and podcast mp3s on a friends server so Im not using any service. Everything is working and Ive sucessfully added 4 podcasts so far, and it shows up correctly in iTunes on my PC.
However my podcasts do not showup correct in the iTunes store website, or on idevices. Meaning, I number my shows 001_"NAME" 002_"NAME" etc. Yet in the iTunes store they show up out of order. So my last show is not at the top its at the bottom, and they are all mixed up (like 002, 001, 004, 003 instead of 4,3,2,1) Also the publish date is the same on two of them (and not what i have in the xml file) and doesnt show up at all on the other two. I assume this is a problem with the xml file, yet I dont see any problems with it. But it seems odd that it all works correctly in the actual iTunes program. Ive tried different code, but im very much a noob at it, and everything i find online is from 5 - 10 years ago or wants you to host your podcasts with their site and I dont need that.
Here is the link to the show on the iTunes website so you can see what i mean: http://itunes.apple.com/us/podcast/your-reality-recap/id501295325
If anybody can, would you mind checking out the code in my xml file and letting me know if you see anything thats causing this issue?
I zipped the xml file and put it here: http://www.ericcurto.com/podcast/YRR.zip
I would be truly greatfuly for any help with this. Ive been trying to fix this for days and dont know what else to do.
Thanks!
EricYour feed is at http://www.ericcurto.com/podcast/YourRealityRecap.xml (please always post the feed URL, not its contents or a copy).
I don't see the issues you mention. The order in the Store and when subscribing is what I would expect:
The order in the Store depends on clicking the header to the column: the default is the first one. Some of the dates are a day out - this is quite commmon and is probably a time zone issue (it may be different where you are - I'm in the UK). I don't know why you are seeing a garbled order unless you've clicked on one of the other columns in the Store. -
<p>Need help with the following error.....what does it mean....</p><p>28943 3086739136 XML-240304 3/7/07 7:13:23 PM |SessionNew_Job1<br /><font color="#ff0000">28943 3086739136 XML-240304 3/7/07 7:13:23 PM XML parser failed: Error <An exception occurred! Type:UnexpectedEOFException, Message:The end of input was not expected> at</font><br />28943 3086739136 XML-240304 3/7/07 7:13:23 PM line <7>, char <8> in <<?xml version="1.0" encoding="WINDOWS-1252" ?><br />28943 3086739136 XML-240304 3/7/07 7:13:23 PM <DSConfigurations><br />28943 3086739136 XML-240304 3/7/07 7:13:23 PM <DSConfiguration default="true" name="Configuration1"><br />28943 3086739136 XML-240304 3/7/07 7:13:23 PM <case_sensitive>no</case_sensitive><br />28943 3086739136 XML-240304 3/7/07 7:13:23 PM <database_type>Oracle</database_type><br />28943 3086739136 XML-240304 3/7/07 7:13:23 PM <db_alias_name1>ODS_OWNER</db_alias_name1><br />28943 3086739136 XML-240304 3/7/07 7:13:23 PM <db_ali>, file <>.<br />28943 3086739136 XML-240307 3/7/07 7:13:23 PM |SessionNew_Job1<br />28943 3086739136 XML-240307 3/7/07 7:13:23 PM XML parser failed: See previously displayed error message.</p><p>Any help would be greatly appreciated. It's something to do with my datasource and possibly the codepage but I'm really not sure.</p><p>-m<br /></p>
please export your datastore as ATL and send it to support. Somehow the internal language around configurations got corrupted - never seen before.
-
Little help with complex XML data as data provider for chart and adg
Hi all,
I've been trying to think through a problem and Im hoping for
a little help. Here's the scenario:
I have complex nested XML data that is wrapped by subsequent
groupings for efficiency, but I need to determine if each inner
item belongs in the data collection for view in a data grid and
charts.
I've posted an example at the bottom.
So the goal here is to first be able to select a single
inspector and then chart out their reports. I can get the data to
filter from the XMLListCollection using a filter on the first layer
(ie the name of the inspector) but then can't get a filter to go
deeper into the structure in order to determine if the individual
item should be contained inside the collection. In other words, I
want to filter by inspector, then time and then tag name in order
to be able to use this data as the basis for individual series
inside my advanced data grid and column chart.
I've made it work with creating a new collection and then
looping through each time there is a change to the original
collection and updating the new collection, but that just feels so
bloated and inefficient. The user is going to have some buttons to
allow them to change their view. I'm wondering if there is a
cleaner way to approach this? I even tried chaining filter
functions together, but that didn't work cause the collection is
reset whenever the .refresh() is called.
If anyone has experience in efficiently dealing with complex
XML for charting purposes and tabular display purposes, I would
greatly appreciate your assistance. I know I can get this to work
with a bunch of overhead, but I'm seeking something elegant.
Thank you.Hi,
Please use the code similar to below:
SELECT * FROM DO_NOT_LOAD INTO TABLE IT_DO_NOT_LOAD.
SORT IT_DO_NOT_LOAD by WBS_Key.
IF SOURCE_PACKAGE IS NOT INITIAL.
IT_SOURCE_PACKAGE[] = SOURCE_PACKAGE[].
LOOP AT IT_SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE.
V_SYTABIX = SY-TABIX.
READ TABLE IT_DO_NOT_LOAD into WA_DO_NOT_LOAD
WITH KEY WBS_Key = WA_SOURCE_PACKAGE-WBS_Key
BINARY SEARCH.
IF SY-SUBRC = 0.
IF ( WA_DO_NOT_LOAD-WBS_EXT = 'A' or WA_DO_NOT_LOAD-WBS_EXT = 'B' )
DELETE IT_SOURCE_PACKAGE INDEX V_SYTABIX.
ENDIF.
ENDIF.
ENDLOOP.
SOURCE_PACKAGE[] = IT_SOURCE_PACKAGE[].
ENDIF.
-Vikram -
Need help with simple XML validation
I am new to Spry and need some help creating a simple
validation. There is a form field which must not contain a value
already in the database. I have a script which accepts a parameter
and returns a boolean result. Here is the XML:
<samples>
<sample>
<ISFOUND>0</ISFOUND>
</sample>
</samples>
1. How do I call this script when the form field changes and
pass the form value as the parameter?
2. How do I check the returned value in the XML and throw an
error if true?
I appreciate any help with this. Please let me know if there
is a better way to achieve the same result.
Thanks,
RichI enabled the call to the XML response. However, I am having
trouble identifying when the call is complete so I can parse the
result. How do I run my check after the data load and display the
proper message?
Maybe you are looking for
-
[Bumblebee]Failed to initialize the NVIDIA GPU at PCI:1:0:0.
Hi! I've instaled Arch about a month ago and now wanted to check my nvidia card using Bumblebee, but have some errors… [wicu@arch:~]$ optirun -vv minecraft [ 4859.259278] [DEBUG]Reading file: /etc/bumblebee/bumblebee.conf [ 4859.404191] [DEBUG]optiru
-
Problems with iMovie 8.0.6 - view, edit, publish, drop clips
Ever since the update to latest version of iMovie which I used frequently up to now, I have not been all of a sudden be able to do the following: - view clips in that are in project timeline in the view window (tried full screen as well) - intermitte
-
What is Oracle Equivalent of SQL Profiler
Hi All, Iam new to oracle world. I have a problem, I have a website which was build by someone and it uses Oracle 9i/10g as its back end and I dont have the code for that website. I have to develop an interface which simulates some of the button clic
-
Hi all, I cleared IZO-147 exam on 27th August 2009 but till not I could not receive the certificate. Could you suggest whom I should contact to get the status of it. Regards Salil Verma
-
Can't find the error on this small code :S
Hi , i've just compiled this code and i can't find what is wrong! :( The compiler is ok, but the output print its not what i was expect. If u insert 121 (capicua) the answer is: This number its not a capicua :S what is wrong? thanks!! Note: Don't cre