How to make xml validation with automatic error fixed

Hi', i have some string which i want to validate it:
String word = "<style>body {background-color:transparent}";     
byte[] bytes = word.getBytes();
InputStream inputStream = new ByteArrayInputStream(bytes);
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setValidating(true);                    
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
DOcument doc = docBuilder.parse(inputStream);This code will produce some exception like this:
Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired.  Parser will use a default ErrorHandler to print the first 10  errors.  Please call the setErrorHandler method to fix this.
Error: URI = "null", Line = "1", : Document root element "style", must match DOCTYPE root "null".
Error: URI = "null", Line = "1", : Document is invalid: no grammar found.
org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.Is there anyway to make this validation not only show the errors but automatic fix it?
Thanks a lot...

I mean there is no general method which is capable of correcting all possible errors found by schema validation.
For example if the validation says it expected to find an <organization> element or a <company> element but it found a <banana> element, there is no way to determine what repair is necessary.
Anyway the requirement is fighting against the way things work in the real world. The purpose of validation is just to find out whether a document matches a schema. If it doesn't, then too bad. Send it back to be fixed or replaced. If you are having a problem because you repeatedly get documents which don't quite match your schema, then you need to train the users to produce valid documents or to give them tools which help them do that.

Similar Messages

  • XML Validation with multiple XSD files (referenced)

    Hello,
    I know that XML validation with version 7.1 is possible now. However I was provided with a set of XSD files that have references to each other and need to be placed in a hierachical file system order so that references can be resolved.
    An element <xsl:include schemaLocation="../../baseSchemas/baseSchema.xsd" /> is used for example. How can I handle that for XSD validation in PI? Can I create the same folder structure or do I need to put all XSD files in one directory and change the import manually?
    But most important question: Is it possible it all to use more than one XSD for schema validation?

    Dear Florian,
    I had encountered such case in a project.
    I was given 3 files. One main file and 2 others called Schema1.xsd and Schema2.xsd.
    This happens because your data type is not in single namespace, but is being referred across namespaces and software components.
    I am assuming that you have read the How to Guide for XML validations on PI 7.1
    Best way to do this quickly is as follows.
    1. Enable XML validation at adapter engine in the sender agreement.
    2. Post a message using HTTP post. (http://sappihttpclient.codeplex.com)
    3. Check communication channel in runtime workbench. There will be an error saying which is missing at what path.
    4. Create the path mentioned and place the file at that path.
    5. Repeat steps 2,3,4 for all the files.
    When you are done with this, you will get a proper validation error in case XML file is not correct. And remember to generate XSD from message type and not data type.
    Regards,
    Vikas
    Edited by: Vikas Aggarwal on Sep 2, 2009 8:45 PM
    Edited by: Vikas Aggarwal on Sep 2, 2009 8:48 PM

  • How to disable xml validation

    I'm trying to write an SVG parser using Xerces. The problem is that when the SVG file contains the doctype tag <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">my program throws the following exception:
    java.net.UnknownHostException: www.w3.org
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
            at java.net.Socket.connect(Socket.java:507)
            at java.net.Socket.connect(Socket.java:457)
    etc.If I remove <!DOCTYPE> tag, it works fine. According to what I read here, it's necessary to disable XML validation. The Xerces API documentation says that there is a method setValidation() in org.apache.xerces.framework.XMLParser but I can't locate it. Moreover, I don't see any org.apache.xerces.framework package in Xerces supplied with NetBeans 5.0 nor in Xerces 2.8.0 downloaded from apache.org (the XMLParser class available to me is located in org.apache.xerces.parsers).
    My question is simple:
    How to disable XML validation if the setValidation() method is not avaliable
    OR
    how to make the setValidation method available to my program?
    I'm really confused :(
    Here is the code:
    package svgviewer;
    import java.io.File;
    import org.w3c.dom.*;
    import org.w3c.dom.traversal.*;
    import org.apache.xerces.parsers.*;
    public class SVGFileParser {
        public void parse(String filename) throws Exception {
            File file = new File(filename);
            DOMParser parser = new DOMParser();
            parser.parse(file.toURL().toString()); //exception is thrown if doctype tag is present in the svg file

    You're solving the wrong problem here. Turning off validation won't help, because DTDs don't only do validation. Even non-validating parsers have to read the DTD in case it contains entity definitions, for example.
    If you want to stop the parser from looking for the DTD then you write a EntityResolver and apply it to the parser. The EntityResolver should be just like the one in the example in the API docs except it should return new InputSource(new StringReader("")).

  • How to make this work with Firefox, HELP!

    Downloading for Real-player, after watching the full movie, I click download and it has to reread the movie from the internet. When using explorer, after downloading the movie, it reads it from memory, which makes it a fast download. How to make this work with Firefox, I like not to use Microsoft products, and I really like Firefox 7.0.1!!!! HELP!

    -> click '''Firefox''' button and click '''Options''' (OR File Menu -> Options)
    * Advanced panel -> Network tab
    * place Checkmark on '''Override Automatic Cache Management''' -> under '''Limit Cache''' specify a large size of space
    * Remove Checkmark from '''Tell me when websites asks to store data for offline use'''
    * click OK on Options window
    * Restart Firefox
    Check and tell if ts working.

  • How to make text columns with adobe muse

    Hi,How to make text columns with adobe muse (like InDesign)?

    Multiple columns can be acheived with CSS - http://www.w3schools.com/css/css3_multiple_columns.asp
    div
    -moz-column-count:3; /* Firefox */
    -webkit-column-count:3; /* Safari and Chrome */
    column-count:3;
    I'm surprised that Muse does not support text columns yet, but perhaps the custom CSS can be added in style tags on page properties. Haven't tried it, but don't see why it wouldn't work.

  • How to make turning page with ibooks author?

    How to make turning page with ibooks author?

    This question has been answered on this thread
    https://discussions.apple.com/message/17981772#17981772#17981772
    Best regards.
    Alex

  • How to validate xml file with XSD schema ??  in JDK1.4.2

    How to validate xml file with XSD schema ?? in JDK1.4.2
    i dont want to use new Xerec Jar ...
    Suggest option ...

    Please do not double-post. http://forum.java.sun.com/thread.jspa?threadID=5134447&tstart=0
    Then use Stax (Woodstock) or Saxon.
    - Saish

  • How to Integrate XML Pulisher with OAF

    Hi,
    How to Integrate XML Pulisher with OAF??
    Regards,
    Mayank,

    Hi,
    If you are using View Link then
    public XMLNode getPrintDataXML()//XMLNode
    OAViewObject vo = (OAViewObject)findViewObject("EmpVO1");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    XMLNode xmlNode = (XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS);
    return xmlNode;
    I hope this will fetch the data from View Link also.
    Regards,
    Reetesh Sharma

  • How to do file validation with ODI 10.1.3.5

    Hi Team,
    Please help me, how to handle file validation with ODI?
    My source is files.
    Requirement:
    With ODI i have to do the file validation and file data loading successfully. Once it is successfully done then i have to move the particular file and move to different directory.
    Any internal tool is there in ODI package to watch the file.
    Regards,
    Suresh

    Hi Suresh,
    You can do your file loading and validation in an ODI interface.
    Once you are done with the interface, add it to a package, you can set up subsequent steps in the package to move the file to another location using the built in ODI file utilities in the package.
    Terrence.

  • How to make email link with a button with AC2 in flash cs3?

    How to make email link with a button with AC2 in flash cs3?
    I wrote this, but it does not work:
    btn_emailinfo.on (release) {
    getURL("mailto:"[email protected]");
    }

    I am guessing you put that on a frame?
    If so, the syntax is as follows:
    btn_emailinfo.onRelease = function(){
    getURL("mailto:[email protected]");
    Though, if you are placing it directly on the button itself,
    the syntax is:
    on(release){
    getURL("mailto:[email protected]");
    }

  • How to make this validation ?

    Dear all
    In my Entity Object I have 4 attributes:
    ID , AccomplishDate ,cancelDate,Status
    I want to make a validation on the Status attribute , which is:
    if status = "CAN" then the CancelDate attribute value will be current date and the AccomplishDate attribute value be null.
    Please can any one tell me how to make this validation.
    Thanks

    Thank you so much for replaying
    The original method was
        public void setProcStatus(String value) {
                 setAttributeInternal(PROCSTATUS, value);
        }I changed it to be like this
          public void setProcStatus(String value) {
            if (value.equals("CAN")){
              setAccomplishDate(new Date());
              setCancelDate(null);
            setAttributeInternal(PROCSTATUS, value);
        }is this right
    please tell me how to set the value of AccomplishDate attribute to the current date

  • I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    It may be due to Continuity
    The following quote is from  Connect your iPhone, iPad, and iPod touch using Continuity
    Turn off iPhone cellular calls
    To turn off iPhone Cellular Calls on a device, go to Settings > FaceTime and turn off iPhone Cellular Calls.

  • In JSF, how to make a menu with access control?

    In JSF, how to make a menu with access control?
    The access control can be guided by programming, database or other means if possible?
    Thanks

    I want to make a dvd menu in iMovie because i don't have IDVD and can't find anywhere to download it?
    For making DVDs I would recommend iMovie 06 and iDVD 09 both readily available on Amazon or eBay.  Shop for iLife 06 and iLife 09.
    You can make menus and chapters with any version of iMovie except the latest one. There's nothing wrong with iMovie 11 either but I prefer iMovie 06.
    By using iMovie 06 and iDVD 09 I make DVDs with professional moving menus with very little effort. They look almost as good as Hollywood.

  • How to make slide images with Dreamweaver CS6?

    How to make slide images with Dreamweaver CS6? Please teach me.

    Hello
    in addition to Jon's hint, I'll send you some links to nice sliders (have fun with the different representations ):
    http://sandbox.scriptiny.com/javascript-slideshow/
    http://jquery.malsup.com/cycle/
    http://wowslider.com/best-jquery-slider-crystal-linear-demo.html
    http://www.jcoverflip.com/demo
    http://www.jacksasylum.eu/ContentFlow/
    http://addyosmani.com/blog/jqueryuicoverflow/
    You only need to use the source code to implant these shows there where you want. In my eyes it would be the best that you use first a very new and blank DW file to perform (maybe in LiveView) the one or the other.
    Hans-Günter

  • My backlight will not turn off automatically.  I have to manually turn it off and forget to sometimes and that drains my battery.  Does anyone know how to make it turn of automatically after a few seconds?

    My backlight will not turn off automatically.  I have to manually turn it off and forget to sometimes and that drains my battery.  Does anyone know how to make it turn of automatically after a few seconds?

    Use the Settings app.
    Settings > General > Auto Lock
    Is Auto Lock set to Never? Change it to less time.

Maybe you are looking for

  • AS2 Sender and receiver adapter.

    Hi All, I have to develop a scenario where i have to send/receive some GS1 messages to/from our trading partner using AS2 adapters. I have gone through some of the links and blogs realted to as2 adapters but still have some doubts. Request you to hel

  • Changing region on DVD player

    Hi, I am trying to watch a PAL dvd and I know there is a way to change the region but I can't figure it out, can some one plaese help me!!

  • Scripting Question's

    I am new to scripting so I would really appreciate any help. I am looking for a way to act on information gathered in the "get caller contact info" step. In particular I would like to be able to play different prompts and set different priority's bas

  • What provisions does the iPhone make to save battery, when the level drops?

    When I get the warning about my battery dropping under 20%, does the iPhone actually make smart provisions to keep it going for as long as possible? For example by reducing screen brightness, stopping push email, email checks, killing background acti

  • OVI Player Download

    Despite several pleading requests to Customer Care for assistance I cannot get OVI Player to download to. I am using windows 7 Home premium OS but every time I attempt to download OVI player I get to the final screen and the download fails. Any ideas