In Reply to : How to validate org.jdom.Document object using xsd: dvohra09

Hi All
I am creating org.jdom.Document object using constructor Document() and adding children using setRootElement(), setChildren() and addContent() methods. The children are objects of org.jdom.Element. If i want to validate the org.jdom.Document using xsd what i have to do. Thanks in anticipation.

I tried the below code and it is always giving the
Parsing fatal error : The markup in the document preceding the root element must be well-formed.
But it is possible to validate the same Document object as right document after writing it onto xml file using XMLOutputter and parsing it using DOMParser
Thanks in anticipation
org.jdom.Document document;
String documentString=document.toString();
StringReader stringReader=new
StringReader(documentString);
SAXBuilder saxBuilder =new
SAXBuilder("org.apache.xerces.parsers.SAXParser",true);
saxBuilder.setFeature("http://xml.org/sax/features/vali
ation",  true);
saxBuilder.setFeature("http://apache.org/xml/features/v
lidation/schema",  true);
saxBuilder.setFeature("http://apache.org/xml/features/v
lidation/schema-full-checking", true);
//Set a error handler with
setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
saxBuilder.build(stringReader);

Similar Messages

  • Covert org.jdom.Document to org.w3c.dom.Document

    Hello,
    How would I convert org.jdom.Document to org.w3c.dom.Document??
    I'm creating org.jdom.Document from the servlet that reads from the database, which gets output like following.
    // doc is org.jdom.Document
    Document doc = new Document( root );
    reportName = new Element( "REPORT_NAME" );
    root.addContent( reportName );
    reportName.setText( "Current Account Balance" );
    // skip...
    XMLOutputter outputter = new XMLOutputter(" ", true, "UTF-8");
    outputter.output(doc, out);
    And in my caller servlet, I read from the previous servlet using URL and parse it, trying to get Document, but it
    InputSource xmlSource = new InputSource( url.openStream());
    //Use a DOM Parser (org.apache.xerces.parsers.DOMParser)
    DOMParser parser = new DOMParser();
    parser.parse( xmlSource );
    Document doc = parser.getDocument();
    // and I do transformation.
    DOMSource inXML = new DOMSource( doc );
    StreamResult outXML = new StreamResult( out );
    transformer.transform( inXML, outXML )
    I'd like to skip passing around XML and share the same Document object so that I don't have parse it again...
    Help!

    Convert jdom document to dom document with class DOMOutputter.
    org.jdom.output.DOMOutputter domOut=new DOMOutputter();
    org.w3c.dom.Document domDocument=domOut.output(org.jdom.Document jdomDocument);

  • How to convert org.dom4j.Document into org.w3c.dom.Document  ?

    Hi,
    I have done googling for how to convert org.dom4j.Document into org.w3c.dom.Document , but could not get any usefull data.
    If any one is having solution or any idea, please reply.
    Thanks in advance
    <!--Session data-->

    Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

  • Java.lang.LinkageError: Class org/jdom/Document

    I run my program in developemnt its working... but its working in production it throws these below mention error.... Any one help me to olve this problem.....
    Exception : java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
         java.rmi.RemoteException: ; nested exception is:
         java.lang.LinkageError: Class org/jdom/Document violates loader constraints: parent and child already loaded different classes

    What program is this? Something you wrote in Java? If so, you're posting to a forum that can't help you. We deal with Messagng Server here, not Java programming. . .

  • How to validate an text field item using javascript for numbers only.

    hi,
    how to validate an text field item using javascript for numbers only.please help me on this urgent
    please mail me solun if posible on [email protected]

    Hi,
    Page HTML header
    <script>
    function onlyNum(evt) {
      // Usage: onKeyPress="return onlyNum(event)"
      evt = (evt) ? evt : window.event;
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        var status = 'This field accepts numbers only!';
        alert(status);
        return false;
      var status = '';
      return true;
    </script>Item HTML Form Element Attributes
    onKeyPress="return onlyNum(event)"Br,Jari

  • I have file with 500 pages created from AutoCad file. In all pages, I have different document numbers.The file is not editable in pdf. How to change all the document numbers using "Comment" feature? Any alternate method?  alternate method? I have Adobe Ac

    I have pdf file with 500 pages created from AutoCad file. In all pages, I have different document numbers.The file is not editable in pdf. How to change all the document numbers using "Comment" feature? Any alternate method?  alternate method? I have Adobe Acrobat X Pro and Windows -7 platform.

    Yes, I just want to cover up all the pages for those particular area of document numbers.
    Nothing sensitive about it. I just want to show the correct document numbers on all pages in print out.
    So, I wanted to cover up by comments, but commenting on each page will be difficult. So, I wanted to comment the same on all pages.

  • How / can I have jpg logo objects used on reports automatically updated

    How / can I have jpg logo objects used on reports automatically updated after making changes to the repository copy of the jpg logo object in the repository?   The reports are in the enterprise items folder of the repository and the logo.jpg file is in a subfolder of repository items.  I made changes but the changes seem to apply only after I set my options in crystal reports and open the actual rpt file itself. 
    Is there a way to have the changes to the logo show / apply in all reports that have the repository item logo inserted into it without having to open every rpt file in the repository?

    Yes, I understand that...  the problem I was having was that check box being unchecked whenever an unrelated change was made to rpt file...  I was able to ensure that it remained checked by doing save as to the rpt file and making sure the "enable repository refresh" box was checked and replacing the file when prompted upons saving the rpt file...

  • How to validate generated XML-Document in Memory by XML-Schema?

    Hi all!
    I have the following problem:
    I am generating a Document using the DOM delivered with Xerces 2.6.2.
    Before I'll send the generated xml-document through network to another system I have to check with my xml-schema if the document is correct.
    In the DOM-FAQ I found an "example" trying to explain how it should work. But with this example the problems begin.
    I am creating my document with this method:
         public void createDocument() {
              myDOM = DOMImplementationImpl.getDOMImplementation();
              doc = myDOM.createDocument("", "documentData", null);
              root = doc.getDocumentElement();
              root.setAttribute(
                   "xmlns:xsi",
                   "http://www.w3.org/2001/XMLSchema-instance");
              //          root.setAttribute("xsi:noNamespaceSchemaLocation", "myScheme.xsd");
              domConfig = ((DocumentImpl) doc).getDomConfig();
              domConfig.setParameter(
                   "schema-location",
                   "file:///d:/workspace/XMLProject/WebContent/WEB-INF/myScheme.xsd");
              domConfig.setParameter("error-handler", new EHandler());
              domConfig.setParameter("validate", Boolean.TRUE);
         }In the line getting the domConfig, it is getting differeing to the example: The example is like this:
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMConfiguration;
    import org.w3c.dom.ls.LSParser;
    Document document = builder.parseURI("data/personal-schema.xml");
    DOMConfiguration config = document.getConfig();
    config.setParameter("error-handler",new MyErrorHandler());
    config.setParameter("validate", Boolean.TRUE);
    document.normalizeDocument();They get the DOM-Configuration from the document-Object, but my document-Object has no "getConfig()" and only after type-casting I get a getDomConfig()-Method to get the configuration.
    Then I fill my document and call                
    ((DocumentImpl) doc).normalizeDocument();When I run my Application I get the following error:
    org.w3c.dom.DOMException: FEATURE_NOT_SUPPORTED: The parameter schema-location is recognized but the requested value cannot be set.
         at org.apache.xerces.dom.DOMConfigurationImpl.setParameter(Unknown Source)
         at xmlProject.createDocument(Convert.java:63)
         at xmlProject.Convert.main(Convert.java:154)I tried several ways to get the validation without success.
    The next question is how I should refer to my xml-schema (which path) and where to place it relative to my jar I will generate, because I will have no webserver I could place it on.
    Has anyone any experience with validating a document created and not placed on disc?
    I have also another question to SAX: I read, that it is reading a document without saving it in the memory. I think this means that if I am validating it by SAX it will be read once and for parsing it will be read a second time. If I would transfer the document over an tcp-connection, I only have the document once in my inputstream and after validation it would be consumed I think. But what can I parse then? Or did I missed a detail with the function of the SAX?
    Thank you for your help!
    Yours
    Christian

    static final String schemaSource = argv[0];
    static final String JAXP_SCHEMA_SOURCE =
    "http://java.sun.com/xml/jaxp/properties/schemaSource";
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    factory.setAttribute(JAXP_SCHEMA_SOURCE,
    new File(schemaSource));

  • How to list an array of objects using struts in jsp and ActionForm

    I am using the struts ActionForm and need to know how to display an Array of objects. I am assuming it would look like this in the ActionForm:
    private AddRmvParts addRmv[];
    But I am not sure how the getter and setter in the ActionForm should look. Should it be a Collection or an Iterator?
    I am thinking I need to use an iterator in the jsp page to display it.
    I am also wondering if the AddRmvParts class I have can be the same class that gets populated by the retrieval of data from the database. This class has 10 fields that need to display on the jsp page in 1 row and then multiple rows of these 10 fields.
    Thanks.

    Most probably the easiest way to make it accessible in your page is as a collection.
    ie
    public Collection getAddRmvParts()
    You can use the <logic:iterate> or a <c:forEach>(JSTL) tag to loop through the collection
    As long as the individual items in the collection provide get/set methods you can access them with the dot syntax:
    Example using JSTL:
    <c:forEach var="addRmvPart" items="${addRmvParts}">
      <c:out value="${addRmvPart.id} ${addRmvPart.name} ${addRmvPart.description}"/>
    </c:forEach>

  • How to set-up change document object for deliveries??

    Hi experts ,
    kindly help me with this config , I did some researched and none of them have solve my problem.
    i need to know on how to set-up a change document object for delivery documents.
    Change document object LIEFERUNG is not available in transaction SWED.
    How will I add this change document object in SWED?

    hi ,
    im wondering why even the existing object VERKBELEG is not being triggered?
    would you know any reason for this?

  • How can we create an entity object using multiple tables?

    Hi All,
    I'm a newbie to OAF.
    I'm trying to create a simple page using OAF.
    While creating Entity object, there is an option to add the database objects from which we can create our Entity Object.
    There we can enter only one database object.
    If suppose I need to create a Entity object by using mutiple data base objects, how can I add other database objects?
    Is there any option for multiple selection of database objects there?
    Thanks in Advance

    User,
    a). You should use the [url http://forums.oracle.com/forums/forum.jspa?forumID=210]OA Framework Forum for this question.
    b). Entity objects always correspond to a single table. I think you want to create a View object instead.
    c). Really, you want to be using the OA Framework forum.
    John

  • How do you track a moving object using Labview and Vision Assistant

    I am using Vision and Labview to create a program that tracks and follow a moving object using a high end camera. Basically what it does is it detects a foreign object and locks on to it and follows it where ever it goes in a control sized room.
    I have no idea how to do this. Please help. Or is there an available example.
    Thanks.

    Hello,
    It sounds like you want to look into a Vision technique called Pattern Matching.  Using our Vision tools, you can look for a image, called a template, within another image.  Vision will scan over the entire image of interest trying to see if there are any matches with the template.  It will return the number of matches and their coordinates within the image of interest.  You would take a picture of the object and use it as the template to search for.  Then, take a picture of the entire room and use pattern matching to determine at what coordinates that template is found in the picture.  Doing this multiple times, you can track the movement of the object as it moves throughout the room.  If you have a motion system that will have to move the camera for you, it will complicate matters very much, but would still be possible to do.  You would have to have a feedback loop that, depending on where the object is located, adjusts the angle of the camera appropriately.
    There are a number of different examples a that perform pattern matching.  There are three available in the example finder.  In LabVIEW, navigate to "Help » Find Examples".  On the "Browse" tab, browse according to "Directory Structure".  Navigate to "Vision » 2. Functions".  There are examples for "Pattern Matching", "Color Pattern Matching", and "Geometric Matching".  There are also dozens of pattern matching documents and example programs on our website.  From the homepage at www.ni.com, you can search in the top-right corner the entire site for the keywords, "pattern matching". 
    If you have Vision Assistant, you can use this to set up the pattern matching sequence.  When it is complete and customized to your liking, you can convert that into LabVIEW code by navigating to "Tools » Create LabVIEW VI..."  This is probably the easiest way to customize any type of vision application in general.
    I hope this helps you get started.  Take care and good luck!
    Regards,Aaron B.
    Applications Engineering
    National Instruments

  • How to add CustomProperties to Excel object using BIPlatform service?

    Hallo,
    I got a Excel Info object using BIPlatform.Get method as follow
    ResponseHolder rh = mPlatformService.Get("path://InfoObjects/Root Folder/fileName/", null);
    Excel obj = (Excel)rh.InfoObjects.InfoObject[0];
    But how can I add Custom properties and them save them back in Server?

    Not available/supported in any of our SDK's.

  • Validate org.w3c.dom.Element against xsd

    I need to validate a org.w3c.dom.Element against an xsd.
    DOMParser dp = new DOMParser();
    URL xmlurl = new URL("file:\\test.xml");
    XSDBuilder builder = new XSDBuilder();
    URL xsdurl = new URL("file:\\test.xsd");
    XMLSchema schemadoc = (XMLSchema)builder.build(xsdurl);
    dp.setXMLSchema(schemadoc);
    dp.setValidationMode(XMLParser.SCHEMA_LAX_VALIDATION);
    dp.setPreserveWhitespace(true);
    dp.setErrorStream (System.out);
    System.out.println("Parsing "+xmlurl);
    dp.parse(xmlurl);
    This works when my input is an xml file. I cannot get it work against an element. If I convert the element as a string or inputsource it gives the error
    "XML-20220: (Fatal Error) Invalid InputSource.
    java.net.MalformedURLException: no protocol:"
    Any idea how it can be done? I am using jdeveloper 10.1.2
    Thanks
    MM

    Thanks for the reply. I get the following error.
    Exception in thread main
    oracle.xml.parser.v2.XMLDOMException: cannot add a node belonging to a different document
    at oracle.xml.parser.v2.XMLNSNode.checkNodePermissions(XMLNSNode.java:854)
    at oracle.xml.parser.v2.XMLNSNode.appendChild(XMLNSNode.java:257)
    at oracle.xml.parser.v2.XMLDocument.appendChild(XMLDocument.java:1010)
    at test.parser.ParseTest.parse1(ParseTest.java:136)
    at test.parser.ParseTest.main(ParseTest.java:63)
    Process exited with exit code 1.
    This is my code
    public void parse1(Element elem) {
    try{
    //Element docElement;
    //Node elemNode=(Node)docElement;
    DOMParser dp1 = new DOMParser();
    XMLDocument xmlDocument=new XMLDocument();
    xmlDocument.appendChild(elem);
    ByteArrayOutputStream docOutputStream = new ByteArrayOutputStream();
    xmlDocument.print(docOutputStream);
    ByteArrayInputStream docInputStream = new ByteArrayInputStream(docOutputStream.toByteArray());
    InputSource inputSource = new InputSource(docInputStream);
    dp1.parse(inputSource);
    catch (IOException e){e.printStackTrace();}
    catch (XMLParseException e){e.printStackTrace();}
    catch (SAXException e){e.printStackTrace();}
    Thanks
    MM

  • How to validate the  select box (combobox)  using the danavalidator

    i have a select box in my jsp . the type is String
    i have been using the validator-rules.xml ,validation.xml
    my question is is there any built in method for validatining the select box
    like "required " or else
    give me some solutions

    I am not sure what is danavalidator. But if you are using Struts, then you can use the required validation same like you use for text fields. It will validate for the option whose value is blank. select box required validation is present in the validation-rules.xml.
    Thanks

Maybe you are looking for

  • ICal events are missing Day and Month in date

    Hello, Sorry if this has been addressed elsewhere - this is such a weird fault I was not sure how to search for it. My iCal events are missing the Day and Month in their start and end dates - it just shows a 4 digit year which can only be edited as a

  • A general purpose TV tuner driver or software for SL?

    I have a tv tuner card which is windows compatible and I would like to use it with my mac. this... http://entermultimedia.com/tvtuner_external_usb210U.html is the one. Is there like a general purpose tv tuner driver for mac?

  • Re: Routing download to SAP ME from ECC

    Hello Friends, When a routing for a material from SAP ECC is sent again to SAP ME, it creates a new version of routing. Is it possible to make a check during routing download if a routing with the same number exists in ME or not. And if it exists the

  • Attachments to Campaign

    Hi , ICWC we have a manager portal and Agent portal. If manager attach documents or url to Campaign in marketing planner screen.How agent can view the attachments in Agent portal. In agent portal we dont have any marketing planner screen, whereas it

  • Problems uploading class files to web server

    Regular class files upload fine(to yahoo geocities) but when I try to upload multiple class files of the same instance(ex: MyProg.class, MyProg1$.class, MyProg1$2.class) the ones with the $ symbols wont upload therefore rendering my applet on my webs