XML validation using javax.xml.validation

Hello,
I am trying to validate some xml against my xsd.
Here is my xml:
<host>
    <status>Unknown</status>
</host>Here is my xsd:
<?xml version="1.0"?>
                                                                                                                                                             <xsd:schema targetNamespace="blah"
        xmlns:tns="blah"
        xmlns:xsd="blah">
<xsd:simpleType name="Status">
<xsd:restriction base="xsd:string">
  <xsd:enumeration value="Unknown"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="host">
   <xsd:complexType>
     <xsd:all>
       <xsd:element name="status" type="tns:Status"/>
     </xsd:all>
   </xsd:complexType>
</xsd:element>
                                                                                                                                                             </xsd:schema>My test code is:
        try
            DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document document = parser.parse(new File("test.xml"));
            // Create a SchemaFactory capable of understanding WXS schemas.
            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            // Load a WXS schema, represented by a Schema instance.
            StreamSource schemaFile = new StreamSource(new File("schema.xsd"));
            Schema schema = factory.newSchema(schemaFile);
            // Create a Validator object, which can be used to validate the document
            Validator validator = schema.newValidator();
            // Validate the DOM tree.
            validator.validate(new DOMSource(document));
        catch(Exception e)
            fail("XML validation failed: " + e.getMessage());
        }I get the following error:
ERROR: 'cvc-elt.1: Cannot find the declaration of element 'host'.'
If i replace "type=tns:Status' in the "status" element with just "type=string", it works fine.
Does anyone have any idea what the problem is?
Thank you,
David

To daft_davy:
1. Your XSD document is invalid: the xmlns attribute of schema documents must always have the following value: "http://www.w3.org/2001/XMLSchema"
All other values will result in the following validation error:
org.xml.sax.SAXParseException: s4s-elt-schema-ns: The namespace of element 'schema' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
Your XSD should look like this:
<?xml version="1.0"?>
<xsd:schema targetNamespace="blah" xmlns:tns="blah" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:simpleType name="Status">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="Unknown"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:element name="host">
    <xsd:complexType>
      <xsd:all>
        <xsd:element name="status" type="tns:Status"/>
      </xsd:all>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>2. Your XML document does not match the XSD schema (even if you use the one above) for the following reasons:
a) The root element of the XML document must be associated with the namespace defined by the targetNamespace attribute of the schema.
b) The "blah" namespace at the element <status> in the XML document has to be undeclared because there is no namespace declaration to this element in the schema document either. There are to ways to do this:
<host xmlns="blah">
  <status xmlns="">Unknown</status>
</host>or:
<xxx:host xmlns:xxx="blah">
  <status>Unknown</status>
</xxx:host>
To watertownjordan:
The namespace URI can be virtually any string, so you don't need to specify a valid URI to define a namespace.

