JAXP vs JAXB

Hi there,
Since there are so many API's to work with XML, and being these Sun specifications, what are the really differences between them? And when should I use one instead of the other.
Many Thanks,
MeTitus

But in this case, why does Sun have two API to work
with XML? JAXP and JAXB.It's because they do completely different things. As I'm sure that link that dvohra posted says.

Similar Messages

  • JAXP or JAXB?

    Hi all,
    I got an XSD and I want to build an HTML that reflected the XSD.
    For example if I got <xs:complex> tag with few elements I want to make a combobox.
    My questions are:
    1. What technology can help me here, JAXP or JAXB? (Don't forget there're few attributes and other types that should be in the object) .
    2. Is someone knows about new technology or there's something out there that do it? (I know about EMF).
    Thanks in advance,

    you need jaxb if you have to create/manipulate an xml file without knowing of xml technology. So it is not used for transforming.
    If I understood correctly, you are building a simple form, in this case starting from a simple well formed xml (not "valid") not binded to schema will do the job. In this case you can specify all attributes and transform easily with xslt.
    <field type="textarea" col="20".../>But all depends on where the data would go after pressing "submit". In a database ? Back into xml ?
    Also I suppose it is not correct (and not possible I guess) transforming an xsd directly into something else, as you could re-arrange all the data constraint. A schema has to keep its integrity, its only purpose is to validate file.

  • JAXP and JAXB

    When to use JAXB and when to use JAXP?

    Excuse me. Is it a meaningless question?Sort of. It's kind of like asking "when to walk and when to ride the bus." Both get you where you are going but at different speeds and costs. For example, you wouldn't ride the bus to the bed to the bathroom and you probably wouldn't walk 20 miles if you can help it.
    On a side note, JAXP is a extremely painful API for building XML documents. If you can use JDOM or some other simplified API and SAX for when you on;y want to parse.

  • JAXB Problem in Oracle9ias(9.0.3)

    Hi,
    I am getting following exception when i try to use JAXB in Oracle9ias(9.0.3).I have placed all latest JAXP and JAXB jars in j2ee\home also.
    Please help me to rectify this.
    Regds,
    Srini.
    PS:Stack trace is .....
    javax.xml.bind.JAXBException: Provider com.sun.xml.bind.ContextFactory could not be instantiated: java.lang.IncompatibleClassChangeError: Implementing class
    - with linked exception:
    [java.lang.IncompatibleClassChangeError: Implementing class]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:118)
    at javax.xml.bind.ContextFinder.searchcontextPath(ContextFinder.java:233)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:153)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:281)
    at ezcommerce.ezjumpins._srini._ezJaxb._jspService(_ezJaxb.java:50)
    [SRC:/EzCommerce/EzJumpins/Srini/ezJaxb.jsp:4]
    at com.orionserver[Oracle9iAS (9.0.3.0.0) Containers for J2EE].http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
    at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:560)
    at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
    at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
    at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.AJPRequestHandler.run(AJPRequestHandler.java:148)
    at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.AJPRequestHandler.run(AJPRequestHandler.java:72)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:797)
    at java.lang.Thread.run(Thread.java:479)

    Unfortunately you are in a grey area here ... by replacing jars in the OC4J/Oracle9iAS distribution you may get a working configuration but typically this is not supported by Oracle Support - they only support certified configurations. Support typically wants a vanilla distribution if there are any problems or some
    sort of backport testing done by the engineering team.
    You may have seen that some folks on the list got a JAXB replacement to work with 9iAS 9.0.2 ... if you want to explore this see:
    JAXB Problem with App Server 9.0.2
    The one issue with the above response is the jaxp jar included in the OC4J distribution is set up to work with the Oracle XML parser so replacing this will likely break other aspects of the installation despite the poster above finding that it worked in his situation.
    Lastly, bear in mind in the Oracle XDK we are now shipping early versions of JAXB and plan to have a JAXB 1.0 implementation around JavaOne in the XML kit that is distributed with OC4J. This will eliminate the need to replace jar files. See:
    http://otn.oracle.com/tech/xml/xdk/content.html
    Hope this helps.
    Mike.

  • Some JAXB code to read?

    I am wondering if anyone would be so kind as to provide me with some example
    code showing a class that outputs the following document:
    <?xml version='1.0' encoding='utf-8'?>
    <parameters>
         <fileBoxInfo>
              <filename>r:\files\practice\file.txt</filename>
              <filename>r:\files\practice\file2.txt</filename>
                    <filename>r:\files\practice\file3.txt</filename>
         </fileBoxInfo>
         <reports>
              <reportName>Report</reportName>
         </reports>
    </parameters>I mostly want to see the actual code to parse output the XML document, i am
    a bit confused as to how this works. I did a search and many of the places I
    found suggested outputing the XML document using write statements, and
    building the XML lines using the String class i.e.=
    "<" + tagName + ">" + value + "</" + tagName ">" ;
    but I would rather learn the nitty-gritty stuff, as ugly as it very well may be.
    Can anyone help me? this is NOT for homework, this is a project i am doing
    at work where i have the opportunity to learn JAXP and JAXB.
    I sincerely appreciate any help you give. Thanks in advance

    1. U need to have a XML schema defined first for ur XML
    2. Download Java WebServices Developer Pack
    3. use JAXB compiler to generate the binding code
    4. Then u can use JAXBContext, Marshaller etc classes to output the below XML
    YES, it is not as straight forward as we expect.

  • XMLBeans an satndard or a potential "Vendor Lock-in" source?????

    Hi...
    I'm developing a J2EE App that needs to persist its configuration data in a non Database storage mainly because one of the config data is the database connection string, driver name, etc.
    Taking a look at some App servers instalations directories (SJSAS an JBOSS) i fpund that both servers persist this type of info using XML files so i think that my app may take advantage of using xml instead Java Properties files...
    Well, the problem is that after searching info about some JAXP and JAXB APIS i found a third party API Called XMLBeans from Apache Foundation... As JAXB, XMLBeans bind java objects to XML file but it also support XMLSchema files.
    My app real requirement is to persist its configuration data to server file system and validate the data at runtime in order to pevent data corruption. XMLBeans appears to be what i need to use but using a third party API would no bring me app to a "VENDOR LOCK-IN"???
    I know that some of this third party libraries becomes parts of J2SE or J2EE Standard after some time but i want to be sure of what i'm doing in order to make my app as portable as possible.
    Regards...

    thanks for the anwser... well my goal is to develop an application capable of read and write xml files according to a schema...
    i want to avoid vendor specific features in order to be able to deploy my app to any J2EE Server that implement the standard (SJSAS, JBoss, Etc).
    it's seen that i do not make myself clear, my goal is to be able to deploy my app without having to create system variables, adding extra libraries to J2EE server, etc.... i guess XMLBeans is the right way, but if you know a way to write xml files and validate it against schemas using native Java API (StrAX, JAXB, JAXP) please let me know....
    I wil try to put XMLBeans libraries inside lib folder of my ear just to see what happend !!!!!!!!!!
    Anyway thanks for the help and any advice you could give me....
    Regards

  • Parsing a schema and persisting to database

    I need to provide ability to upload schema from a webpage, parse it and break it down into its constituent elements to store into the database...so come up with an equivalent relational model for arbitrary schemas dynamically in effect.
    Any one have experience parsing schemas (Xsd's) programmatically to extract elements and attributes? appreciate any info you can provide on approach or what parsers to use (jaxp? jaxb? jdom? dom4j?)
    RT

    Hava a look at DOM (Document Object Model),
    http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/dom/
    HH

  • Read/update large xml files

    Hi,
    My requirement is to store and update data in xml files (no other option) which can be of size > 100MB.
    This is what I am doing at the moment..
    1. In order to be able to modify, delete nodes easily I am using DOM (Dom4j)
    2. As the file size is blowing up memory I have decided to distribute data in multiple files as one file per day. In a loop I load each file as Document, modify or delete nodes and write back to disk.
    The problem is its still taking a lot of time to complete one operation and intuitively I am not comfortable with this design, I guess there is better options available..
    Can anybody suggest a better alternatives for this using less memory and faster update times. I did a bit of search on google but none like JAXP or JAXB solve my problem.

    I had a similar problem.
    I had to read through an XML file and then output it in a certain format of text file. The normal size of the XML files I was working with would be between 200KB and 3MB.
    I wrote the code for doing this using DOM, and it worked okay, and reasonably fast.
    However when I tested the file with huge files (~150MB) it completely ate up the systems memory, and eventually crashed, even with a hugely extended Java heap.
    So to solve my problem I re-wrote the program using SAX. This concerned me at first, for I'm sure the same reasons you're thinking now. At first it took me a while to get my head around how to use it, but now that I understand how it works, I find SAX to be a superior way to work with XML in Java.
    In addition, the performance improvements are huge. The program now works over twice as fast, and uses a comparatively minimal amount of memory.
    So my suggestion is to do a bit of reading about SAX and port your application to use it. If you have any questions regarding this, I'd be happy to help, especially as I've recently done the same thing.

  • Confusion on choosing the right Java XML tehcnology

    Hi there,
    I have a question about Java XML. I am still confuse on whether should I choose JAXP or JAXB for XML documents processing. I need to access a the configuration values form a properties file which stored in XML format to startup an application server, the configuration values might be using while the application server is running all the time. And probably write a tool to add/delete/modify the config values in XML file. From my point of view, I think JAXB is suitable for my needs, but I'm not sure whether the DOM tree manipulation from JAXP will be useful in my application or not. Any suggestion?
    Thanks,
    Jax

    You might want to have a look at the tutorials here:
    http://java.sun.com/webservices/docs/1.1/tutorial/doc/index.html
    When you go to the page about JAXP you will see that it says, right up front, "The Java API for XML Processing (JAXP) makes it easy to process XML data using applications written in the Java programming language." That sounds like what you want to do. And the page about JAXB says "The Java Architecture for XML Binding (JAXB) is a Java technology that enables you to generate Java classes from XML schemas." That doesn't sound like what you want to do.

  • Install JAXB and JAXP only

    Hi,
    We want to use the funtion of JAXB and JAXP
    but do not want to use the whole java web service
    Can the JAXB and JAXP work separately on JDK1.2/JDK1.3.1
    Jacinle

    The Jaxb directory in jwsdp-1.2 dir has the JAXB implementation.
    The Jaxp directory in jwsdp-1.2 dir has the JAXP implementation.

  • JAXP,JAXB

    can some body please suggest me the websites or link where I can found advanced concepts of JAXP,JAXB.
    thanks
    kanth.

    JAXP can be used to parse into DOM, using SAX, and then output to XML after you've made your changes.

  • Approach on parsing an XML file (JAXP, JAXB, DOM, SAX, XSLT)

    I have a pretty basic xml file that contains a database table name, fields, and sort order. My job is to read the XML file, construct the query based on the information in the nodes, and then output it in various ways. I know I can use JAXP, JAXB, DOM, SAX, and XSLT for this.
    I have the experience doing this using DOM. I have read up on JAXP, JAXB, and XSLT. I'm having a little bit of a difficult time on chosing the most appropriate way to do this. Again, I've always done it using DOM, but I'm not so sure that is the best way to do it here. Just looking for some recommendations from people whom are more familiar with XML parsing and processing.

    markwagoner wrote:
    I tried several of those but found them rather tedious. Now I just use JDOM for everything, it make life much easier.It doesn't, actually. It kept your learning curve shallow, but that's all. If you were to invest some time in JAXB, you'd find it made life easier for some things. If you invested time in XSLT, it would make life easier. Endlessly working with JDOM is incredibly tiresome after a while. You just don't know it because you never invested enough in learning anything else.
    Don't bother posting any code to "enlighten" me as to how simple JDOM is. I've been using it for years.

  • JAXB , JAXP and SAX compare

    Hi,
    I want to convert XML to another XML using XML Schema.
    I have XML Schema for the one I will convert to.
    I also need to modify some of the data.
    But I am confuse which process should I use, JAXB, JAXP or SAX.
    Any suggestions?
    Thanks,

    javax.xml.transform

  • Bug in JAXP or not?

    Hi all,
    I'm using JAXP 1.4 and JDK1.5_12, when I get to the following method I get the following exception:
    transformer.transform(source, result);
    Exception in thread "main" java.lang.NoSuchMethodError: com.sun.org.apache.xerces.internal.parsers.XML11Configuration.getFeature0(Ljava/lang/String;)Z
         at com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration.getFeature(XIncludeAwareParserConfiguration.java:278)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.reset(AbstractSAXParser.java:2098)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:147)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:391)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:231)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:493)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:663)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:300)
         at com.mycompany.test.jaxb.TestJAXP.main(TestJAXP.java:38)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)Edited by: sasi2103 on Dec 18, 2007 7:53 AM

    Hello
    I have got similar exception when trying to run my web application in linux red hat.
    Jetty + JaxWS
    com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized WSSERVLET11: failed to parse runtime descriptor: java.lang.NoSuchMethodError: com.sun.org.apache.xerces.internal.parsers.XML11Configuration.getFeature0(Ljava/lang/String;)Z
    java.lang.NoSuchMethodError: com.sun.org.apache.xerces.internal.parsers.XML11Configuration.getFeature0(Ljava/lang/String;)Z
         at com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration.getFeature(XIncludeAwareParserConfiguration.java:278)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.reset(AbstractSAXParser.java:2098)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:147)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:560)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:642)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
         at com.sun.xml.ws.util.pipe.AbstractSchemaValidationTube.createDOM(AbstractSchemaValidationTube.java:90)
         at com.sun.xml.ws.server.ServerSchemaValidationTube.getSchemaSources(ServerSchemaValidationTube.java:103)
         at com.sun.xml.ws.server.ServerSchemaValidationTube.<init>(ServerSchemaValidationTube.java:58)
         at com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext.createValidationTube(ServerTubeAssemblerContext.java:212)
         at com.sun.xml.ws.util.pipe.StandaloneTubeAssembler.createServer(StandaloneTubeAssembler.java:76)
         at com.sun.xml.ws.server.WSEndpointImpl.<init>(WSEndpointImpl.java:152)
         at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:217)
         at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
         at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
         at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
         at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
         at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:540)
         at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
         at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
         at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:510)
         at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
         at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
         at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
         at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
         at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
         at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
         at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
         at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
         at org.mortbay.jetty.Server.doStart(Server.java:222)
         at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    I have that xercesImpl in classpath, maybe i need a different version for Linux? my app works fine in Windows.
    Whatcould be the problem here?
    thanks a lot
    BR,
    seb

  • JAXB v1.0.2 and Webstart

    Hi,
    I'm trying to use JAXB within an app that is started via JNLP and WebStart.
    If i add all the JAXP jars to the JNLP file the app fails to start when JAXB calls into some xerces code that tries to access java.home.
    java.security.AccessControlException: access denied (java.util.PropertyPermission java.home read)
    /* stack trace */
         at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(SAXParserFactoryImpl.java:95)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.getXMLReader(AbstractUnmarshallerImpl.java:80)
    If i dont put in the JAXP jars then i get the following:
    Caused by: java.lang.RuntimeException: Installation Problem??? Couldn't load messages: Can't find bundle for base name org.apache.xerces.impl.xpath.regex.message, locale en_US
         at com.sun.msv.datatype.xsd.regex.RegexParser.setLocale(RegexParser.java:132)
         at com.sun.msv.datatype.xsd.regex.RegexParser.<init>(RegexParser.java:122)
    If i put the jaxp jars in jre/lib/endorsed, then everything works - except that isnt going to work for a remote client.
    So, question is why does xerces require access to java.home ?

    I am getting essentially the same exception when running my app from command line:
    java.lang.RuntimeException: Installation Problem??? Couldn't load messages: Can't find bundle for base name org.apache.xerces.impl.xpath.rege
    x.message, locale en_US
    at com.sun.msv.datatype.xsd.regex.RegexParser.setLocale(RegexParser.java:132)
    at com.sun.msv.datatype.xsd.regex.RegexParser.<init>(RegexParser.java:122)
    at com.sun.msv.datatype.xsd.regex.ParserForXMLSchema.<init>(ParserForXMLSchema.java:71)
    [ snip ]
    The same code works find when running inside a webapp on Tomcat 5.
    Did you ever find the source of your problem, and indeed a solution?

