unmarshal a xml string with jaxb - jaxb

I have a string to unmarshal
<?xml version="1.0" encoding="UTF-8"?><Nbr>65</Nbr>
i want to get the value 65.
please help me , i am beginner in JAXB.

You should look at unmarshalling examples available over internet. One such example: http://www.javatpoint.com/jaxb-unmarshalling-example

Related

XML conditional duplicate filtering

I want to filter an XML document.
Lets use a simple example:
Based on the code below, IF appears MORE than once in the document, WITHIN the tags, then it must point each occurrence out.
<car>
<engine>
</engine>
//THIS SHOULD THEN BE POINTED OUT//
<engine>
</engine>
//THIS SHOULD THEN BE POINTED OUT//
</car>
So it must show these with the click of a button(only if the conditions are true).
Maybe some sort of a program or xml schema?
Please any help would be much appreciated. Thanks in advance.
I have tried XML schema and Altova as well as excell.

Is there a counterpart of JaxB's ObjectFactory in JiBX?

I'm trying to enhance a module from using JaxB to JiBX. I was able to produce the java classes through the jiBX maven plugin in pom.xml although I'm having issues on how I can generate an Objectfactory just like the one in JaxB's. Is there like a counterpart in JiBX because I've been searching through the net for hours but I can't find one. I'm new to marshalling and unmarshalling mechanisms so any help will be much appreciated. Thanks!
Rocky,
JiBX has a similar mechanism. You need to create a JiBX Binding Factory then create a Marshalling or Marshalling context. The best way to see this is to look at one of our examples. Here's a link to a simple program that creates a java object, marshalls it to XML, then unmarshals the XML back to java objects.
https://github.com/jibx/maven-plugin/blob/master/test-suite/base-binding-test/org.jibx.schema.test.person/src/main/java/org/jibx/schema/test/person/PersonTest.java
Enjoy!
Don

JAXB unmarshall validation against DTD

Apologies if the question is already posted elsewhere. I couldn't find the correct answer yet.
I am using javax.xml.bind.Unmarshaller to unmarshall a XML document into a Java Object. While unmarshalling I need to validate this XML against a pre-defined DTD to ensure the tags in the XML document are correct. Can someone let me know how to do this?

Gate- add annotation to entire document

I am trying to do document classification with gate. For that I need to annotate the entire document with one type of annotation. Can anyone please tell me how to do that?
Usually I use XML for that purpose. Something like:
<document class="class-1">
The text of you document 1 is here..
</document>
<document class="class-2">
The text of you document 2 is here..
</document>
Then save these xml as separated files (or as one document).
In GATE application you can use Annotation Set Transfer PR and move annotation from "Original markups" to default annotation set. This is one of the options. Other options depends on data format you have.
If your source documents are HTML or XML then there will already be an annotation in the Original markups set that spans all the content, otherwise the simplest option would be to load the Groovy plugin and use the scripting PR with a one-line script like
outputAS.add(doc.start(), doc.end(), "Document", Utils.featureMap())

DTD to XSD migration of web.xml

I'm migrating my project from j2ee-1.3.jar to javaee-api-5.jar.
web.xml used to use http://java.sun.com/dtd/web-app_2_3.dtd DTD for validation now it needs to use the XSD http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
The original web.xml as usual fails with the current XSD,while trying to install in webLogic
I have following questions -
1. Do i need to compulsory do the correction of all the elements which are not correct according to the new XSD basically servlet tags are rearranged or changed I guess.
2. Is it compulsory to have an XSD in web.xml, can I do away with the XSD definition and hence validation of the XML
Do i need to compulsory do the correction of all the elements which are not correct according to the new XSD basically servlet tags are rearranged or changed I guess.
Yes
Is it compulsory to have an XSD in web.xml, can I do away with the XSD definition and hence validation of the XML
No
References
XML 1.0 Schema: xml.xsd

Resources