How to validate the Xml File With Java

Hi,
Can pls tell me. I want to validate the XML File for the Some Mandartory TAG. if that if Tag null i want to generate error xml file with error and i want move another folder with java. pls help me as soon as possible

Use a validating parser (any recent Xerces, for one) and switch on the validation feature. Very much vendor-specific, so look at the docs of your parser. Oh, you do have a schema for these documents, don't you?

Similar Messages

  • How to validate an XML file with XSD Schema on JDK 1.4

    Hi
    I'm looking for samples how to validate xml files with xsd schema using jsdk 1.4
    Thank you.

    This is how.
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.dom.DOMResult;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.validation.Schema;
    import javax.xml.validation.SchemaFactory;
    import javax.xml.validation.Validator;
    DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
    dbfac.setNamespaceAware(true);
    SchemaFactory factory1 = SchemaFactory
                        .newInstance("http://www.w3.org/2001/XMLSchema");
    Schema schema = factory1.newSchema(new File("person.xsd"));
    dbfac.setSchema(schema);
    DocumentBuilder dbparser1 = dbfac.newDocumentBuilder();
    Document doc1 = dbparser1.parse(new File("person.xml"));
    Validator validator1 = schema.newValidator();
    DOMSource dm1 = new DOMSource(doc1);
    DOMResult domresult1 = new DOMResult();
    validator1.validate(dm1, domresult1);

  • How to download the xml file with netweaver 2004s

    I am trying to find the xml file in order to link R/3 to my portal
    I installed Netweaver 2004s but I am not able to link to R/3
    I heard that I can use another xml file from another server and download it and change the config to match the new server
    JF

    Hi JF,
           Michael is right in EP5, system are defined in XML file. use the following properties you will able to create system connecting to R/3.
    choose System Administration->System Configuration-> System Landscape.
    Create a  system of  SAP_R/3_Dedicated type system
    Select the <b>Connector</b> from the Property category dropdown
    Application Host : <R/3 Host name>
    SAP Client: <Clent no>
    SAP System ID (SID):
    Server Port: 
    SAP System Number
    System Type: SAP_R3
    Select the <b>User Management</b> from the Property category dropdown
    Logon Method - UIDPW
    User Mapping Type - Admin,user
    Select <b>System Aliases</b> in the Edit dropdown list.
    This opens the System Alias Editor, and displays the existing list of aliases created for this system. Add the system alias here.
    Select the <b>test connection</b> in the Edit dropdown list:
    test the connection
    Hope this will solve your problem.
    Thanks
    Sai

  • How to edit the existing data in the XML file from java programming.

    Hi all
    i am able to create XML file with the sample data as below from java programming.
    i need sample code on how to edit the existing data in the XML file?
    for example
    <?xml version="1.0"?>
       <mydata>
               <data1>
                         <key1>467</key1>
                        <name1>Paul</name1>
                        <id1>123</id1>
              </data1>
              <data2>
                         <key2>467</key2>
                        <name2>Paul</name2>
                        <id2>123</id2>
              </data2>
        </mydata>
    i am able to insert the data in the XML.
    now i need sample code on how to modify the data in the above XML file from the java programming for only key2,name2,id2 tags only. the remaining tags data in the XML file i want to keep same data except for key2,name2,id2 which are i want to modify from java code
    Regards
    Sunil
    [points will be always rewardable]

    hi
    u need a parser or validate the xml file for to read the xml file from java coding u need for this
    xml4j.jar u can download this file  from here
    http://www.alphaworks.ibm.com/tech/xml4j
    or we can use the SAX(simple API for XML)
    some sample applications for this
    http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html
    http://www.developertutorials.com/tutorials/java/read-xml-file-in-java-050611/page1.html
    http://www.xml-training-guide.com/e-xml44.html
    let me know u need any other info
    bvr

  • How to get the XML file if we are using the Product short name.

    Hi,
    Till now I have used Short name of the Concurrent Program for Code while creating a Data Definition. Now saw a seeded template which has given the Code by Product short name. If we have the concurrent program then it is easy to refer the fields by checking the XML file. In this case how to find the XML file or how to refer all the fields if we have given code with Product short name. I saw this for iReceivables(ARI). Anybody please help me.
    Thanks.

    Hi Siva
    Just to clarify, rather than the short name of the conc program there is a shipped data definition that just uses the product short name? What is the data def so I can check it.
    Regards, Tim

  • How to create the exe file for java project.

    How to create the exe file for java project.
    am done the project in java swing , i like to create the project in exe format, so any one help for me,
    send the procedure for that.
    thanking u.

    How to create the exe file for java project.Have you ever heard of google? I pasted your exact "question" into a google search:
    http://www.google.com/search?q=How+to+create+the+exe+file+for+java+project.
    and got several useful links.
    Better search terms might yield even better results.
    Sheesh.

  • How to fix the .pdf file with error "invalid annotation object"

    how to fix the .pdf file with error "invalid annotation object"

    As long as the PDF opens, then just try saving it to a new file name. There may be a preflight script that would help troubleshoot the issue.

  • How to call the XML file as PrivateResourcePath in JSP

    Hi All,
    I want to call the layer-config.xml values in JSP dropdown list. How to call the XML file as PrivateResourcePath in JSP... please advise me if any solution.
    locaiton: dist/PORTAL-INF/layer-config.xml
      <?xml version="1.0" encoding="utf-8" ?>
    - <layer-config>
    - <system>
      <layer>Test</layer>
      <internal>true</internal>
      </system>
    - <system>
      <layer>Test1</layer>
      <internal>false</internal>
      </system>
    - <system>
      <layer>Test3</layer>
      <internal>false</internal>
      </system>
      </layer-config>
    Thanks in advance.

    Hi,
    The below link may help you.
    [Accessing image from dist/imgaes folder inside JSPDynpage Component;
    Regards,
    Suresh Bachimanchi

  • How to create the exe files for java application

    How to create the exe file for java application?
    got any software to do that?
    Thanks

    In terms of converting java applications into exe files, there are 3 schools of thought:
    1) Instead of converting it to an exe, convert it to a jar file. Jar files are more portable than exe files because they can be double-clicked on any operating system. The caveat is that a Java interpreter must be installed on the target computer for the double-clicking to work.
    http://developer.java.sun.com/developer/Books/javaprogramming/JAR/
    2) Create an exe launcher that, when double-clicked, attempts to find a Java interpreter on the local computer and launches the Java application. The exe file is still double-clickable but whether your java application runs depends on whether a Java interpretor is installed on the target computer.
    http://www.sureshotsoftware.com/exej/
    http://www.objects.com.au/products/jstart/index.jsp
    http://www.duckware.com/products/javatools.html
    http://www.ucware.com/jexec/
    http://www.rolemaker.dk/nonRoleMaker/javalauncher/
    http://www.jelude.cjb.net/
    http://thor.prohosting.com/~dfolly/java/index.html
    3) Create an exe launcher that bundles a Java interpretor. Same as above but when the exe file is double-clicked, it searches for a Java interpreter and if one is not found, it installs one on the target computer. The caveat is that the exe file would have an overhead of 10 MB in size for the interpreter.
    http://www.excelsior-usa.com/jet.html (evaluation version available)
    4) Convert the Java application into a native exe file. The caveat is that if you use Swing for your GUI, it won't be converted. Also this option is still somewhat experimental.
    Can't think of any free options right now.

  • How to call the XML file as Private

    Hi All,
    I want to call the layer-config.xml values in JSP dropdown list. How to call the XML file as PrivateResourcePath in JSP... please advise me if any solution.
    locaiton: dist/PORTAL-INF/layer-config.xml
      <?xml version="1.0" encoding="utf-8" ?>
    - <layer-config>
    - <system>
      <layer>Test</layer>
      <internal>true</internal>
      </system>
    - <system>
      <layer>Test1</layer>
      <internal>false</internal>
      </system>
    - <system>
      <layer>Test3</layer>
      <internal>false</internal>
      </system>
      </layer-config>
    Thanks in advance.

    Hi,
    The below link may help you.
    [Accessing image from dist/imgaes folder inside JSPDynpage Component;
    Regards,
    Suresh Bachimanchi

  • How to overwrite the xml file...

    Hi,
    can any one help me how to overwrite the xml file.....
    ~~Sk

    Flash Player cannot write XML files at all. but using
    php+flash we could do it .

  • ServiceBus java callout - how to pack the JAR file with libraries?

    Hello
    I want to use a Java Callout from a Service Bus flow.
    What is the correct way to pack the JAR file with its nessecary libraries?
    I tried different methods to pack my JAR, but yet, as though the Java runs perfectly from the Workshop (Eclipse) , when I am trying to use the exported Jar on the ServiceBus flow, it fails with an ClassNotFoundException.
    I would really appreciate your advice here.
    Thanks
    Koby

    Well.. Looking inside my exported JAR file, I got all of the files there inside, including the jar file containing the library.
    What I'm trying to do is run a simple java program that connect through SSH and therefore use an SSH library.
    On the workshop I got it as an imported library JAR. And it works perfectly there.
    Any idea?
    Here's the complete error I get:
    <BEA-382515> <Callout to java method "public static java.lang.String sshpackage.SshProg.remoteScriptInvoke(java.lang.String,java.lang.String,java.lang.String,java.lang.String)" resulted in exception: null
    java.lang.reflect.InvocationTargetException
    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:597)
    at stages.transform.runtime.JavaCalloutRuntimeStep$1.run(JavaCalloutRuntimeStep.java:158)
    Truncated. see log file for complete stacktrace
    java.lang.NoClassDefFoundError: ch/ethz/ssh2/Connection
    at sshpackage.SshProg.remoteScriptInvoke(SshProg.java:29)
    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:597)
    Truncated. see log file for complete stacktrace
    java.lang.ClassNotFoundException: ch.ethz.ssh2.Connection
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at com.bea.wli.sb.resources.archive.HookedJarClassLoader.loadClass(HookedJarClassLoader.java:251)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    Truncated. see log file for complete stacktrace
    Edited by: kobyssh on 04:12 01/02/2010

  • How to save an XML file with a proper name and how to maintain the history?

    Hi All,
    As per the requirement, I have to remane the name of the XML file which is under the KM repository Userhome/personaldocuments based on the user logon information.
    I have created a Repository service for the same and following is the code for the same. The service is working, but only for the first entry in the XML form. Second onwards, the file does not get remaned to the preferred one.
    Request you to throw some light as what is wrong or missing in the code, so that I can follow the right approach. Many thanks in advance.
    // Code snippet is here//
    //Starts here//
    com.sap.security.api.IUser epUser;
                                            epUser = UMFactory.getAuthenticator().getLoggedInUser();
                                     String EntID = epUser.getUniqueName();
    IResourceContext resContext = null;
    try {
         resContext = ResourceFactory.getInstance().getServiceContext("cmadmin_service");
    } catch (ResourceException e1) {
              e1.printStackTrace();
    RID rid = RID.getRID("/userhome""/"EntID+"/Personal Documents");
    IResource resource = null;
    try {
         resource = (ResourceFactory.getInstance().getResource(rid, resContext));
    } catch (ResourceException e2) {
              e2.printStackTrace();
    ICollection collection = (ICollection)resource;
    IResourceList resourseList = null;
    try {
         resourseList = collection.getChildren();
    } catch (AccessDeniedException e3) {
              e3.printStackTrace();
    } catch (ResourceException e3) {
              e3.printStackTrace();
         for(int i=0;i<resourseList.size();i++){
              IResource res_new = resourseList.get(i);
                try {
                   res_new.rename("Address_new.xml");
              } catch (NotSupportedException e) {
                                  e.printStackTrace();
              } catch (AccessDeniedException e) {
                                  e.printStackTrace();
              } catch (ResourceException e) {
                                  e.printStackTrace();
    //Code ends here//
    Regards
    DK
    Edited by: DIPENDRA MOHANTY on Jun 5, 2009 5:20 PM

    Hi,
    The code seems ok.
    But you have mentioned about a KM Rep service, what service is that? which event it is listening to?
    Regards
    BP

  • How to "use" a xml file with a script?

    Hey Guys!
    I use the normal Button with the send-option to send the xml file to an url.
    My question is how it's possible to work in a php-script with the xml data out of the formular?
    Thanks for help.
    LG
    Adrian

    Hi,
    I need to read a XML document with StringReade class.
    My aplication receives an absolute path but this
    doesn't work:
    StringReader oStringReader =
    new StringReader(c:\java\libros.xml);
    However it works with:
    StringReader oStringReader =
    new StringReader("<?xml version="1.0" e......");
    ie, with the whole document as a String, but I need
    to do it as the frist way.
    Thankstake a look at this link:
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/2a_echo.html

  • How do you display xml file with xlst sheet in jsp

    I have an xml file with accompanying xslt file (and several images that are used in a single directory. If I doubleclick on the xml file, it displays perfectly in my browser - Formatting, images and all!
              The 100 dollar question - How do I duplicate this behavior in a JSP page in WebLogic 8.1 using the code in the xml and the accompanying xslt (formatting) file? I tried simple embedding the xml code in the jsp, but that didn't seem to work. What is the secret?
              Okay, I need to add a bit more information here. I understand that it is really easy to just redirect to the XML file. The issue is really security. I want the XML to be inside a jsp that will only allow validated users to view it.
              Another way to look at the problem would be, can I add a jsp security tag to the xml file? Or how to I add the xml code inside a jsp and keep the path references to the xslt and graphics.
              Hope the added information helps
              Thanks,
              Ken
              Message was edited by: KLee - 20050609 10:25 MST
              [email protected]

    This proved out to be the answer. Thanks for the direction!
              import java.io.File;
              import java.io.IOException;
              import java.io.InputStream;
              import java.io.OutputStream;
              import java.io.FileNotFoundException;
              import java.io.FileOutputStream;
              import javax.servlet.ServletException;
              import javax.servlet.http.HttpServlet;
              import javax.servlet.http.HttpServletRequest;
              import javax.servlet.http.HttpServletResponse;
              import javax.xml.transform.Transformer;
              import javax.xml.transform.TransformerConfigurationException;
              import javax.xml.transform.TransformerException;
              import javax.xml.transform.TransformerFactory;
              import javax.xml.transform.stream.StreamResult;
              import javax.xml.transform.stream.StreamSource;
              public class XML_XSLT_Servlet extends HttpServlet {
              protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
                        String xmlfile = req.getParameter("xmlfile"); if (xmlfile==null) xmlfile = "test.xml";
                        String xsltfile = req.getParameter("xsltfile"); if (xsltfile==null) xsltfile = "test.xslt";
                        /* Test if file exists!, or use default file */
                        File f1 = new File(getServletContext().getRealPath("WEB-INF/displayfiles/"), xmlfile);
                        File f2 = new File(getServletContext().getRealPath("WEB-INF/displayfiles/"), xsltfile);
                   if (f1.exists() && f2.exists()) {
                             // System.out.println("Files Found");
                        } else {
                             System.out.println("XML and XSLT Files NOT Found");
                             System.out.println(f1.getPath());
                             System.out.println(f1.getName());
                             xmlfile = "test.xml";
                             xsltfile = "test.xslt";
              InputStream fileXML = getServletContext().getResourceAsStream("WEB-INF/displayfiles/" + xmlfile);
              InputStream fileXSLT = getServletContext().getResourceAsStream("WEB-INF/displayfiles/" + xsltfile);
              OutputStream os = res.getOutputStream();
              TransformerFactory xFactory = TransformerFactory.newInstance();
              StreamSource stylesheet = new StreamSource(fileXSLT);
              Transformer xformer = null;
              try {
              xformer = xFactory.newTransformer(stylesheet);
              } catch (TransformerConfigurationException tfce) {
              tfce.printStackTrace();
              StreamSource input = new StreamSource(fileXML);
              StreamResult output = null;
              try {
              output = new StreamResult(os);
              } catch (Exception e) {
              e.printStackTrace();
              try {
              xformer.transform(input, output);
              } catch (TransformerException xfe) {
              xfe.printStackTrace();
              <pre></pre><pre></pre>

Maybe you are looking for

  • Choosing a value based on a report filter

    I need a bit of help improving a calculation in my model. Its a basic model, Orders FactTable, Items Dimension & Locaiton Dimension. For all locations the stdPrice is used, except for Location 3, where special price is used. How do i work this into m

  • Internet Connection

    Does anyone know how I can connect my ipod touch to the internet whilst I am out and about??? Message was edited by: leeutd24

  • Currency in PO??

    Hi All, Where do we get the currency in PO from? I think it should be from the vendor master. I have maintained currency in the vendor master but the same is not coming in the PO. Please let me know if I am going wrong somewhere.. Regards, V S

  • How do I transfer mov footage to premiere element 7

    HI I bought the canon 500d dslr camera and I'm unable to load it onto  my premiere. The codec is missing as the camera shoots in mov. Is it possible to convert  it so that it will work on premiere 7 Thanks

  • When i press the new tab button I land on yahoo. I hate yahoo, how do I change the landing page for the new tab button?

    When I pressed the new tab button, I use to land on google. I downloaded something that changed my new tab landing page. I now land on Yahoo. I hate yahoo!. How do I reset my landing page so I land on google when opening a new tab in Firefox.?