Maybe you are looking for

  • Scanning from 5520 to iPad in wireless direct mode ?

    I have a Photosmart 5520 printer and a 3G  iPad - without any other computer equipment or WiFi network or router in the house. The printing from the iPad to the 5520 in the Wireless direct mode works well. My question is if I can scan from the 5520 t

  • How to find out if my system allows for a SSD upgrade

    Hi, I've X1 Carbon that was bought in last december. It says type 3444 - 9FU.  I've only 180 GB, I want to know if I could upgrade this to 512GB or more if possible? How do I find out if my system will allow this? Thanks in advance. Solved! Go to Sol

  • Usage Customer Exit EXIT_SAPLCUKO_003 / Enhancement CCUX0004

    Hello, I like to add new attributes of instances in LOVC during configuration of material in VA02. I found this Userexit and with function module CUDB_SET_VAL it is possible to add new values in the global table cudbd_pr_at_msg of function group CUDB

  • How to Convert a Element to a different Element?

    I get a xml Element from others, for some reason I must convert it to my format, like add some attribute, change some attributes' name: example, original include:   <original id="000" name="father">     <original id="001" name="first"/>     <original

  • XAER_RMFAIL : Resource manager is unavailable

    Weblogic 8.1, I don't recall which service pack, sp10? Maybe? Anyway, here's the relevant stack trace. We had a strange WLS implosion last night that we're tracking down. We saw these when our code was trying to get a connection out of the datapool.