How use XSD and Java? What classes/methods?

I want to use an XSD instead of a DTD with my XML and Java. Does anyone know the classes/methods I should use to do this? Is it even possible? Can you send sample code?

here is the helper function... hope it helps...
import java.io.IOException;
import java.math.*;
import java.text.*;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
public class SAXParserDemo
     public SAXParserDemo()
     public void performDemo(String uri)
          System.out.println("Parsing XML file: " + uri + "\n\n");
          ContentHandler contentHandler = new MyContentHandler();
          ErrorHandler errorHandler = new MyErrorHandler();
          try
               XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
               parser.setContentHandler(contentHandler);
               parser.setErrorHandler(errorHandler);
               parser.setFeature("http://xml.org/sax/features/validation", true);
               parser.parse(uri);
          catch(IOException e)
               System.out.println("Error reading URI: " + e);
          catch(SAXException e)
               System.out.println("Error in parsing: " + e);
     public static void main(String[] args)
          if(args.length != 1)
               System.out.println("Usage: java SAXParserDemo [XML URI]");
               System.exit(0);
          String uri = args[0];
          SAXParserDemo parserDemo = new SAXParserDemo();
          parserDemo.performDemo(uri);
class MyErrorHandler implements ErrorHandler
     public void warning(SAXParseException exception) throws SAXException
          throw new SAXException("Warning encountered."+exception);
     public void error(SAXParseException exception) throws SAXException
          throw new SAXException("Error encountered: "+exception);
     public void fatalError(SAXParseException exception) throws SAXException
          throw new SAXException("Fatal error encountered."+exception);
class MyContentHandler implements ContentHandler
     private Locator locator;
     public void setDocumentLocator(Locator locator)
          //System.out.println("     * setDocumentLocator() called");
          this.locator = locator;
     public void startDocument() throws SAXException
          //System.out.println("System Message: Parsing begins...");
     public void endDocument() throws SAXException
          //System.out.println("System Message: ...Parsing ends.");
     public void processingInstruction(String target, String data) throws SAXException
          //System.out.println("System Message: PI: Target: "+target+" and Data: "+data);
     public void startPrefixMapping(String prefix, String uri)
          //System.out.println("System Message: Mapping starts on prefix "+prefix+" mapped to URI "+uri);
     public void endPrefixMapping(String prefix)
          //System.out.println("System Message: Mapping ends on prefix "+prefix);
     public void startElement(String namespaceURI, String localName, String rawName, Attributes atts) throws SAXException
          //System.out.println("System Message: startElement: "+localName);
          if(!namespaceURI.equals(""))
               //System.out.println("System Message: in namespace "+namespaceURI+" ("+rawName+")");
          else
               //System.out.println("System Message: has no associated namespace");
          int i;
          for(i=0;i<atts.getLength();i++)
               //System.out.println("System Message: Attribute: "+atts.getLocalName(i)+"="+atts.getValue(i));
     public void endElement(String namespaceURI, String localName, String rawName) throws SAXException
          //System.out.println("System Message: endElement: "+localName+"\n");
     public void characters(char[] ch, int start, int length) throws SAXException
          String s = new String(ch, start, length);
          //System.out.println("System Message: characters: "+s);
     public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
          String s = new String(ch, start, length);
          //System.out.println("System Message: ignorableWhitespace: ["+s+"]");
     public void skippedEntity(String name) throws SAXException
          //System.out.println("System Message: Skipping entity: "+name);
}