Similar Messages

  • Writing XML file using javax.xml package

    I am writing an XML file with the foll piece of code:
    public static void writeXmlFile(Document doc, String filename) {
    try {
    // Prepare the DOM document for writing
    Source source = new DOMSource(doc);
    // Prepare the output file
    File file = new File(filename);
    Result result = new StreamResult(file);
    // Write the DOM document to the file
    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    xformer.transform(source, result);
    } catch (TransformerConfigurationException e) {
    } catch (TransformerException e) {
    In this case above, the whole Document has to be passed to create a new DOMSource. is there any way where in I can pass the individual Nodes to the DOMSource ?
    I want the Nodes to be written one by one as writing the whole document is giving me a OutOfMemoryError (I have about a million records to be written in the XML file).
    Any help would be greatly appreciated

    I am writing an XML file with the foll piece of code:
    public static void writeXmlFile(Document doc, String filename) {
    try {
    // Prepare the DOM document for writing
    Source source = new DOMSource(doc);
    // Prepare the output file
    File file = new File(filename);
    Result result = new StreamResult(file);
    // Write the DOM document to the file
    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    xformer.transform(source, result);
    } catch (TransformerConfigurationException e) {
    } catch (TransformerException e) {
    In this case above, the whole Document has to be passed to create a new DOMSource. is there any way where in I can pass the individual Nodes to the DOMSource ?
    I want the Nodes to be written one by one as writing the whole document is giving me a OutOfMemoryError (I have about a million records to be written in the XML file).
    Any help would be greatly appreciated

  • How to create new XML file using retreived XML content by using SAX API?

    hi all,
    * How to create new XML file using retreived XML content by using SAX ?
    * I have tried my level best, but output is coming invalid format, my code is follows,
    XMLFileParser.java class :-
    import java.io.StringReader;
    import java.io.StringWriter;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMResult;
    import javax.xml.transform.sax.SAXSource;
    import javax.xml.transform.sax.SAXTransformerFactory;
    import javax.xml.transform.sax.TransformerHandler;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.XMLFilterImpl;
    public class PdfParser extends XMLFilterImpl {
        private TransformerHandler handler;
        Document meta_data;
        private StringWriter meta_data_text = new StringWriter();
        public void startDocument() throws SAXException {
        void startValidation() throws SAXException {
            StreamResult streamResult = new StreamResult(meta_data_text);
            SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
            try
                handler = factory.newTransformerHandler();
                Transformer transformer = handler.getTransformer();
                transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                handler.setResult(streamResult);
                handler.startDocument();
            catch (TransformerConfigurationException tce)
                System.out.println("Error during the parse :"+ tce.getMessageAndLocation());
            super.startDocument();
        public void startElement(String namespaceURI, String localName,
                String qualifiedName, Attributes atts) throws SAXException {
            handler.startElement(namespaceURI, localName, qualifiedName, atts);
            super.startElement(namespaceURI, localName, qualifiedName, atts);
        public void characters(char[] text, int start, int length)
                throws SAXException {
            handler.characters(text, start, length);
            super.characters(text, start, length);
        public void endElement(String namespaceURI, String localName,
                String qualifiedName) throws SAXException {
            super.endElement("", localName, qualifiedName);
            handler.endElement("", localName, qualifiedName);
        public void endDocument() throws SAXException {
        void endValidation() throws SAXException {
            handler.endDocument();
            try {
                TransformerFactory transfactory = TransformerFactory.newInstance();
                Transformer trans = transfactory.newTransformer();
                SAXSource sax_source = new SAXSource(new InputSource(new StringReader(meta_data_text.toString())));
                DOMResult dom_result = new DOMResult();
                trans.transform(sax_source, dom_result);
                meta_data = (Document) dom_result.getNode();
                System.out.println(meta_data_text);
            catch (TransformerConfigurationException tce) {
                System.out.println("Error occurs during the parse :"+ tce.getMessageAndLocation());
            catch (TransformerException te) {
                System.out.println("Error in result transformation :"+ te.getMessageAndLocation());
    } CreateXMLFile.java class :-
    Sax.startDocument();
    Sax.startValidation();
    Sax.startElement("", "pdf", "pdf", new AttributesImpl());
    Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());          
    String xmp_str = new String(meta_data.getByteArray(),"UTF8");
    char[] xmp_arr = xmp_str.toCharArray();
    Sax.characters(xmp_arr, 0, xmp_arr.length);
    Sax.endElement("", "pdf", "pdf");
    Sax.endValidation();
    Sax.endDocument();
    Sax.endElement("", "basic-metadata", "basic-metadata");* In CreateXMLFile.java
    class, I have retreived the xml content in the meta_data object, after that i have converted into character array and this will be sends to SAX
    * In this case , the XML file created successfully but the retreived XML content added as an text in between basic-metadata Element, that is, retreived XML content
    is not an XML type text, it just an Normal text Why that ?
    * Please help me what is the problem in my code?
    Cheers,
    JavaImran

    Sax.startDocument();
    Sax.startValidation();
    Sax.startElement("", "pdf", "pdf", new AttributesImpl());
    Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());          
    String xmp_str = new String(meta_data.getByteArray(),"UTF8");
    char[] xmp_arr = xmp_str.toCharArray();
    Sax.characters(xmp_arr, 0, xmp_arr.length);
    </code><code>Sax.endElement("", "basic-metadata", "basic-metadata");</code>
    <code class="jive-code jive-java">Sax.endElement("", "pdf", "pdf");
    Sax.endValidation();
    Sax.endDocument();     
    * I HAVE CHANGED MY AS PER YOUR SUGGESTION, NOW SAME RESULT HAS COMING.
    * I AM NOT ABLE TO GET THE EXACT OUTPUT.,WHY THAT ?
    Thanks,
    JavaImran{code}

  • XML validation using Oracle XML parser v2

    Not sure if this is the right forum for this question as I didn't found any.
    I had a tough time trying to build an XMLSchema (Oracle XML Parser V2) object from the input schema having include/import. Actually I am working on a Java program to validate the input xml with input schema using Oracle XML parser v2 api.
    The issue is that the code doesn't work for schema that has some "include" in it. The code is working fine for the schema without any import/include. Here is the lines of code -
    XSDBuilder builder = new XSDBuilder();
    schema = builder.build(new InputSource(xsdReader));
    I am writing this in JDeveloper. The error is -
    oracle.xml.parser.schema.XSDException: Can not build schema 'http://www.fpml.org/2005/FpML-4-2' located at 'xsd\FpML42\xml\fpml-fx-4-2.xsd'
    I also tried creating the EntityResolver to specify the path of included schema. But that doesn't solves the problem.
    I am not sure whether parser is able to locate the included schema or not.The main schema and included schema are all in same folder. The included schema is perfectly fine and has no errors.
    Please help if you have encountered this issue and resolved it. I will really appreciate any pointers or clue to solve this issue.
    Thanks.

    Thanks for the reply. But it does not seem to be working. Am I missing something
    I put <TrxDate xsi:nil="true"/> but still getting error.
    Here's my xsd:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xsd:element name="TrxDate" type="xsd:date" nillable="true" />
    XML:
    <?xml version="1.0" encoding="UTF-8" ?>
    <ServiceRequest>
    <TrxDate nil="true"/>
    </ServiceRequest>

  • How do I marshall a list using javax.xml.bind.annotation?

    Hopefully this is so simple a cave man could do it.
    I had to remove the Duke Stars for the time being. I found another bug in the program that may have resulted in my array being empty.
    I'm trying to marshall a standalone document of my DeckImpl class. It is a deck of cards of course. It contains an array of CardImpl objects that need to be marshalled too. I could not figure out how to marhall the array so I have a marshall(Marshaller m) method that will
    initialize the List (see below) with an ArrayList. I figured the marshaller would do the rest but I just get the declaration and a closed <DECK />tag with the correct attributes (see way below) when I comment out the @XmlElementWrapper, or a DECK root node that simply contains a closed <CARDS /> tag with the line enabled. You can see tha CardImpl class is annotated too.
    I must be missing something obvious. Please help.
    @XmlRootElement(name = "DECK")
    @XmlType(name = "DECK")
    public class DeckImpl implements Comparable<DeckImpl> {
        @XmlAttribute
        public int id;
        @XmlAttribute
        public boolean isShuffled;
        @XmlAttribute
        public boolean isCut;
        public CardImpl[] cards;
        @XmlElementWrapper(name="CARDS")
        @XmlElements(@XmlElement(name="CARD",type=CardImpl.class))
        public List<CardImpl> CARDS;
        private static JAXBContext context;
        private static Marshaller marshaller;
    public DeckImpl(int id, boolean isCut, boolean isShuffled,
                CardImpl[] cards) {
            this.id = id;
            this.isShuffled = isShuffled;
            this.isCut = isCut;
            this.cards = cards;
            try {
                context = JAXBContext.newInstance(DeckImpl.class);
                marshaller = context.createMarshaller();
            } catch (JAXBException ex) {
                Logger.getLogger(CardImpl.class.getName()).log(Level.SEVERE, null, ex);
    //... class code goes here
    /** Generates XML representation of a deck
         * @param writer
         * @throws javax.xml.bind.JAXBException
        public void marshall(Writer writer) throws JAXBException {
            CARDS = new ArrayList<CardImpl>(cards.length);
            for (CardImpl i : cards) {
                CARDS.add(i);
            marshaller.marshal(this, writer);
    @XmlType(name = "CARD")
    public class CardImpl implements Comparable<CardImpl> {
        @XmlElement(name = "NAME")
        public String name;
        @XmlElement(name = "SUIT")
        public String suit;
        @XmlAttribute
        public int value;
        @XmlAttribute
        public int pointValue;
    //... class code
    }The output is:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><DECK isCut="false" isShuffled="true" id="1"/>Regards,
    Bill
    Edited by: bthayer on Jan 24, 2009 7:15 AM
    Edited by: bthayer on Jan 25, 2009 7:02 AM

    There's a bit in here on marshalling.
    http://java.sun.com/webservices/docs/1.4/tutorial/doc/index.html
    Problem with JAXB (and I could be wrong - try posting on the Web Services / XML forum) is that you can only marshal the generated classes. This may mean that you need to create the object, and populate it using the setter / getter methods.
    Castor is much more friendly for this as it can marshall objects using reflections. You may also want to look into XMLBeans (which I have no exp of)

  • Can we use javax.xml.parser API's from j2sdk kit?

    Hi All,
    I am new to this jaxp API's and my first doubt is Can I use the javax.xml.parser API which come bundled with j2sdk-1.4.1 or Should I install JWSDP-1.3 to get to javax.xml.parsers API?
    Thanks

    Hi,
    I am trying to read an xml file on Solaris.
    Can we not use doc.getElementById(String elementID) after deriving doc obejct ?
    Here is the code I am trying to use:
    try
    factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(false);
    File file = new File("/command/parse_doc.xml");
    doc = factory.newDocumentBuilder().parse(file); //upto here it works
    Element element = doc.getElementById("Topics");
    String name = element.getTagName(); //returns nothing but throws exception "null"
    }catch(Exception exe){
    out.println("Exception:" + exe.getMessage());}
    here I get no such element, and the try catch block exception also null.
    Is there something I am missing?
    DO I have to call doc.getDocumentElement() before I call get ElementBy ID() and if so why?
    Thanks.

  • Webservices using xmlrpc which uses javax.xml package

    Hi
    Can any one Tell me how to write a Webservice using xmlrpc
    but which doesnt have org.apache or either helma package or jars
    I need to achieve it using j2ee jars
    eg: javax.xml.rpc
    I dont want SOAP to be involved in it.....
    Can any one tell me the useful links or sample code related to this topic
    Thank you
    Geetanjalee

    HI Geetanjale,
    If you aren't going to use SOAP as your message exchange protocol, then you can't do it with WS.
    Cheers
    Sai Pradeep

  • Guide Lines to Use SAX,DOM using javax.xml. * files only, I

    Hi Respected Recievers,
    My Name is Surya, i am working as a Java
    Programmer.
    I need JAR files to run SAX and DOM properly.
    I don't want to Use xerces.jar or jaxp.jar files, i will use only javax.xml.* files only.
    Could provide some examples on those topics like reading,modifying,the files using SAX and DOM.
    Thanks&Regards
    Surya

    Add rt.jar to Classpath.
    DOM Tutorial
    http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXPDOM3.html
    SAX tutorial
    http://java.sun.com/j2ee/1.4/docs/tutorial-update2/doc/JAXPSAX.html

  • VB6 & XML Datasource using Native XML Driver

    We used to use reports that used ADO XML dataset, and in VB 6 we easily told the report which XML file to use by:
    Dim objCRReport As CRAXDRT.Report
    Set objCRReport = objCRApplication.OpenReport(App.path & "\crystal\" + rptName)
    objCRReport.DiscardSavedData
    objCRReport.Database.Tables.Item(1).Location = xmlFile
    where xmlFile was the fully qualified path to the xml data to pass to the report.
    Now we are trying to do this with a new report which uses a XML Native driver as its connection method. In VB6, how can we pass different xml files to use?
    We looked at objCRReport.Database.SetDataSource, but it expects some parameters that I don't understand ( data , { data type } , { table number  } )
    Is there an example anywhere of how to switch your datasource in code while using the XML Native Driver?

    See [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] note.
    I would also recommend that you read the following regarding distribution of the runtime. This is important as the xml driver (crdb_xml.dll) uses Java:
    Apart from the regular deployment procedure for COM/RDC/NET applications, you have to follow the additional below-given steps in the client machines.
    Install the Java (JVM) 2 Runtime Environment (this is essentially the Java Framework needed to launch the crdb_xml native driver 1.4.2 from the java sun web site at:
    http://java.sun.com/j2se/1.4.2/download.html.
    Create a java folder inside the " C:Program FilesBusiness ObjectsCommon3.0";.
    Copy over the Crconfig.xml(C:Program FilesCommon FilesBusiness Objects3.0java) file from the development machine to the deployed machine in at the following path "C:Program FilesCommon FilesBusiness Objects3.0java" path. Open the crconfig.xml ; this file in Notepad and search for the line <JavaDir>. If JRE is installed to C:Program FilesJavaj2re1.4.2_12 in then the value should be look like this <JavaDir> C:Program FilesJavaj2re1.4.2_12 in</JavaDir>.
    Create a folder called lib in the "C:Program FilesCommon FilesBusiness Objects3.0java".
    Copy over the entire contents of the lib folder (especially the external folder) from the development machine to the newly created lib machine on the deployed machine. The point of this is to ensure that the crconfig.xml file contains all the files here which exist at the correct path which they now should because we copied over the lib and external directories.
    Copy crdb_xml.dll, crdb_xml_res_en, and all the files with "crdb_xml_res_xx from your development machine to the deployment machine (C:Program FilesCommon FilesBusiness Objects3.0 in).
    Restart your machine and try accessing your web application. The reports will show up the data without any issue.
    The above is written for CR XI release 1. You may have to adjust the path given above as you do not specify the version of Crystal reports you are using.
    Ludek

  • ClassCastException when using javax.xml.soap.DetailEntry

    I am using the Java Web Services development pack and I'm getting a ClassCastException when trying to use a DetailEntry object.
    My code is basically as follows:
    SOAPFault fault = responseSoapBody.getFault();
    Detail detail = fault.getDetail();
    Iterator iterator = detail.getDetailEntries();
    DetailEntry entry = (DetailEntry)iterator.next(); //exception!!
    Exception:
    java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.dom4j.TextImpl
    The object being returned from the Iterator seems to be a TextImpl. In my CLASSPATH are the jars in the lib directory under <JWSDP>\jwsdp-1_0_01\common\lib.
    Any idea why I'm getting this Exception? Is this a bug in the JWSDP, or in my code?
    Thanks...

    You post has been forwarded to the SAAJ person as it seems
    like a SAAJ exception ... u should be hearing from the
    individual soon
    asengup

  • What changes i should made in web.xml for using jsp/xml using weblogic

    Hi all,
    I just know some changes has to made in web.xml or weblogic.xml if i have to use weblogic for jsp/xml.
    Pls. anybody post the steps to intereaction with xml using weblogic.
    I am using jdk1.4

    The problem is solved.
    The information is given at
    http://e-docs.bea.com/wls/docs61/webapp/webappdeployment.html

  • Xsd validation of an xml.. another program...

    hiii......this is another program ..........
    please see the problem with the code..
    package com.pgs.tma;
    import java.io.*;
    import javax.xml.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import java.io.IOException;
    import org.w3c.dom.Document;
    import org.xml.sax.SAXException;
    public class valid {
         static final String JAXP_SCHEMA_SOURCE =
                        "http://java.sun.com/xml/jaxp/properties/schemaSource";
         public static void main(String args[]) throws IOException, SAXException, ParserConfigurationException
         if(args.length < 2)
                             System.err.println("usage is:");
                             System.err.println(" java -jar tips.jar -validatedom "
                                                      + "xml.xml xsd.xsd");
                             return;
         System.out.println(args[0]);
         System.out.println(args[1]);
         File input = new File(args[0]),
                             schema = new File(args[1]);
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setNamespaceAware(true);
              factory.setValidating(true);
         System.out.println("1");
         try{
              System.out.println("2");
              factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
    "http://www.w3.org/2001/XMLSchema");
              System.out.println("3");
              factory.setAttribute(JAXP_SCHEMA_SOURCE,"C://TWWorkspace//TMA//input//schema.xsd");
    //     factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",schema);
         System.out.println("4");
         catch(IllegalArgumentException x)
                   System.out.println("5");
                   System.err.println(" DOM parser is not JAXP 1.2 compliant"+x);
         System.out.println("6");
         Document doc = null;
         try{       
              DocumentBuilder parser = factory.newDocumentBuilder();
              //factory.setErrorHandler( myErrorHandler );
              doc = parser.parse(input);
              System.out.println("7");
         catch (ParserConfigurationException e){
              System.out.println("Parser not configured: " + e.getMessage());
         catch (SAXException e){
              System.out.print("Parsing XML failed due to a " + e.getClass().getName() + ":");
              System.out.println(e.getMessage());
         catch (IOException e){
              e.printStackTrace();
         System.out.println("end of program");
    the error message is:
    C:\TWWorkspace\TMA\input\input.xml
    C:\TWWorkspace\TMA\input\schema.xsd
    1
    2
    3
    5
    DOM parser is not JAXP 1.2 compliantjava.lang.IllegalArgumentException: http://java.sun.com/xml/jaxp/properties/schemaSource
    6
    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=file:C:/TWWorkspace/TMA/input/input.xml Line=3: cvc-elt.1: Cannot find the declaration of element 'shiporder'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=4: cvc-elt.1: Cannot find the declaration of element 'orderperson'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=5: cvc-elt.1: Cannot find the declaration of element 'shipto'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=6: cvc-elt.1: Cannot find the declaration of element 'name'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=7: cvc-elt.1: Cannot find the declaration of element 'address'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=8: cvc-elt.1: Cannot find the declaration of element 'city'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=9: cvc-elt.1: Cannot find the declaration of element 'country'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=11: cvc-elt.1: Cannot find the declaration of element 'item'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=12: cvc-elt.1: Cannot find the declaration of element 'title'.
    Error: URI=file:C:/TWWorkspace/TMA/input/input.xml Line=13: cvc-elt.1: Cannot find the declaration of element 'note'.
    7
    end of program

    I see you problem but the strictness of XML is essential. One has learned from of HTML - each browser trying to fix and show the stuff in spite of, say, invalid tags. To blow up at the first error is a compliant (and maybe desired?) behaviour.

  • Javax.xml.ws.soap.SOAPFaultException: InvalidSecurity : error in processing the WS-Security security header error while invoking FinancialUtilService using HTTP proxy client

    I am trying to invoke FinancialUtilService using HTTP proxy client. I am getting below error while i am trying to invoke this service. Using FusionServiceTester i am able to invoke service and upload file to UCM. Using oracle.ucm.fa_client_11.1.1.jar also i am able to upload file to UCM without any issue. But using HTTP proxy client i am facing below error. Can anyone please help me. PFA code i am using to invoke this service.
    javax.xml.ws.soap.SOAPFaultException: InvalidSecurity : error in processing the WS-Security security header
      at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:197)
      at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:125)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:95)
      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
      at $Proxy43.uploadFileToUcm(Unknown Source)
      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 weblogic.wsee.jaxws.spi.ClientInstance$ClientInstanceInvocationHandler.invoke(ClientInstance.java:363)
      at $Proxy44.uploadFileToUcm(Unknown Source)
      at com.oracle.xmlns.apps.financials.commonmodules.shared.financialutilservice.FinancialUtilServiceSoapHttpPortClient.invokeUpload(FinancialUtilServiceSoapHttpPortClient.java:299)
      at com.oracle.xmlns.apps.financials.commonmodules.shared.financialutilservice.FinancialUtilServiceSoapHttpPortClient.main(FinancialUtilServiceSoapHttpPortClient.java:273)
    Process exited with exit code 0.
    Message was edited by: Oliver Steinmeier
    Removed attachment

    Hi Jani,
    Thanks for your reply.
    I am new to webservices and we are trying to do a POC on invoking FinancialUtilService using HTTP proxy client. I am following steps mentioned in attached pdf section "Invoking FinancialUtil Service using Web Service Proxy Client". I have imported certificate using below command. 
         keytool -import -trustcacerts -file D:\Retek\Certificate.cer -alias client -keystore D:\Retek\default-keystore.jks -storepass welcome1
    Invoking
        SecurityPolicyFeature[] securityFeature =
        new SecurityPolicyFeature[] { new
        SecurityPolicyFeature("oracle/wss11_saml_token_with_message_protection_client_policy")};
        financialUtilService_Service = new FinancialUtilService_Service();
        FinancialUtilService financialUtilService= financialUtilService_Service.getFinancialUtilServiceSoapHttpPort(securityFeature);
        // Get the request context to set the outgoing addressing properties
        WSBindingProvider wsbp = (WSBindingProvider)financialUtilService;
        WSEndpointReference replyTo =
          new WSEndpointReference("https://efops-rel91-patchtest-external-fin.us.oracle.com/finFunShared/FinancialUtilService", WS_ADDR_VER);
        String uuid = "uuid:" + UUID.randomUUID();
        wsbp.setOutboundHeaders( new StringHeader(WS_ADDR_VER.messageIDTag, uuid), replyTo.createHeader(WS_ADDR_VER.replyToTag));
        wsbp.getRequestContext().put(WSBindingProvider.USERNAME_PROPERTY, "fin_user1");
        wsbp.getRequestContext().put(WSBindingProvider.PASSWORD_PROPERTY,  "Welcome1");
        wsbp.getRequestContext().put(ClientConstants.WSSEC_RECIPIENT_KEY_ALIAS,"service");
        wsbp.getRequestContext().put(ClientConstants.WSSEC_KEYSTORE_LOCATION, "D:/Retek/default-keystore.jks");
        wsbp.getRequestContext().put(ClientConstants.WSSEC_KEYSTORE_PASSWORD, "welcome1" );
        wsbp.getRequestContext().put(ClientConstants.WSSEC_KEYSTORE_TYPE, "JKS" );
        wsbp.getRequestContext().put(ClientConstants.WSSEC_SIG_KEY_ALIAS, "client" );
        wsbp.getRequestContext().put(ClientConstants.WSSEC_SIG_KEY_PASSWORD, "password" );
        wsbp.getRequestContext().put(ClientConstants.WSSEC_ENC_KEY_ALIAS, "client" );
        wsbp.getRequestContext().put(ClientConstants.WSSEC_ENC_KEY_PASSWORD, "password" );
    SEVERE: WSM-00057 The certificate, client, is not retrieved.
    SEVERE: WSM-00137 The encryption certificate, client, is not retrieved due to exception oracle.wsm.security.SecurityException: WSM-00057 : The certificate, client, is not retrieved..
    SEVERE: WSM-00161 Client encryption public certificate is not configured for Async web service client
    SEVERE: WSM-00005 Error in sending the request.
    SEVERE: WSM-07607 Failure in execution of assertion {http://schemas.oracle.com/ws/2006/01/securitypolicy}wss11-saml-with-certificates executor class oracle.wsm.security.policy.scenario.executor.Wss11SamlWithCertsScenarioExecutor.
    SEVERE: WSM-07602 Failure in WS-Policy Execution due to exception.
    SEVERE: WSM-07501 Failure in Oracle WSM Agent processRequest, category=security, function=agent.function.client, application=null, composite=null, modelObj=FinancialUtilService, policy=oracle/wss11_saml_token_with_message_protection_client_policy, policyVersion=null, assertionName={http://schemas.oracle.com/ws/2006/01/securitypolicy}wss11-saml-with-certificates.
    oracle.wsm.common.sdk.WSMException: WSM-00161 : Client encryption public certificate is not configured for Async web service client
      at oracle.wsm.security.policy.scenario.executor.Wss11SamlWithCertsScenarioExecutor.sendRequest(Wss11SamlWithCertsScenarioExecutor.java:173)
      at oracle.wsm.security.policy.scenario.executor.SecurityScenarioExecutor.execute(SecurityScenarioExecutor.java:545)
      at oracle.wsm.policyengine.impl.runtime.AssertionExecutor.execute(AssertionExecutor.java:41)
      at oracle.wsm.policyengine.impl.runtime.WSPolicyRuntimeExecutor.executeSimpleAssertion(WSPolicyRuntimeExecutor.java:608)
      at oracle.wsm.policyengine.impl.runtime.WSPolicyRuntimeExecutor.executeAndAssertion(WSPolicyRuntimeExecutor.java:335)
      at oracle.wsm.policyengine.impl.runtime.WSPolicyRuntimeExecutor.execute(WSPolicyRuntimeExecutor.java:282)
      at oracle.wsm.policyengine.impl.PolicyExecutionEngine.execute(PolicyExecutionEngine.java:102)
      at oracle.wsm.agent.WSMAgent.processCommon(WSMAgent.java:915)
      at oracle.wsm.agent.WSMAgent.processRequest(WSMAgent.java:436)
      at oracle.wsm.agent.handler.WSMEngineInvoker.handleRequest(WSMEngineInvoker.java:393)
      at oracle.wsm.agent.handler.wls.WSMAgentHook.handleRequest(WSMAgentHook.java:239)
      at weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory$JAXRPCTube.processRequest(TubeFactory.java:220)
      at weblogic.wsee.jaxws.tubeline.FlowControlTube.processRequest(FlowControlTube.java:98)
      at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:604)
      at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:563)
      at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:548)
      at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:445)
      at com.sun.xml.ws.client.Stub.process(Stub.java:259)
      at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:152)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:115)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:95)
      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
      at $Proxy43.uploadFileToUcm(Unknown Source)
      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 weblogic.wsee.jaxws.spi.ClientInstance$ClientInstanceInvocationHandler.invoke(ClientInstance.java:363)
      at $Proxy44.uploadFileToUcm(Unknown Source)
      at com.oracle.xmlns.apps.financials.commonmodules.shared.financialutilservice.FinancialUtilServiceSoapHttpPortClient.invokeUpload(FinancialUtilServiceSoapHttpPortClient.java:111)
      at com.oracle.xmlns.apps.financials.commonmodules.shared.financialutilservice.FinancialUtilServiceSoapHttpPortClient.main(FinancialUtilServiceSoapHttpPortClient.java:86)
    Caused by: oracle.wsm.security.SecurityException: WSM-00161 : Client encryption public certificate is not configured for Async web service client
      at oracle.wsm.security.policy.scenario.processor.Wss11X509TokenProcessor.insertClientEncCertToWSAddressingHeader(Wss11X509TokenProcessor.java:979)
      at oracle.wsm.security.policy.scenario.processor.Wss11X509TokenProcessor.build(Wss11X509TokenProcessor.java:206)
      at oracle.wsm.security.policy.scenario.executor.Wss11SamlWithCertsScenarioExecutor.sendRequest(Wss11SamlWithCertsScenarioExecutor.java:164)
      ... 30 more
    Caused by: oracle.wsm.security.SecurityException: WSM-00057 : The certificate, client, is not retrieved.
      at oracle.wsm.security.jps.WsmKeyStore.getJavaCertificate(WsmKeyStore.java:534)
      at oracle.wsm.security.jps.WsmKeyStore.getCryptCert(WsmKeyStore.java:570)
      at oracle.wsm.security.policy.scenario.processor.Wss11X509TokenProcessor.insertClientEncCertToWSAddressingHeader(Wss11X509TokenProcessor.java:977)
      ... 32 more
    SEVERE: WSMAgentHook: An Exception is thrown: WSM-00161 : Client encryption public certificate is not configured for Async web service client
    File upload failed
    javax.xml.ws.WebServiceException: javax.xml.rpc.JAXRPCException: oracle.wsm.common.sdk.WSMException: WSM-00161 : Client encryption public certificate is not configured for Async web service client
      at weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory$JAXRPCTube.processRequest(TubeFactory.java:231)
      at weblogic.wsee.jaxws.tubeline.FlowControlTube.processRequest(FlowControlTube.java:98)
      at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:604)
      at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:563)
      at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:548)
      at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:445)
      at com.sun.xml.ws.client.Stub.process(Stub.java:259)
      at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:152)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:115)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:95)
      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
      at $Proxy43.uploadFileToUcm(Unknown Source)
      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 weblogic.wsee.jaxws.spi.ClientInstance$ClientInstanceInvocationHandler.invoke(ClientInstance.java:363)
      at $Proxy44.uploadFileToUcm(Unknown Source)
      at com.oracle.xmlns.apps.financials.commonmodules.shared.financialutilservice.FinancialUtilServiceSoapHttpPortClient.invokeUpload(FinancialUtilServiceSoapHttpPortClient.java:111)
      at com.oracle.xmlns.apps.financials.commonmodules.shared.financialutilservice.FinancialUtilServiceSoapHttpPortClient.main(FinancialUtilServiceSoapHttpPortClient.java:86)
    Caused by: javax.xml.rpc.JAXRPCException: oracle.wsm.common.sdk.WSMException: WSM-00161 : Client encryption public certificate is not configured for Async web service client
      at oracle.wsm.agent.handler.wls.WSMAgentHook.handleException(WSMAgentHook.java:395)
      at oracle.wsm.agent.handler.wls.WSMAgentHook.handleRequest(WSMAgentHook.java:248)
      at weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory$JAXRPCTube.processRequest(TubeFactory.java:220)
      ... 19 more

  • XSLT-transformation in Java-Mapping with javax.xml

    Hi,
    we wanna use javax.xml for transformations in Java-Mapping.
    Inside the Java-mapping we read in XSL-files to transform a XML-stream. With XSLT 1.0 everything works fine - but with XSLT 2.0 we are getting runtime errors.
    Is it possible that javax.xml only supports XSLT 1.0?
    Regards
    Wolfgang

    Hi ,
    Jaxp 1.3 is available in this link -
    http://java.sun.com/webservices/jaxp/
    Use these jar files to process XSLT 2.0.
    Nanda

  • Error: while trying to invoke the method javax.xml.transform.Transformer.

    Hi All,
    I am working on Version 12.1.8 Build(20),  I have referred  SAP notes 1294013 and placed the following files
    - serializer.jar
    - xalan.jar
    - xercesImpl.jar
    - xml-apis.jar
    - xsltc.jar
    in the specified path.
    now when i use XSLT transformation block using IllumRowsetTableWithPageBreaks.xsl i am getting an error
    [ERROR] [XSL_Transformation_0]XSLTransform error: while trying to invoke the method javax.xml.transform.Transformer.transform(javax.xml.transform.Source, javax.xml.transform.Result) of an object loaded from local variable 'processor'
    please guide me.

    Hi Alex,
    No, the case you have explained is not applicable to me. Sharing the code snippet for your reference. This is the code due to which my XSLT gives an error, if I remove these lines of code then the XSLT works fine.
    <xsl:variable name="ENERGY" select="translate(ENERGY,',','')">
         <xsl:choose>
              <xsl:when test="ENERGY= ''">
                   <xsl:value-of select="0.00"/>
              </xsl:when>
              <xsl:otherwise>
                   <xsl:value-of select="ENERGY"/>
              </xsl:otherwise>
         </xsl:choose>
    </xsl:variable>
    Also, the same XSLT works absolutely fine in 12.1 but gives error in 14.0 SP05.
    Warm Regards,
    Anuj

Maybe you are looking for