Similar Messages

  • How to import custom java jar/class into oracle to be used in java proc ?

    Hi
    I would like to know how to import custom java jar/class files into oracle to be used in java stored procedure.
    I am developing a oracle pl/sql procedure to call java program. The java program will be created as procedure and will be published.
    But, my question is that I do have a other external jar/class file that need to be imported into this java program.
    example
    raise_sal.java
    import java.util.*;
    import oracle.sql.*;
    <<reference other java programs >>
    import cmpmsgsvc.xxxx.* ;
    import cmpmsgsvc.yyyy.* ;
    import cmpmsgsvc.zzzz.* ;
    how do I import the cmpmsgsvc jar/class file into oracle so that I don't have any
    compilation errros on raise_sal.java program ??
    what are the steps to import/compile and validate to do this?
    thanks for your help in advance.
    Thanks
    rrb.

    Kuassi
    Problem is that, I have 6 jar files that are needed to be included in the main java program. And, there are more than 50+ classes, propertiers in those 6 jar files.
    It might be not good idea to have all those 50+ classes in the production database.
    Is there anyway that I keep all those 6 jar files in unix box (our's is oracle erp installation with oracle being installed on unix box) and just refer them in the main java program. I mean database will be loaded with main java program and it should able to refer other 6 jar files from unix.
    if we create a directory and keep all jar files in there and include that directory in classpath variable, does this works? or what is other method?
    Please let me know.
    Thanks

  • ActiveX in BradySoft (CodeSoft) - What Class/Method/Object's would I use to send variable form data to BradySoft?

    What Class/Method/Object's would I use to send variable form data to BradySoft? I have a basic label setup in BradySoft and I want to send it variable form data (a serial number) from Labview ActiveX. I have attached Brady's ActiveX programmers guide but can't figure out what to use for this. P.S. I would call Brady or TekLynx tech support about this but they have a strict policy whereas BradySoft supports ActiveX but their tech support doesn't provide programming help with it. I figured I'd try the NI Forums.  

    Aaronb, I presume by publishing an ActiveX programmers manual the BradySoft software installs Active X objects. You may choose to interact with these objects within LabVIEW using Active X controls. The following link will provide a starting point for LabVIEW help topics on Active X communication: Select ActiveX Object Dialog Box
    http://zone.ni.com/reference/en-XX/help/371361F-01/lvdialog/insert_active_x_object/
    Building a Simple Web Browser Using ActiveX (Example of ActiveX arcitecture)
    http://zone.ni.com/devzone/cda/epd/p/id/81 Hope this helps provide a bit of guidance. Cheers!  

  • Information Retrieval with Genetic Programming using J2ME and Java WTK

    i have a big project to make a software using java programming especially n using J2ME and Java Wireless Toolkit, and i'm a begginer for java programming. I have no idea for the interface and how to setting connection between my phone mobile and GPRS. what should i do? thank you

    I believe MIT has lots of sourcecode. Try searching their site.

  • Not able to recognize any video/audio devices using jmf and java soun

    Hi ,
    I need one help from your side.
    Here I am expecting some clarifications from you. Before that let you my environement.
    My working environment :
    Eclipse tool and added jmf jar to my project I did not do any thing more.
    If any thing I need to do just let me know. My target platform is MAC & UBUNTU.
    Please bare with my questions.
    1) I am not able to recognize any video/audio devices using jmf and java sound APIs on My system.
    ( I checked with the app mentioned in the http://www.java-forums.org/new-java/11201-jmf-cannot-connect-device.html )
    Do we need any administrives rights for our working PC.
    What is the procedure/ setup I need to follow from a java application to enable particular audio/video device since I dont about end-user system setup right.
    If possible send some sample code to recognize /r detect audio device ( voice input ). It should run on both MAC and UBUNTU.
    2) I run the one sample audio recording application of this link (http://www.jsresources.org/examples/SimpleAudioRecorder.java.html) which is provided by YOU.
    I got output audio file and able to hear voice on UBUNTU system but not able to hear voice on MAC system.
    I heared that default line in ( audio setup of the sys) is wont take any voice data on MAC.Why I made this stmt means we are getting false when using isSupported methods of JAVA SOUND API.
    ( like for TragetdataLine ...i,e, all ports are getting false)
    I have one sample audio recording app implemented by QUICKTIME API. In this case also he taking audio ftom device only using quicetime API.
    With that we are able to record and hear audio ( voice input --> not line in , external device we added some thing like SSB...)
    3) In case of Video capturing DataSource, Streams are implemented by PullBufferDataSource , PullBufferStream intefaces used.
    In case of Audio capturing DataSource, Streams are implemented by PushBufferDataSource, PushBufferStream intefaces used.
    Can you explain the reasons ? I gone through API but i am not clear.
    HOPE I WILL BE CLARIFIED EVERY THING FROM YOU.
    Thanks
    RamaRao.G

    Hi ,
    I need one help from your side.
    Here I am expecting some clarifications from you. Before that let you my environement.
    My working environment :
    Eclipse tool and added jmf jar to my project I did not do any thing more.
    If any thing I need to do just let me know. My target platform is MAC & UBUNTU.
    Please bare with my questions.
    1) I am not able to recognize any video/audio devices using jmf and java sound APIs on My system.
    ( I checked with the app mentioned in the http://www.java-forums.org/new-java/11201-jmf-cannot-connect-device.html )
    Do we need any administrives rights for our working PC.
    What is the procedure/ setup I need to follow from a java application to enable particular audio/video device since I dont about end-user system setup right.
    If possible send some sample code to recognize /r detect audio device ( voice input ). It should run on both MAC and UBUNTU.
    2) I run the one sample audio recording application of this link (http://www.jsresources.org/examples/SimpleAudioRecorder.java.html) which is provided by YOU.
    I got output audio file and able to hear voice on UBUNTU system but not able to hear voice on MAC system.
    I heared that default line in ( audio setup of the sys) is wont take any voice data on MAC.Why I made this stmt means we are getting false when using isSupported methods of JAVA SOUND API.
    ( like for TragetdataLine ...i,e, all ports are getting false)
    I have one sample audio recording app implemented by QUICKTIME API. In this case also he taking audio ftom device only using quicetime API.
    With that we are able to record and hear audio ( voice input --> not line in , external device we added some thing like SSB...)
    3) In case of Video capturing DataSource, Streams are implemented by PullBufferDataSource , PullBufferStream intefaces used.
    In case of Audio capturing DataSource, Streams are implemented by PushBufferDataSource, PushBufferStream intefaces used.
    Can you explain the reasons ? I gone through API but i am not clear.
    HOPE I WILL BE CLARIFIED EVERY THING FROM YOU.
    Thanks
    RamaRao.G

  • How can we call java control source methods within jsp

    Hi guys!
              How can we access java control source methods that are defined in java control projects within jsp.I am getting error when I tried to call java control source's methods in scriptlet of JSP page.Any help/suggestion is appreciated.
              Thanks
              -Chandu

    Uh, what?
    (And you are sure that it's not a Weblogic-specific question?)

  • When to use interface and when Abstract Class?

    In a recent interview I was asked "When to use interface and when Abstract Class?" Explain with an example.
    Also in what situations a class should be made final(real time example)

    Interface is a pure contract with no implementation. Typically used to define a communication contract between two different sub-systems. Example EJB home interface. This also allows the design to change as long as the contract is met.
    Abstract class is when there exists a lot of common functionality already known and can be coded. However, a few unknowns exists (typically about data) for which abstract methods need to be defined and implemented by the sub class.
    Example: Consider a workflow engine. A great example for abstract class. The workflow process has lot of common code that is independent of the workflow type (vendor flow, contract flow, payment flow etc). However, certain decisions on the route to take will depend on value of data being submitted. So the base class will define a abstract Data getData() method and proceed assuming data will come. The implementing subclass will provide the actual logic for getting the data.
    Also see the "Template" design pattern.
    Note: To some extent the common code design drives the behavior of the abstract methods. So if the design changes then so "might" the behavior expected from the abstract methods.

  • Simple XML to Text onversion using XSLT and Java?

    Hi all!
    I'm completly new to using XSLT and Java and are trying to convert a XML file into a ordinary Textfile that I am gonna import into another application.
    I started up writing a ordinary XML parser in Java which interpreted the XML file, but realized later on that it was possible to do with a ordinary XSLT.
    So far it is a 2-step process right now, I've tied my XSLT to the XML file and then just open the XML file up in a ordinary browser and then get the result.
    I found an example (http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=3) where u hook up a XML file and a XSL file separately and the process it, and dump it to Stdout. But do I need to hook up a XSL file like this when the XML file is tied to a XSL file internally?

    Just to give you an example to show you how easy it is: http://www.daniweb.com/forums/thread137587.html

  • Need to write a report to show who is using SAP and to what extent

    Hi Experts,
    I need to write a report which should display who are using SAP and to what extent to forcast future SAP license needs...
    and to ensure the compliance by allocating license types correctly.
    My report should helpfull to organization to reduce the current license requirements and costs.
    Actually my problem is where can i get all these details in SAP, means from which tables.
    in which table can we get the sap user ids using mail id...
    Thanks in advance........
    Ram

    Hi gajeramesh ,
    Goto transaction 'SU10'
    Here you have all the data selection regarding a particular user id, so what you can do is do F1 on any of the fields and see the technical help in that for the table names.
    some of the tables are :
                                     1) 'USUSERS'(User: Transfer structure for lists of users),
                                     2) 'USER_ADDR' (Users by address data)
                                     3) 'USUSERALL' (Users with All Data for List Output)
    I hope this helps you  !!

  • Downloaded Mt Lion Yesterday and my Tool bar has disappeared. I can still access the individual tools but cannot see my header.  I used 'help' and did what it suggested. slected 'hide tool bar' and then 'show toolbar'.  I also restarted etc.

    Downloaded Mt Lion Yesterday and my Tool bar has disappeared. I can still access the individual tools but cannot see my header.  I used 'help' and did what it suggested. slected 'hide tool bar' and then 'show toolbar'.  I also restarted etc.

    Good point BDAqua, the Escape key helps get me back to reality in Lion.
    While I've only dabbled around a little in Lion since it's release (I upgraded a 10.6 Clone to Lion on one of my FireWire Drives) now I'm currently downloading Mountain Lion (to upgrade a Clone of that Lion Clone) so that now I can continue to move forward in madness.
    P.S. Trust me, I'm not laughing. 

  • How to use java.lang.Class.getMethod() and java.lang.reflect.Method.invoke(

    I want to call a specified method of one class dynamically. I use the method
    "getMethod()" in package "java.lang.Class" to get method and "invoke()" in
    " java.lang.reflect.Method " to invoke method.
    The problem is as following :
    1. There are two argument in this method "getMethod(String MethodName , Class[] paremterTypes)" in package "Class". I have no idea about the second parameter " Class[] parameterTypes ".what does the argument exactly mean ?
    2. There are two argument in the method "invoke(object obj, object[] obj)" in package "Method".
    I have no idea about the second parameter "object[] obj ".what is mean ?
    I pass " null " value to it and it works.But i pass anothers ,jvm will throw exception.

    I have a generic Method Executer that has a method like
    public Object execute(String className, String methodName, Object args)
        String fullClassName = packageName + className ;
        Class delegateClass = Class.forName(fullClassName);
        BaseDelegate delegate = (BaseDelegate)delegateClass.newInstance();
        Method method = null;
        if (args == null)
            method = delegateClass.getMethod(methodName, new Class[] {});
            obj = method.invoke(delegate,new Object[] {});
        else
            method = delegateClass.getMethod(methodName, new Class[] {args.getClass()});
            obj = method.invoke(delegate, new Object[]{args});
       }This seems to have problems when I call the method from a class like:
    execute("CategoryDelegate", "getCategoryById", new Integer(4144));(I get a NoSuchMethodException)
    The method I am trying to execute in CategoryDelegate looks like:
    public Category getCategoryById(int categoryId) throws DelegateExceptionI think it has to deal with the difference in the way we handle Primitive Wrappers and Objects. Wrapper we have to use Interger.TYPE and with the rest of the Objects we have to use obj.class.
    Am I doing something wrong here? Any suggestions to make it work for primitive wrappers as well as Objects?

  • How to use java api while java programming especially using javase and java swing?

    i need help for java api for undo, redo, htmleditorkit,editorkit.
    in my project i have to use java swing for desktop application but, i need help for how to implement and how to retrieve java api.
    please reply with example or code..

    i need help for java api for undo, redo, htmleditorkit,editorkit.
    in my project i have to use java swing for desktop application but, i need help for how to implement and how to retrieve java api.
    please reply with example or code..
    You find examples and code by searching the internet, not by using forums.
    Start with The Java Tutorials - it has trails for the bulk of the Java functionality.
    See the trail 'How to Write an Undoable Edit Listener'
    http://docs.oracle.com/javase/tutorial/uiswing/events/undoableeditlistener.html
    You learn by DOING - not by reading. Actually DO the tutorial example and try to understand WHAT it does and HOW it does it.
    Then search for other tutorial trails that are of interest.

  • External hardrive to use with Imac - how to format and to what?

    i have my external hardrive i use with my pc
    how and to what should i format it so i can use ut with leopard and timemachine, also is it possible to make 2 partiton on it so one partition
    would still be windows format so i can backup windows on it too?

    If you have an Intel Mac do this:
    Extended Hard Drive Preparation
    1. Open Disk Utility in your Utilities folder.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area. If it does not say "Verified" then the drive is failing or has failed and will need replacing. SMART info will not be reported on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Set the number of partitions from the drop down menu to two and resize as desired using the sizing gadget. Click on the Options button, set the partition scheme to GUID (only required for Intel Macs) then click on the OK button. Click on the Partition button and wait until the process has completed.
    4. Select the PC volume you just created (this is a sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window. Set the format type to MSDOS (FAT32) from the Format drop down menu. Click on the Erase button.
    5. Select the OS X volume you just created (this is the other sub-entry under the drive entry) from the left side list. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    You should now be able to use the drive on both platforms. One partition for OS X and the other for Windows.

  • Building a best practice web application using ColdFusion and Jave EE

    I've been tasked with rewriting a software using ColdFusion.  I cannot seem to find a lot of information on best practice development in ColdFusion.  I am an experience Java developer who has never used ColdFusion before.  I want to build this application using a synergy of ColdFusion and Java EE technologies.  Can someone recommend me a book that outlines how to developer in ColdFusion?  Ideally this book assumes the reader is an experienced developer with no exposure to ColdFusion.  Ideally the methods outlined in the book are still "best practice" methods.

    jaisheela wrote:
    Hello Friends,
    I am also in the same situation.
    I am a building a new web application using JSF and AJAX.
    Requirement is I need to use IBM version of DOJO and JSF but I need to develop the whole application using Eclipse 3.3,2 and Tomcat 5.5.
    With IBM version of DOJO and JSF, will Eclipse and Tomcat help to speed up the development or do you suggest me to go for Rational Application Developer and WebSphere Application Server.
    If I need to go with RAD and WAS, then I am new to RAD and WAS, is it easy to use RAD and WAS for this kind of application and implement web applicaiton fast.
    Any feedback will be great help.Those don't sound like requirements of the system to me. They sound more like someone wants to improve their CV/resume
    From what I've read recently, if it's just fast you want, look at Ruby on Rails

  • Compiler use of 1.5 only classes/methods

    I just discovered that the 1.5 compiler uses StringBuilder for String concatenation. Does the compiler ever generate calls to StringBuilder that aren't exactly the same for StringBuffer? I'm guessing this is only done because StringBuilder isn't thread safe, not because it presents any extra functionality over StringBuffer.
    Are there any other compiler uses of classes or methods that are only available in 1.5? All I know of so far are java.lang.Enum for enumerations, and the <Primitive>.valueOf () methods for auto-unboxing.
    God bless,
    -Toby Reyelts

    Yes, all annotation types extend
    java.lang.annotation.Annotation.
    There's also java.lang.Iterable of course, but I don't
    think it gets the kind of usage you're interested in
    here.Yes, I was already aware of that, and those cases are not what I'm interested in. Let me try to be more specific - I'm looking for compiler use of types or methods that are not explicitly "requested" by the source code - like StringBuilder and the valueOf method calls.
    God bless,
    -Toby Reyelts

Maybe you are looking for

  • Is it possible to add buttons on a screen without drawing in screen painter

    Hi experts and others, I want to design a flexible screen structure so I want my buttons which are on a screen appears according to my wish at runtime. Is it possible to design a screen like this. In addition, I would get my button's name and fcode f

  • Filtering with wildcards in af:table

    Hello! We are using af:tables with filter bars. By default, attributes of Java type String are filtered with an additional wildcard at the end, respectively they are using the STARTSWITH operation in the ViewCritieriaItem. This behaviour is done in c

  • Delivery and billing problem

    Hi While raising sales order and saving it i am not getting any problem but, while doing pgi or saving invoice an error is  occuring stating that field not assigned to condition access what might be the reason for this.... regards, ram

  • Keyboard layout switcher Gnome panel

    Hi guys, Am using US altgr-intl as default. The icon US keyboard pops up everytime I start the system though I removed the layout a couple of times through system->prefs. It's not a big deal but starts to irritate me. Anyone an idea how to either dis

  • Apple TV won't sync or stream from iTunes

    Ok, I've seen numerous threads with numerous fixes for syncing issues. I just bought this unit,lightly used. It setup fine, it sees my wireless network and does show up in iTunes 8.1. It just gives me the old firewall 3689 apple tv not responding cra